How to use Webread and analyze video
9 次查看(过去 30 天)
显示 更早的评论
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);
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
0 个评论
采纳的回答
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!
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!