Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting pixel format #46

Open
machinekoder opened this issue Jun 18, 2019 · 4 comments
Open

Selecting pixel format #46

machinekoder opened this issue Jun 18, 2019 · 4 comments

Comments

@machinekoder
Copy link
Contributor

Is there a way to select the v4l2 cameras pixel format when starting the opencv stream?

It looks like it selects the uncompressed stream per default on my device, which rather slow at 1080p even with USB 3.0.

@J-Rojas
Copy link

J-Rojas commented Jul 18, 2019

The output format should also be selectable. BGR8 is hard-coded.

@furushchev
Copy link
Collaborator

furushchev commented Jul 23, 2019

Sorry for late response.

@J-Rojas I think what @machinekoder mentioned about is not about format of published image messages but image data format captured from v4l2 camera device.

@machinekoder Currently since we don't specify any option to set pixel format for v4l2 camera device, OpenCV tries to set possible format in certain order.
( https://github.com/opencv/opencv/blob/f663e8f903645a3dd66f6833f63717b86e861d77/modules/videoio/src/cap_v4l.cpp#L485 )
Looking at the code, it looks we can change the format by setting cv::CAP_PROP_FOURCC
( https://github.com/opencv/opencv/blob/f663e8f903645a3dd66f6833f63717b86e861d77/modules/videoio/src/cap_v4l.cpp#L1832 )

I'll create a PR to support the feature when I have time.

@marcelino-pensa
Copy link

I was able to get images from the MJPG stream by adding the following in this line:
cap->set(cv::CAP_PROP_FOURCC, cv::VideoWriter::fourcc('M','J','P','G'));

It worked, but the CPU usage went through the roof... not sure if that's expected, but I'd appreciate if anyone had any ideas on how to overcome high CPU usage, or whether that'll be a given for getting data from a MJPG stream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants