简体   繁体   中英

How to use my own functions with CMake for OpenCV

I am using OpenCV 2.3 on Windows 7 32 bits with Visual C++ 2010. My CMakeLists file looks like that:

SET( PROJECT_NAME Tennis_tracking )
PROJECT( ${PROJECT_NAME} )
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
FIND_PACKAGE( OpenCV REQUIRED )
ADD_EXECUTABLE( ${PROJECT_NAME} main.cpp )
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${OpenCV_LIBS} )
ADD_EXECUTABLE( histogram histogram.cpp )
TARGET_LINK_LIBRARIES( histogram ${OpenCV_LIBS} )

For example I'd like to create a custom function "getImageHistogram" for example (which already exists in OpenCV) that will be used by main.cpp. The header and main files are done, how do I link those in my CMakeLists?

Thank you very much.

As long as you are using C++ you can define this function within another (custom) namespace and call it as custom::getImageHistogram() .

And for the CMake part, there's nothing special to be done since you are already adding that file to the build process:

ADD_EXECUTABLE( ${PROJECT_NAME} main.cpp )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM