How to show an image saved in runtime at a matrix as a video?

조회 수: 1 (최근 30일)
Francisco Mendoza
Francisco Mendoza 2014년 12월 7일
댓글: Francisco Mendoza 2014년 12월 7일
Hi, all, i have a problem with this script that doesn't do what a need to; i'm getting initiated in Matlab, so i'm waiting you to support me for. I'll be very grateful.
The code is:
_____________________________________________________
function videomonocolor
vid = videoinput('macvideo', 1, 'YCbCr422_1280x720');
k=0;
c=1;
start(vid);
while c<100
A = getsnapshot(vid);
A=imresize(A,0.3);
rgb = A;
I = ycbcr2rgb(rgb);
imshow(I)
c=c+1;
end
end
__________________________________________________________
As You can see, the script is very austere; then well, what im trying to do is take a snapshot from my macbook's camera and give it to a matrix that could be modified, saving, so, all informatión of image, then work with it, and display it again. All this have a purpose, but now, I just have one problem: the imshow doesn't show me anything. Some times show just the last image that was taken, when the program it's done. I think isn't the appropriate way to display every image and show almost at runtime, just like a video motion. I don't want to take a sequence of photos, then use the comand that convert this same sequence to a video. I want to work with an image at the time, and show the same information that has been token. I know about the function that do this, showing a preview of the video.. but i want every snapshot for do something with it... I apologise for my english, that is not the best. Greetings from México, and good night here.

답변 (2개)

Image Analyst
Image Analyst 2014년 12월 7일
편집: Image Analyst 2014년 12월 7일
The badly-named I is probably a double and imshow doesn't like RGB doubles. Cast it to uint8 and it will probably be okay. But a worse problem is that you're possibly taking an RGB image and passing it in to ycbcr2rgb() which expects an input that is of YCbCr color space, not RGB color space. If you call imshow(A), does it look like a normally colored image? If so why are you even calling ycbcr2rgb() since A is already RGB?
How do you make sure the badly-named A is an RGB image? Well after you instantiate vid you have to set the returned color space:
vid.ReturnedColorSpace = 'rgb';
  댓글 수: 12
Image Analyst
Image Analyst 2014년 12월 7일
See my attached demo where I track a green sharpie in a video. Just follow my example.
Francisco Mendoza
Francisco Mendoza 2014년 12월 7일
Thanks for the script, and all the support. I'll work on it :')

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


Francisco Mendoza
Francisco Mendoza 2014년 12월 7일
Here is image:

Community Treasure Hunt

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

Start Hunting!

Translated by