getsnapshot function is leaving blank (all black) photos

2 views (last 30 days)
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);
untitled.png
  2 Comments
Siddharth Bhutiya
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.
Anthony Zand
Anthony Zand on 21 Nov 2018
Hello,
I am using three logitech Brio webcams.
I just wanted to follow up on my problem! I was able to get the code to function properly by performing a complete restart of the PC and camera configuration. The problem is reproducable and seems to lie when the PC is placed in a standby or sleep mode, all three webcams would not function properly when awoken with this script.
The restart had fixed it, I am unsure which settings may cause for this to occur but I believe this issue is outside of MatLab space, and in the PC configuration space.

Sign in to comment.

Accepted Answer

Cris LaPierre
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
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.
Anthony Zand
Anthony Zand on 21 Nov 2018
Thanks for the follow up, in my other comment I replyed how I was able to resolve the issue. However, if I do run into my problem again, I will try this method. I see how the implimentation of start(TopCam) would wake the device out of the standby state it is in and resolve the problem. Thank you!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!