MATLAB: Getsnapshot function is leaving blank (all black) photos

getsnapshotimage acquisition

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

Best Answer

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);