Open CV using Cmake - opencv

I am working on a harr detecttion project. I want to generate the exe files using the .cpp files that come with Opencv. I am using CMake for it. When I try to do that I am getting an error like this. Don`t know how to solve it.
CMake Error at CMakeLists.txt:7 (ocv_check_dependencies):
Unknown CMake command "ocv_check_dependencies".
Configuring incomplete, errors occurred!
Source link: C:/opencv/apps/haartraining
Destination link: D:/build
Please help me.

I was working on some image processing that involves Haar detection. And i was having a hard time trying to configure with Cmake at first but i finally found manual configuration tutorial with out using Cmake or else. It has helped me a lot and you can get it here. I hope it will work perfect as it worked for me too. Click here -> http://www.anlak.com/using-opencv-2-3-1-with-visual-studio-2010-tutorial/. The tutorial uses open CV 2.3.1 but it will work perfect for recent versions too with the need for Cmake ore else.If you more questions, hit me up and i will explain.Good luck!

It looks like You need to compile the whole library with build examples option enabled (if You are using windows then I bet You use graphic cmake interface, so it shouldn't be a problem), and then You will find the .exe in bin directory,
or You would need to include OpenCVModule.cmake file found in cmake catalogue to CMake file You are trying to use for the build.
I didn't test the second option myself, but it looks like CMake file You are trying to use does not load all macros needed for it to run, but macros are loaded when the root library CMake file is used.

Related

Problems when building Drake from source with cmake

I am trying to build and install Drake from source in order to get support for Mosek. I keep running into trouble, however. For the record, I am running macOS Catalina.
Right now my approach has been this:
Clone drake from github to a location on my computer (from https://github.com/RobotLocomotion/drake.git)
Install prereqs
with ./setup/mac/install_prereqs.sh
Run bazel build //... Make a
directory called build and cd build cmake .. and then make
and make install
And in my C++ project, which I build using cmake, I add this to CMakeLists.txt:
link_directories(drakelocation/build/install/lib)
include_directories(drakelocation/build/install/include)
However, when I try to build my project, I get an error that Drake is unable to locate Eigen: 'Eigen/Core' file not found. I was able to work around this by adding:
target_link_libraries(my_lib Eigen3::Eigen) to my CMakeLists.txt
I found this a bit strange, as I expect that Drake includes Eigen when it is built, but at least this made me able to get a bit further.
After this I get a bunch of messages of the type:
no member named 'signbit' in the global namespace
i.e. it seems like Drake suddenly is missing all the standard C++ libraries. I have not yet been able to fix this issue, so this is where I am currently stuck.
Do you have any suggestions, or have you encountered any similar problems before?
Other information:
Using find_package(drake) does not work with my current approach at all (cmake is not able to locate drake-config.cmake). Am I missing something here that is required to make this work? Where does cmake expect libraries to be installed, and how do I install them in that place?
I have also tried skipping the entire bazel build //... step, going directly to the cmake .. step, which did not seem to make any difference.
In between every different build approach I have run bazel clean --expunge to make sure that nothing sticks around from the previous run.
Thanks!
You need to tell CMake where your Drake installation is located:
list(APPEND CMAKE_PREFIX_PATH /absolute/path/to/drakelocation/build/install)
find_package(drake REQUIRED)
add_library(my_lib ...)
target_link_libraries(my_lib drake::drake)
This ensures you have all the necessary compiler and linker flags. Setting the include directory to simply /absolute/path/to/drakelocation/build/install/include is insufficient since it does not contain the include directories of the various dependencies of Drake.
Note that you do not need to call bazel yourself before calling cmake. When you run make install, it will call bazel internally.
Thanks #Jamie that solved the find_package() problem I had.
I still had some trouble with the build. Turns out that there was something wrong with my default SDK path, and that setting "CMAKE_OSX_SYSROOT" according to this: Catalina C++: Using <cmath> headers yield error: no member named 'signbit' in the global namespace after an update to XCode did the trick.
After this, I got a lot of strange error messages from Eigen, complaining that i.e. MatrixXd was not defined in the namespace 'Eigen'. For some reason, uninstalling it with brew uninstall eigen and then downloading and building eigen from source solved those problems.
It now works!

Error while building opencv_contrib opencv 3.0

I wanted to use the "extra" modules, that come as opencv_contrib from here for other functions of opencv 3.0. I followed the instructions as per the page, for building and compiling the modules, but am stuck with this error
Command:
cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..
Error:
<Skipping the common Cmake statements and going straight to the error>
CMake Error at opencv_contrib/modules/adas/tools/fcw_train/CMakeLists.txt:16 (ocv_include_modules_recurse):
Unknown CMake command "ocv_include_modules_recurse".
-- Configuring incomplete, errors occurred!
I checked the CMakeLists.txt as mentioned in the path and there were other lines of code that had ocv_xxx , thus it was not a rename issue (I thought they misspelt opencv).
This is my folder structure:
Opencv
- build
- opencv_contrib
This is to verify if my CMake command was correct, as I had posted above.
Can you please tell me how to rectify this error?
UPDATE 1
As per a suggestion, I tried,by putting the opencv_contrib folder outside the opencv folder structure. The new structure was like this
-Opencv
- build
-opencv_contrib
and my new command was
cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
the error is still the same.
Fixed it, thanks to this question. From that question, I understood that the value of the argument should be correct, to turn on the build or something like that. So I changed my command from
cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..
to
cmake -DOPENCV_EXTRA_MODULES_PATH=opencv_contrib/modules .
Plain and simple, without hierarchy information and it worked. Cheers.

Where is OpenCV source code (.cpp) on Ubuntu?

I did not download and unzip OpenCV manually. Instead I relied on apt-get to install OpenCV.
The only place I can find are header files in /usr/include/opencv2
No link to OpenCV GitHub link please. It would be a pain later if it turns out that the code I am using on my PC is different from the one in GitHub.
I have looked at this post but I am not sure where OPENCV_HOME is.
If you do a pkg-config:
pkg-config --cflags opencv
You will find the include files, header files like you give above. I think you are referring to cpp files. Since you downloaded with apt-get you dont have cpp files on your disk. You are going to face the github reality in this case. Just get the same version source code from github. But I dont think of any usage of source code besides compiling. If you want to search the source of a function just use the github web interface, it is easier and a lot helpful

CMake error configuring opencv

I have been trying to work with the flandmark code for facial detection. in order to compile the libraries, I need to run CMAKE.gui.exe. However I keep getting the same error and no one seems to have an idea how to get around it. I would really appreciate if please someone could help.
Error:
Cmake Warning at /OpenCV2.3/cmake/OpenCVConfig.cmake:153(message):
Found OpenCV 2.4.3 Windows Super Pack but it has not binaries compatible with your configuration.
You should manually point Cmake variable OpenCV_DIR to your build of OpenCV library.
Call Stack(most recent call first):
CMakeLists.txt:2(find_package)
CMake Error at CMakeLists.txt:2(find_package):
Found package configuration file:
/OpenCV2.3/cmake/OpenCVConfig.cmake
but it set OPENCV_FOUND to FALSE so package "OpenCV" is considered to be
NOT FOUND
Just delete CMake cache.
I've had more or less the same problem, posted & answered a question myself.
Check it at https://stackoverflow.com/a/36622706/3292304 for the whole problem if you want. I hope this will help.
I would suggest you take a look at this post
It happened in my case since I had already installed another version of OpenCV.
I hope it helps
Something weird is going on with the cmake configuration files.
For me the problem was solved by simply setting OPENCV_FOUND to TRUE and OpenCV_FOUND to TRUE.
Also I had to set OpenCV_DIR to /usr/local/share/OpenCV.

How to build muPDF for android (Need help)

i've been working on this for a while now but i'm still stuck. This is what i've done...
Installed Eclipse
Installed SDK, NDK
Created a project from an existing source... which i browsed to muPDF/android
Then i installed Cygwin to build the project
I used ndk-build to build the project by cygwin
Then i got an error that says ".../Downloads/mupdf-0.8.165/android/jni/mupdf.c:11:19: error: mupdf.
h: No such file or directory"
I've been finding a way to fix this but it keeps on having other new problems after and after. so i would like to ask for your help... plz
Thanks in advance... Best regards, Sirisub
In the directory above there is a script called build.sh that runs the Android.mk and other makefiles; all the locations in those makefiles are set to be run from that location.
However, there are lots of other problems, not all of which I've resolved yet; quick hints, though, you need the third-party libs like jpeg and so on in a directory called "thirdparty" in the same source location as the rest of mupdf (so as siblings of the android subdirectory) and some of the libs need you to produce config headers to make everything work!
I'm currently trying to work out how to link it all ....

Resources