Unable to use SurfFeatureDetector in OpenCV 3.0.0 - linker

System-
Windows 8.1 64 bit machine
OpenCV 3.0.0
Visual Studio 12 2013
I have built the openCV 3.0.0 with the contrib modules. However, when I compile this code I get errors.
#include <OpenNI.h> //used for taking in input from xtion pro live
#include <iostream>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\core\core.hpp>
#include <opencv2\features2d\features2d.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/xfeatures2d.hpp> // these are the libraries in the new location (they contain SURF implementation)
#include <opencv2/xfeatures2d/nonfree.hpp>
using namespace std;
//using namespace openni;
using namespace cv;
int main(void)
{
//from sample code
int minHessian = 400;
SurfFeatureDetector detector(minHessian);
return 0;
}
The error is-
error C2065: 'SurfFeatureDetector' : undeclared identifier

The syntax to construct a Surf feature detector in OpenCV 3.0 is different from 2.x versions.
Ptr<SURF> surf=SURF::create(minHessian);
std::vector<KeyPoint> keypts;
Mat desc;
surf->detectAndCompute(img,noArray(),keypts,desc);
Apologies if the above example would still throw any errors, I don't have a working version to field test it.

I think for SURF you must use 'extra' modules. Have a look on that: https://github.com/itseez/opencv_contrib/
Basically what you need to do is download the code (opencv_contrib). Add it to the list of modules in the opencv source folder. Then, in cmake you must add the path < opencv_contrib >/modules into EXTRA_MODULES_PATH. Finally, after generate the project via cmake, you will find the xfeatured2d (I think is the one you need) on your opencv solution and you will be able to build it and use them.

In opencv3.0, it combined all library in opencv_world300d.lib (debug) and opencv_world300.lib (release).
For this, you can use #include to instead other include.
On the other hand, they are opencv_world310d.lib (debug) and opencv_world310.lib (release) in opencv3.1.

Related

How to set default Project Properties in NetBeans?

I create projects using C99 in NetBeans. But when I try to include the library math.h, sqrt() and cbrt() won't work. I am on Ubuntu and using Apache NetBeans IDE 11.2. It is updated to NetBeans 8.2 Patch 2.
The steps I do are : File > New Project > C/C++ > C/C++ Application > Finish. The option Create Main File is checked and it is in C99. I then add #include at the beggining of my code, and at each line I use sqrt() I get an error code : Unable to resolve identifier sqrt.
My code is the following :
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char** argv) {
double x = 1.5;
double z;
z = sqrt(x);
return (EXIT_SUCCESS);
}
And I get an error at line 9.
The reason why I want to edit default project properties is because when I add -lm to my project properties, the error remains but at least to project can run. If it is not in project properties, the project will not run.

How to use SiftDescriptorExtractor in openCV 3.0.0

I use SiftDescriptorExtractor in such use :
SiftDescriptorExtractor detector;
and i try all type bellow:
#include <opencv2\nonfree\features2d.hpp>
#include <features2d.hpp>
#include <opencv2\features2d\features2d.hpp>
#include <opencv2/features2d.hpp>
but non of them work properly.
anyone know right way to use SiftDescriptorExtractor in openCV 3.0.0 ?
The standard OpenCV 3.0 builds do no have SIFT included. You need to build and install the contrib module to use SIFT. See opencv_contrib. Please take notice of the licensing terms of the SIFT algorithm.

Eclipse project cannot include tchar.h

I am trying to build an lzmat_lib compression library using Eclipse with Cygwin gcc. I downloaded the library from the link http://www.matcode.com/lzmat_lib.zip. The file has the following include files:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <tchar.h>
#include "lzmat.h"
It cannot find the tchar.h header file. I do not understand how to add this header file. Please suggest a solution.
Your options are to install a Windows development environment, like Visual Studio or mingw along with the Windows SDK, or to port the code to your cygwin (posix) environment.
To port the code, you'd just do this:
Remove #include <tchar.h>.
Search and replace _TCHAR to char.
Search the file for all strings beginning with _t and remove that prefix. E.g., _tfopen becomes just fopen. _tprintf becomes printf.
Search for the text _T and remove it. You could also remove the extra parentheses that will then surround your string.
Deal with any other issues as they come up by removing the dependency on tchar.h and using a standard function instead.

Linking the PCL library with ROS

i had installed ROS and PCL in ubuntu...
The import in my code are:
#include <pcl/io/pcd_io.h>
#include <pcl/point_cloud.h>
#include <pcl/correspondence.h>
#include <pcl/features/normal_3d_omp.h>
#include <pcl/features/shot_omp.h>
#include <pcl/features/board.h>
#include <pcl/keypoints/uniform_sampling.h>
#include <pcl/recognition/cg/hough_3d.h>
#include <pcl/recognition/cg/geometric_consistency.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/kdtree/impl/kdtree_flann.hpp>
#include <pcl/common/transforms.h>
#include <pcl/console/parse.h>
When i compile the program with this CMakeLists:
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(correspondence_grouping)
find_package(PCL 1.3 REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(correspondence_grouping correspondence_grouping.cpp)
target_link_libraries(correspondence_grouping ${PCL_COMMON_LIBRARIES}${PCL_IO_LIBRARIES})
appears this error:
In file included from /opt/ros/fuerte/include/pcl-1.5/pcl/io/pcd_io.h:43:0,
from /home/user/Desktop/PCL/Grouping/correspondence_grouping.cpp:1:
/opt/ros/fuerte/include/pcl-1.5/pcl/point_cloud.h:46:29: fatal error: std_msgs/Header.h: No such file or directory
I'm new in Linux and ROS+PCL (i'm using them for an university project..) and i can't understand which is the problem.
P.S. Similary error appear with other cpp files with PCL.
I don't know how to do to fix it...
Thanks
I think you will be better off using the ROS build system, which is either rosbuild or catkin depending on the version of ROS you are using. catkin is AFAIK a set of CMake macros that pull in ROS dependencies etc.
See:
http://wiki.ros.org/pcl/Tutorials
You should use the rosbuild environment to create a package (See: [Creating a ros package]) and then put this into your CMakelist.txt to use PCL:
...
find_package(PCL 1.3 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
...
The dependencie to std_msgs is handled by the manifest.xml (automatically generate with the package) with the following standard dependecies:
<package>
...
<depend package="std_msgs"/>
<depend package="rospy"/>
<depend package="roscpp"/>
...
</package>

Unable to link libpng or zlib in Eclipse with MinGW C linker

I'm new to external static libraries in C, and i'm having trouble adding pnglib (or any library) to Eclipse. Im using Eclipse v3.3.2 with mingw on windows 7 64bit.
I first followed these instructions to install libpng and zlib: http://wiki.openttd.org/Compiling_on_MinGW
Then in Eclipse under C/C++ Build -> Settings ->Tool Settings -> MinGW C Linker -> Libraries
I added: "png" then "z" in Libraries (-l)
and: "C:\MinGW\libpng-1.5.12" then "C:\MinGW\zlib-1.2.7" in the Library search path (-L)
If I execute the simplest code:
#include <stdio.h>
#include <zlib.h>
#include <png.h>
int main(void) {
printf("foo\n");
unsigned char header[8];
//png_sig_cmp(header, 0, 0);
return 0;
}
It works fine, however as soon as i uncomment the function, the code compiles (without error/warning), but does absolutely nothing, (not even the print statement). This happens when I use ANY function from an external library.
I assume it can read the headers but there's funny business with finding function definitions.
I have no idea where i went wrong.
I'm sure I have missed something trivial!

Resources