How to use Webread and analyze video

16 Ansichten (letzte 30 Tage)
Life is Wonderful
Life is Wonderful am 22 Mai 2023
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

Akzeptierte Antwort

Piyush Patil
Piyush Patil am 31 Mai 2023
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!

Weitere Antworten (0)

Tags

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by