简体   繁体   English

如何在CMake for OpenCV中使用我自己的功能

[英]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: 我正在Windows 7 32位和Visual C ++ 2010上使用OpenCV 2.3。我的CMakeLists文件如下所示:

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. 例如,我想创建一个自定义函数“ getImageHistogram”(已存在于OpenCV中),将由main.cpp使用。 The header and main files are done, how do I link those in my CMakeLists? 头文件和主文件已完成,如何链接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() . 只要使用C ++,就可以在另一个(自定义)名称空间中定义此函数,并将其称为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: 对于CMake部分,没有什么特别的事情要做,因为您已经将该文件添加到了构建过程中:

ADD_EXECUTABLE( ${PROJECT_NAME} main.cpp )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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