How to detect keypoints, compute descriptors and match those descriptors in OpenCV 3.0.0, Visual Studio 2013, in C++? - c++

I have seen the documentation of OpenCV. In there, SurfFeatureDetector, SurfDescriptorExtractor and BruteForceMatcher are being used.
But when I try in my code, it is showing -
Error : identifier "SurfFeatureDetector" is unidentified.
Same case for other two.
After going through some threads and forums, I tried to include some header files like - #include <opencv2 nonfree="" features2d.hpp=""> and some others but those files don't exist. So shows another error saying -
Error : Cannot open source file "opencv2/nonfree/features2d.hpp"
Is there any alternative way to do these in OpenCV 3.0.0?

I had similar problem and it got fixed when I built Opencv locally on my system instead of using pre-built libraries. You can refer to this thread for building Opencv on your system Where is the lib folder (or its replacement) in the current OpenCV?
In opencv3.0, SURF/SIFT/BruteForceMatcher have been moved to a seperate opencv_contrib repository, you may download it and make changes to cmake path for Visual Studio to recognize these functions. Although it did appear after building it locally on my system without doing any additional modification.
After you built it locally you can find it in the following path
Build_folder/install/include/opencv2/features2d.hpp

Related

dlib and windows function conflict

I have recently added dlib 19.1 to my project in Visual Studio 2013. I'm able to run compile the library without problem, to run the example and also to create my own console applications and make it work just fine.
But when integrating dlib to my project, I have recently faced the current error:
Error 14 error : identifier "WaitForSingleObject" is undefined
\include\dlib\threads\threads_kernel_1.h 120
There are 50 errors similar to this one, all in threads_kernel_1.h
I'm looking to all project properties and didn't find anything suspicious compare to my example project that include dlib.
identifier "WaitForSingleObject" is defined by including <windows.h> header in your application. this header is included by \include\dlib\threads\threads_kernel_1.h, but something went wrong on your machine
You can try using this function separate from dlib and check if it works in your application first.
Also you can explicitly #include <windows.h> at the top of your cpp file
And do you have any custom "windows.h" file in your application, may be some naming conflict?
Also I can recommend you generating Visual Studion project by CMake and then using it from IDE

ImageMagick ++ Read Error ErrorMissingDelegate

I have downloaded and installed ImageMagick++ from http://www.imagemagick.org/Magick++/.
I am using Windows7 32 bit and Visual Studio 2008. I want to use the ImageMagick in an existing project. I made the required/suggested changes to my project properties like adding dependencies etc. I added three libraries in the additional dependencies (CORE_RL_Magick++_.lib,CORE_RL_MagickCore_.lib and CORE_RL_MagickWand_.lib
I added
<Magick++.h> header file and
using namespace Magick
Then
Magick:: Image image (No error)
image.read("5.png") throws an error "ErrorMissingDelegate at memorry location ....".
I tried other image formats also, but same error.
Please help.

OpenCV w/ CUDA build fail on Visual Studio 2013 [duplicate]

I'm trying to build OpenCV 2.4.6 on Windows 8 in Visual Studio 2012. Having downloaded the source from https://github.com/Itseez/opencv I generate (leaving the default configuration) using cmake and then load the resulting file ALL_BUILD.vcxproj into Visual Studio 2012. I then try to build it. Several of the modules do indeed build (e.g. core, flann, imgproc, ...) but I am trying to build highgui so that I can use the PDB file for debugging my code (which fails to open a video file). The build errors start with this and many similar errors:
error C2039: 'max' : is not a member of 'std' C:\OpenCV2.4.6\3rdparty\openexr\Imath\ImathMatrixAlgo.cpp 1094 1 IlmImf
One fix for errors like this (e.g. in this answer) is to add #include <algorithm> to the failing files. I tried that on a few files and it seems to work but I'm nervous about locally changing the source for a popular library. It must build on Windows (you can download the binaries, though not the PDB files, from the OpenCV sourceforge site) so I would like to understand how to build it on my machine without changing the source.
Am I missing something out in the configuration step? Is there some path setting etc. missing on my machine? Why am I getting these errors and how should I fix them?
========== EDIT ==========
Looking at the directory path this appears to be a problem with one of the 3rd party dependencies, OpenEXR. Looking on Github it appears to be version 1.7.1 of OpenEXR that is used in OpenCV 2.4.6. The instructions in the OpenCV's Quick Start Installation on Windows state:
In case of the Eigen library it is again a case of download and extract to the D:/OpenCV/dep directory.
Same as above with OpenEXR.
so I downloaded the OpenEXR 1.7.1 source code release and extracted the resulting files putting the directory openexr-1.7.1 into C:\OpenCV2.4.6\dep.
Then I ran cmake and tried to build the resulting Visual Studio solution. Sadly I see the same errors.
I was stumbling on the same issue while compiling OpenEXR. Then I found the solution googling for openexr std::min.
There is an issue opened on OpenCV where it says that, when using VS2013 Preview, you must add the line #include <algorithm> in the file where you're using std::min and std::max.
I put that line into the files where these methods are called and voilĂ ! Compilation succeeded.
You probably need to #define NOMINMAX. Try putting it before any other includes.
If that helps, then put in the you project's preprocessor defines.
There's lots of info about this, just search for NOMINMAX. Here's one post about it.
#include <iostream>
#include <algorithm>
Just include above 2 lines to the cpp file and the compilation error will disappear.

OpenCV 2.4.8. Installation from source does not contain \Build\x64\vc10

I'm running into trouble when trying to use OpenCV 2.4.8 in Visual Studio 2010. I've built OpenCV from source since i'll be needing CUDA functionality.
When arriving at the step to add the path to the environment variable as indicated here: http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html#windowssetpathandenviromentvariable, it seems \Build\x64\vc10 is not present in my OpenCV folder. Instead, I've simply added C:\OpenCV\build as OPENCV_DIR to my environment path, since it seems lib and bin are present in this folder.
However, adding $(OPENCV_DIR)....\include to my Visual Studio 2010 project, as indicated here: http://docs.opencv.org/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.html#windows-visual-studio-how-to will yield unwanted results, as this will point to my C:\ drive, instead of the OpenCV root folder. My OpenCV root folder does have an include folder, however it does not seem to contain relevant files (some files related to CMake).
Long story short, it seems I'm unable to add OpenCV to Visual Studio 2010 if OpenCV is built from source.
Can anybody see what I'm missing here?
Any help is greatly appreciated.
The instructions assume you are using the prebuilt binaries that come with OpenCV. If you build it yourself (as in your case), you have two options:
Set CMAKE_INSTALL_PREFIX when building opencv and run the INSTALL target to put all of the OpenCV files you need in known place that works for you. Set OPENCV_DIR to this installed location (i.e. C:\libs\opencv), and set the include directory to $(OPENCV_DIR)\include.
set OPENCV_DIR to the build directory (as you've done), but when setting the include directory only go up one directory: $(OPENCV_DIR)..\include; this will point to the include directory in the original source location

Setting Up OpenCV and .lib files

I have been trying to set up OpenCV for the past few days with no results. I am using Windows 7 and VS C++ 2008 express edition. I have downloaded and installed OpenCV 2.1 and some of the examples work. I downloaded CMake and ran it to generate the VS project files and built all of them but there with several errors, and couldn't get any farther than that.
When I ran CMake I configured it to use the VS 9 compiler, and then it brought up a list of items in red such as BUILD_EXAMPLES, BUILD_LATEX_DOCS, ect. All of them were unchecked except BUILD_NEW_PYTHON_SUPPORT, BUILD_TESTS, ENABLE_OPENMP, and OPENCV_BUILD_3RDPARTY_LIBS. I configured and generate without changing anything and then it generated the VS files such as ALL_BUILD.vcproj. I built the OpenCV VS solution in debug mode and it had 15 failures (maybe this is part of the problem or is it because I don't have python and stuff like that?)
Now there was a lib folder created after building but inside there was just this VC++ Minimum Rebuild Dependency file and Program Debug Database file, both called cvhaartraining. I believe it should have created the .lib files I need instead of this. Also, the bin folder now has a folder called Debug with the same types of files with names like cv200d and cvaux200d.
Believe I need those .lib files to move forward.
I would also greatly appreciate if someone could direct me to a reliable tutorial to set up VS for OpenCV because I have been reading a lot of tutorials and they all say different things such as some say to configure Window's environment variables and other say files are located in folders such as OpenCV/cv which I don't have. I have gotten past the point of clear headed thinking so if anyone could offer some direction or a simple list of the files I need to link then I would be thankful.
Also a side question: why when linking the OpenCV libs do you have to put them in quotes?
If you're just getting started, you should probably grab the prebuilt libraries for OpenCV instead. It's OpenCV-2.1.0-win32-vs2008.exe from this page.
Once you have that, there is really no setup. Just link to the (already built) lib files in any VS project you create, and make sure the OpenCV include directory is in the projects include path.