Display the different size of preview image from that of the captured images.

Hi, I have a question about webcam Image Capture and Preview.
The following is my simple code. This cpde captures images from the webcam every one second while displaying the preview image.
----------------------------------------------------------------------
cap1 = videoinput('winvideo', ID_num1,'YUY2_1920x1080');
preview(cap1)
for 1 = 1:1000
frame1 = getsnapshot(cap1);
imwrite(frame1,'title','.jpg');
pause(1)
end
----------------------------------------------------------------------
The preview image from my webcam is 1920x1080. Instead, I would like to display the preview image 320x240 while capturing the images from the webcam for 1920x1080.
Is there any suggestion or any way to solve my problem?
Thank you for your help and kindness.

 Accepted Answer

What you basically want is a preview window that is smaller. You can achieve that by forcing the figure (and axes) to be a smaller dimension. Try something like this:
cap1 = videoinput('winvideo', ID_num1,'YUY2_1920x1080');
figure('Units', 'pixels', 'Position', [100 100 340 260]);
axes('Units', 'pixels', 'Position', [10 10 320 240]);
vidRes = get(cap1, 'VideoResolution');
nBands = get(cap1, 'NumberOfBands');
hImage = image( zeros(vidRes(2), vidRes(1), nBands) );
preview(cap1, hImage)
for ii = 1:1000
frame1 = getsnapshot(cap1);
imwrite(frame1,sprintf('image%03d.jpg', ii));
pause(1)
end

More Answers (3)

Perhaps preview(imresize(cap1,[320 240])) or something similar?
Mr. Roberson
Sorry, it didnt work. I found useful info. let me try this.http://www.mathworks.com/help/toolbox/imaq/rn/bqnawj5-1.html
So far I have:
Changing ROIPositon is not a solution in my case. However, it does some jobs.
To change ROIPosition:
cap1.ROIPosition = [0 0 320 240];
cap1.ROIPosition = [0 0 1920 1080];
When I change ROIPosition, the preview image also changes according to ROIPosition.
Instead, use this first code to display the figure at low resolution(http://www.mathworks.com/help/toolbox/imaq/f11-74309.html#f11-76067). Then, change ROIPosition before the capture the image.
The problem in this way is dramatic decrease in performance.

Community Treasure Hunt

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

Start Hunting!