videoio: Support Orbbec Astra 3D cameras using OpenNI2 API#18763
videoio: Support Orbbec Astra 3D cameras using OpenNI2 API#18763opencv-pushbot merged 1 commit intoopencv:masterfrom
Conversation
| // Open color stream | ||
| VideoCapture colorStream(CAP_V4L2); | ||
| // Open depth stream | ||
| VideoCapture depthStream(CAP_OPENNI2_ASTRA); |
There was a problem hiding this comment.
Main problem of this approach is how to sync data from these streams.
There was a problem hiding this comment.
@alalek, we had a conversation with Orbbec (the producer of Astra cameras), currently this is the only possibility, i.e. the hardware itself does not provide any hardware synchronization and the streaming from both the depth sensor and the color sensor is done absolutely independently.
| while (true) | ||
| { | ||
| std::unique_lock<std::mutex> lk(mtx); | ||
| dataReady.wait(lk); |
There was a problem hiding this comment.
It may also be unblocked spuriously.
https://en.cppreference.com/w/cpp/thread/condition_variable/wait
Need to add while loop with condition check.
|
|
||
| //! [Decode color] | ||
| // Decode grabbed color data | ||
| colorStream.retrieve(colorFrame); |
There was a problem hiding this comment.
Threads should not call .grab() during .retrieve() calls from another thread.
- OpenCV API is not thread safe in this way (except storage containers partially, like Mat/UMat). Threads can't invoke methods of the same object instance without extra external synchronization.
- Capturing garbage may appear if buffers queue is full.
There was a problem hiding this comment.
Should be fixed in the latest update.
|
General notes on Tutorial text:
|
doc/tutorials/videoio/astra.markdown
Outdated
|
|
||
| -# Configure OpenCV with OpenNI support enabled by setting the WITH_OPENNI2 flag in CMake. If the OpenNI | ||
| library is found, OpenCV will be built with OpenNI2 support (see the status of OpenNI2 in CMake log). | ||
| You may also like to enable the BUILD_EXAMPLES flag to get a code sample working with your Astra camera. |
There was a problem hiding this comment.
Please add piece of CMake output with proper OpenNI detection as example here.
doc/tutorials/videoio/astra.markdown
Outdated
|
|
||
| @snippet samples/cpp/tutorial_code/videoio/astra/astra.cpp Open streams | ||
|
|
||
| The first object will use the regular Video 4 Linux interface to access the color sensor. The second one |
There was a problem hiding this comment.
Video4Linux in one word.
There was a problem hiding this comment.
doc/tutorials/videoio/astra.markdown
Outdated
|
|
||
| @snippet samples/cpp/tutorial_code/videoio/astra/astra.cpp Get properties | ||
|
|
||
| The following properties of cameras available through OpenNI interfaces are supportedf for the depth |
Only depth sensor is supported. Color sensor is accessible as a regular UVC camera.
This pull request includes minor modifications to the OpenNI module of VideoCapture to handle Orbbec Astra cameras properly. Only depth sensor reading is supported. The color sensor is accessible as a regular UVC camera.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.