Opening my Webcam using Screen function

Hello,

I’m trying to find proper code to utilize my capture card in PTB’s Screen functionality.

MATLAB recognizes the capture card as a webcam, but I’m having trouble converting that over to something Screen can open up.

Does anyone have suggestion for the issue?

In our experiment, our AI model will be ran on a live stream of a Tetris game; using the capture card.

1 Like

PTB comes with various demos of this that may provide a good starting point. See e.g. VideoCaptureToMatlabDemo

Having the same problem (I guess), but just started digging into it. I am trying to use the StarTech DVI framegrabber USB32DVCAPRO under Win10 (MATLAB R2018b, latest PTB and gstreamer). The demo VideoToMatlabCaptureDemo crashes hard (with a gstreamer issue - what a surprise!), also under Octave, but VideoRecordingDemo does something, so I have still some hope to get it figured out.

Try VideoCaptureDemo first. Maybe specify the optional ‘roi’ parameter for your camera, e.g., [0 0 640 480] if it would be a 640x480 pixels resolution. Similar, maybe specify fps explicitely, e.g., 30 for 30 fps. Usually it works if one gives it the right parameters, but especially the Windows and macOS version sometimes needs some help if it can’t auto-detect parameters reliably, or if some capture card does not actually expose settings properly. Other than that, post full output if you run into problems, possibly at Screen(‘preference’,‘verbosity’, x) levels of x = 6 or higher.

Especially VideoCaptureToMatlabDemo.m will need customization. If you look at the code it assumes 640x480 at 30 fps and nothing else.
VideoCaptureDemo is a good starting point to play with parameters.

Appreciate the replies. But I do have one follow up. The issue is opening up a capture card that isn’t auto detected from PTB.

The device is registered in the image acquisition tool with a certain name and even configured it to represent webcam in MATLAB in general, but I am unsure how to manipulate ‘deviceID’ or ‘name’ with the correct values to identify it.

Short of finding a different driver for the capture card, I was hoping for some help there.

There isn’t a direct way from whatever Matlab’s image acquisition toolbox says to what PTB expects.

PTB supports Firewire and USB-3 machine vision cameras on Linux, and Firewire cameras on macOS, via a dedicated high-perf libdc1394 based engine. And then everything that has a suitable video capture plugin for GStreamer on all OSes.

So what’s the output of devs = Screen(‘Videocapturedevices’) ?
Or what exact vendor/model/type is your capture card?

1 Like