Skip to content

videoio: Support Orbbec Astra 3D cameras using OpenNI2 API#18763

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
GArik:orbbec
Nov 16, 2020
Merged

videoio: Support Orbbec Astra 3D cameras using OpenNI2 API#18763
opencv-pushbot merged 1 commit intoopencv:masterfrom
GArik:orbbec

Conversation

@GArik
Copy link
Copy Markdown
Contributor

@GArik GArik commented Nov 9, 2020

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

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

// Open color stream
VideoCapture colorStream(CAP_V4L2);
// Open depth stream
VideoCapture depthStream(CAP_OPENNI2_ASTRA);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main problem of this approach is how to sync data from these streams.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may also be unblocked spuriously.

https://en.cppreference.com/w/cpp/thread/condition_variable/wait

Need to add while loop with condition check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


//! [Decode color]
// Decode grabbed color data
colorStream.retrieve(colorFrame);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed in the latest update.

@asmorkalov
Copy link
Copy Markdown
Contributor

asmorkalov commented Nov 12, 2020

General notes on Tutorial text:

  • Please add image with result view in jpeg format. It could be camera view on some simple shape or just general object on table.
  • Add reference to OpenCV documentation for VideoCapture
  • Use @ref to add references to generic OpenCV classes and enums simplify navigation in documentation for beginners.
  • I prpose to add "Crbbec" to name of tutorial and code files, because "astra" is very generic name.


-# 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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add piece of CMake output with proper OpenNI detection as example here.


@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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Video4Linux in one word.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"supportedf" - typo

Only depth sensor is supported. Color sensor is accessible as a
regular UVC camera.
@GArik GArik changed the title Add tutorial on how to use Orbbec Astra 3D cameras videoio: Support Orbbec Astra 3D cameras using OpenNI2 API Nov 13, 2020
@asmorkalov asmorkalov removed the category: documentation Documentation fix or update label Nov 16, 2020
@asmorkalov asmorkalov self-requested a review November 16, 2020 08:35
Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me.

@asmorkalov
Copy link
Copy Markdown
Contributor

@alalek We discussed the solution with @vpisarev and decided to re-design Orbbec support in other way. The PR contains general fixes to initialize streams correctly and do not crash samples. Tutorial will be proposed in the next PR.

@opencv-pushbot opencv-pushbot merged commit 56074c2 into opencv:master Nov 16, 2020
@alalek alalek mentioned this pull request Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants