mirror of
https://github.com/opencv/opencv.git
synced 2026-09-11 04:43:22 -05:00
fbc9bf4ba0cc830f8406ceb90f5fa24c01c6de8c
open() used to accept only Mono8/Mono12/Mono16/BayerGR8 and silently forced the camera to Mono8 for everything else, so color cameras were degraded to grayscale. retrieveFrame() passed the payload through as is, leaving the demosaicing and the bit depth of the result to the caller. open() now enumerates the pixel formats the camera offers and picks the best one it can decode, in this order: 1. true color - BGR8/RGB8, BGRa8/RGBa8, BGR10/12, RGB10/12, 2. Bayer CFA - BayerRG/BG/GR/GB, 8, 10, 12 and 16 bit, 3. grayscale - Mono8, Mono10, Mono12, Mono14, Mono16. The least deep format is preferred within a group, as the result is 8 bit anyway. Bit packed formats are not selected, their payload cannot be mapped to a Mat without unpacking it first. retrieveFrame() converts whatever arrives to BGR CV_8UC3: Bayer data is demosaiced, RGB is swapped to BGR, grayscale is replicated to three channels and deeper formats are scaled down from their significant bits. The pixel format description is kept in a single table, which also drives CAP_PROP_FOURCC. Both directions of the property now cover all the formats above instead of just four, setProperty() reports failure for a fourcc the camera cannot provide and refreshes the cached format description, which the old code did not do. Note that Aravis names a Bayer pattern after its top left 2x2 tile, while OpenCV names it after the second row, so the codes are related by an R <-> B swap: BayerRG8 is demosaiced with COLOR_BayerBG2BGR. An explicit payload size check is added to retrieveFrame(), the frame is no longer wrapped in a Mat without knowing the buffer is large enough.
OpenCV: Open Source Computer Vision Library
Resources
- Homepage: https://opencv.org
- Courses: https://opencv.org/courses
- Docs: https://docs.opencv.org/4.x/
- Q&A forum: https://forum.opencv.org
- previous forum (read only): https://answers.opencv.org
- Issue tracking: https://github.com/opencv/opencv/issues
- Additional OpenCV functionality: https://github.com/opencv/opencv_contrib
- Donate to OpenCV: https://opencv.org/support/
Contributing
Please read the contribution guidelines before starting work on a pull request.
Summary of the guidelines:
- One pull request per issue;
- Choose the right base branch;
- Include tests and documentation;
- Clean up "oops" commits before submitting;
- Follow the coding style guide.
Additional Resources
- Submit your OpenCV-based project for inclusion in Community Friday on opencv.org
- Subscribe to the OpenCV YouTube Channel featuring OpenCV Live, an hour-long streaming show
- Follow OpenCV on LinkedIn for daily posts showing the state-of-the-art in computer vision & AI
- Apply to be an OpenCV Volunteer to help organize events and online campaigns as well as amplify them
- Follow OpenCV on Mastodon in the Fediverse
- Follow OpenCV on Twitter
- OpenCV.ai: Computer Vision and AI development services from the OpenCV team.
Description
Languages
C++
87.6%
C
3.2%
Python
2.9%
CMake
2%
Java
1.5%
Other
2.6%