MJPG output from webcam (MATLAB Support Package for USB Webcams)

Is it somehow possible to acquire images in MJPG instead of YUV format with the snapshot function?
I need a higher framerate from my webcam. According to the datasheet YUV is 5 fps@1600x1200 while MJPG is 15 fps@1600x1200.

Answers (2)

sir,i think may be consider the camera device config

10 Comments

...but how? I can only see this in MATLAB (edit: copied from MATLAB help to show the general principle):
cam =
webcam with properties:
Name: 'Logitech Webcam 250'
Resolution: '640x480'
AvailableResolutions: {1x11 cell}
Exposure: -4
Gain: 253
Saturation: 32
WhiteBalance: 8240
ExposureMode: 'auto'
Sharpness: 48
Brightness: 128
BacklightCompensation: 1
Contrast: 32
And then I can use ffmpeg to see some other device config:
Where can I set the camera to MJPEG?
People have been doing mjpeg streaming with that webcam in Linux https://community.octoprint.org/t/usb-webcams-known-to-work-with-mjpg-streamer/21149
I can stream MJPEG too with my webcam, but not in Matlab. There simply seems no way to enable this?
Ok, it sems that this is not 100% Matlab related.... Still, it is very unclear to me how I can change the mode of the webcam and set it to YUYV422 or MJPEG.
I am playing around with ffmpeg, I can e.g. set the following:
ffmpeg -f dshow -pixel_format yuyv422 -show_video_device_dialog true -i video="OPTOLUTION_USB_Cam1"
Then I get (amonst other stuff I dont fully understand) the following reply from ffmpeg:
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1600x1200, 5 fps, 5 tbr, 10000k tbn, 10000k tbc
I can also set something else with ffmpeg:
ffmpeg -f dshow -vcodec mjpeg -show_video_device_dialog true -i video="OPTOLUTION_USB_Cam1"
... then the reply is:
Stream #0:0: Video: mjpeg (Baseline) (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 1600x1200, 30 fps, 30 tbr, 10000k tbn, 10000k tbc
So, apparently this somehow affects the setting of the webcam. But this still doesn't seem to have an effect inside Matlab. However, I think that I "accidentally" managed to run my Webcam in Matlab using MJPEG a single time (because it had like 50 fps in the preview video). But I cannot reproduce this... Any ideas?
Ok, so without any configuration work, see the following effect:
With MatlabR2019b, Webcam uses YUV
With Matlab R2021b, Webcam uses MJPEG...
This is pretty bad, how can I influence this?
sir,may be update the matlab version
I am confused. The device response says "Logitech Webcam 250", but the C250 contains no support for 1600 x 1200 in any mode. The highest resolution video for it is 640 x 480.
I just copied the text from MATLAB help to show what options exist in general. I am pretty sure that it doesn't matter what camera I use. MATLAB just silently changed the way it handles webcams, there seems to be no changelog available. So I am totally stuck and can't continue developing hardware for people that use my toolbox. This is pretty frustrating.... I am using this camera: https://www.arducam.com/product/arducam-2mp-global-shutter-usb-camera-board-for-computer-50fps-ov2311-monochrome-uvc-webcam-module-with-low-distortion-m12-lens-without-microphones-compatible-with-windows-linux-android-and-mac-os/
And it is super important to know of MJPEG or another format is used (I absolutely prefer non compressed data), because I am triggering the camera. The timing between hardware Trigger input and the actual exposure needs to be known exactly for my application. And this timing is totally different between MJPEG and other formats. So in the end, I think I have to use ffmpeg (called from my MATLAB GUI) to capture the data which really sucks.
@yanqi liu: The application is not for me. It is for the users of a popular toolbox. But with a random and apparently undocumented change of MATLABs behaviour, this will be pretty hard.
Hi has anyone resolved this problem? I'm having the exact problem now. I'm using a logitech brio 4k and I can't seems to be available to load a 4k resolutions due to this problem. thanks in advance

Sign in to comment.

The MATLAB Support Package for USB Webcams supports the MJPEG format from R2023a release.

Categories

Products

Release

R2018b

Asked:

SG
on 9 Apr 2019

Answered:

on 6 Jun 2024

Community Treasure Hunt

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

Start Hunting!