getsnapshot function is leaving blank (all black) photos
2 views (last 30 days)
Show older comments
Anthony Zand
on 18 Nov 2018
Commented: Anthony Zand
on 21 Nov 2018
Using Image Acquisition Toolbox, "getsnapshot" function is ending up with blank (all black) photos.
Yet, when I use preview(TopCam), the camera initializes and shows video properly.
My understanding is that, getsnapshot will turn on the camera, wait for video stream to begin, take a frame from this stream, and save it to memory, then terminate stream.
I am unsure where the black or blank photo data is coming from.
Below is my code and output:
TopCam = videoinput('winvideo', 2, 'MJPG_4096x2160');
TopImg = getsnapshot(TopCam);
image(TopImg);

2 Comments
Siddharth Bhutiya
on 20 Nov 2018
What camera are you using?
Could you try doing getsnapshot 5-6 times in a row and see if that gives you the image. Some cameras have a warm up period that it takes, before returning proper images.
Accepted Answer
Cris LaPierre
on 21 Nov 2018
What error messages are you getting? I obviously don't have the same hardware as you, but on my computer, this code works. Note that the camera id is in single quotes, and i have to start the camera.
TopCam = videoinput('winvideo', '1');
start(TopCam);
TopImg = getsnapshot(TopCam);
stop(TopCam)
image(TopImg);
2 Comments
Cris LaPierre
on 21 Nov 2018
Of course, now that I got it working once, it runs even if I strip the code back down to your original code. Still, the first time, I did get a black screen just like you.
More Answers (0)
See Also
Categories
Find more on Image Acquisition Support Packages for Hardware Adaptors (Generic Video Interface) 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!