How to use Webread and analyze video

조회 수: 4 (최근 30일)
Life is Wonderful
Life is Wonderful 2023년 5월 22일
댓글: Life is Wonderful 2023년 5월 31일
Hi there,
I am trying to perform webread using the following link,
httpsUrl = 'https://upload.wikimedia.org/wikipedia/en/transcoded/4/4c/Green_and_cyan-green_demonstration_of_frame_rate_control_FRC_4K60.webm/Green_and_cyan-green_demonstration_of_frame_rate_control_FRC_4K60.webm.160p.webm';
imageUrl = strcat(httpsUrl, '/assets/computerVision.jpg');
rgb = webread(imageUrl);
Error using matlab.internal.webservices.HTTPConnector/copyContentToByteArray
The server returned the status 404 with message "Not Found" in response to the request to URL https://upload.wikimedia.org/wikipedia/en/transcoded/4/4c/Green_and_cyan-green_demonstration_of_frame_rate_control_FRC_4K60.webm/Green_and_cyan-green_demonstration_of_frame_rate_control_FRC_4K60.webm.160p.webm/assets/computerVision.jpg.

Error in readContentFromWebService (line 46)
byteArray = copyContentToByteArray(connection);

Error in webread (line 125)
[varargout{1:nargout}] = readContentFromWebService(connection, options);
whos rgb
I'd like to analyse the video provided in the link, and I'd like to know whether there is a better way to do it than the existing one.
Thank you

채택된 답변

Piyush Patil
Piyush Patil 2023년 5월 31일
Hello,
You can follow these steps to perform "webread" and analyze the video from the given link -
1. Download video data from the link using "webread
videoData = webread('https://upload.wikimedia.org/wikipedia/en/transcoded/4/4c/Green_and_cyan-green_demonstration_of_frame_rate_control_FRC_4K60.webm/Green_and_cyan-green_demonstration_of_frame_rate_control_FRC_4K60.webm.160p.webm');
2. Write video data to a file using "fwrite"
fid = fopen('vid_file_name.mp4', 'w');
fwrite(fid, videoData);
fclose(fid);
3. Read the video from the file using "VideoReader"
videoObj = VideoReader('vid_file_name.mp4');
4. Capture and display the video frames using a loop that iterates over all frames in the video
while hasFrame(videoObj)
frame = readFrame(videoObj);
imshow(frame);
end
5. Now you can analyze the frames as needed
Here is the example code -
% Download the video data
videoData = webread('https://upload.wikimedia.org/wikipedia/en/transcoded/4/4c/Green_and_cyan-green_demonstration_of_frame_rate_control_FRC_4K60.webm/Green_and_cyan-green_demonstration_of_frame_rate_control_FRC_4K60.webm.160p.webm');
% Write the video data to a file
fid = fopen('vid_file_name.mp4', 'w');
fwrite(fid, videoData);
fclose(fid);
% Read the video from the file
videoObj = VideoReader('vid_file_name.mp4');
% Capture and display the video frames
while hasFrame(videoObj)
frame = readFrame(videoObj);
imshow(frame);
% Analyze the frames as needed
end
Hope this helps!
  댓글 수: 1
Life is Wonderful
Life is Wonderful 2023년 5월 31일
@Piyush Patil, Excellent and Nice writeup. Thank you very much.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by