Filter löschen
Filter löschen

video frame saving in running loop

4 Ansichten (letzte 30 Tage)
Muhammad
Muhammad am 7 Jan. 2023
Kommentiert: Image Analyst am 8 Jan. 2023
actualy i am readig a video and taking its frame one after another in loop, what i wanna know is that how i can use each frame inn imread command as that read from specific path
vidObj = VideoReader('ch.mp4');
i=1;
while hasFrame(vidObj)
vidFrame = readFrame(vidObj);
inframe = imread('');
localcolor = [100 50 0]/255;
% convert to HSV
hsvcolor = rgb2hsv(localcolor);
hsvframe = rgb2hsv(inframe);
% substitute HS
hsvframe(:,:,1) = hsvcolor(1);
hsvframe(:,:,2) = hsvcolor(2);
% convert back to RGB
outframe = hsv2rgb(hsvframe);
imshow(outframe)
pause(1/vidObj.FrameRate);
i=i+1;
end
  1 Kommentar
Jan
Jan am 8 Jan. 2023
There is no need to call imread, because you do not want to imprt an image file. Therefore I'd simply omit this command and work with the alreayd imported frame.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 8 Jan. 2023
See attached demo. It runs through a video taking the mean R, G, and B values of the image and, optionally, writing each frame out to disk. Then it builds a new video by reading those frames on disk back in and constructing a new video from them.

Community Treasure Hunt

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

Start Hunting!

Translated by