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

Technical Source
2 min readFeb 7, 2022

--

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?

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

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

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source
Technical Source

Written by Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

No responses yet