canot convert image to movie frame using 'im2frame'

2 views (last 30 days)
here the code :
//
vObj = vision.VideoFileReader(car_video.avi);
while ~isDone(vObj)
v = step(vObj);
if (v > threshold)
a=a+1;
imshow (v);
f(a) = im2frame(v);
end
end
movie(f,10);
//
and i get error message like this 'Error using im2frame Can only make movie frames from image matrices of type double or uint8'

Answers (2)

Geoff Hayes
Geoff Hayes on 13 Oct 2014
Fitroh - according to the documentation at vision.VideoFileReader and step, the output of the step function is a frame, so the im2frame function should be unnecessary. Verify the class type of v by putting a breakpoint at the line
f(a) = im2frame(v);
and then run the program. When the debugger pauses at this line, type the following in the Command Window
class(v)
Based on the output of this call, if the class type is struct then it is (probably) a frame with the fields cdata and colormap. If that is the case, then you can replace your above line with just
f(a) = v;
Try the above and see what happens!

Image Analyst
Image Analyst on 13 Oct 2014
What is f? Is it a struct? It must be to use get frame() output. See attached demo.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!