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

Add example with C++ and OpenCV 2 #646

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

remmel
Copy link

@remmel remmel commented Nov 16, 2021

Add example using C++ and OpenCV 2 to display and saving RGB + D frames
based on https://openkinect.org/wiki/C%2B%2BOpenCvExample
Need to enable BUILD_CV (set (BUILD_CV ON))

Signed-off-by: Remy Mellet remy.mellet@gmail.com

find_package(Threads)
find_package( OpenCV REQUIRED )

include_directories(. ${THREADS_PTHREADS_INCLUDE_DIR})
Copy link
Author

@remmel remmel Nov 16, 2021

Choose a reason for hiding this comment

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

include_directories(. ${THREADS_PTHREADS_INCLUDE_DIR}) doesn't seems to be needed, maybe other OS? (tested on Ubuntu 20.04 LTS)

Copy link
Contributor

Choose a reason for hiding this comment

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

It should not be necessary - I think THREADS_PTHREADS_INCLUDE_DIR does not even exist in CMake anymore. But since you already require cxx_std_11, you could use std::thread and std::mutex instead of pthread in the code. Then there would be no need to find Threads package at all.

@remmel remmel changed the title Add example with C++ and OpenCV 4 Add example with C++ and OpenCV 2 Nov 17, 2021
find_package(Threads)
find_package( OpenCV REQUIRED )

include_directories(. ${THREADS_PTHREADS_INCLUDE_DIR})
Copy link
Contributor

Choose a reason for hiding this comment

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

It should not be necessary - I think THREADS_PTHREADS_INCLUDE_DIR does not even exist in CMake anymore. But since you already require cxx_std_11, you could use std::thread and std::mutex instead of pthread in the code. Then there would be no need to find Threads package at all.


include_directories(. ${THREADS_PTHREADS_INCLUDE_DIR})

add_executable( freenect-cppopencv cppopencv.cpp)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion - make this conditional on if (BUILD_EXAMPLES).

Copy link
Author

Choose a reason for hiding this comment

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

that CMakeLists.txt is included only if BUILD_CV is enabled. Are you sure you want a 2nd condition?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally yes because this is an example. But I see the existing cvdemo does not depend on BUILD_EXAMPLES so it's just a suggestion.

@piedar piedar added this to the next milestone Jan 3, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants