How to use SiftDescriptorExtractor in openCV 3.0.0 - sift

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.

Related

libelf by example missing vis.h header

I was wondering if anybody here is familiar with the "libelf by example" book.https://www.dbooks.org/libelf-by-example-1587/read/
I was trying to run prog2.c but I couldn't find the header vis.h (header it's used in chapter 3 and 5)
I downloaded the libelf library from the sourceforge link https://sourceforge.net/p/elftoolchain/wiki/Home/ I also tried to googled it up but I couldn't find anything relevant. I was wondering if it's been substituted by another header in future versions.
I couldn't find the header vis.h
The author appears to be using this vis function.
Try changing #include <vis.h> to #include <bsd/vis.h>.
On my system, this file comes from libbsd-dev package. It is likely that you'll need to link against libbsd.so to get the definition of vis.

Unable to use SurfFeatureDetector in OpenCV 3.0.0

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.

cmake not finding gl.h on OS X

I am on OS X 10.10 and trying to build a C 'project' with GLUT and OpenGL.
I reduced it to a minimal example showcasing my problem. I have the following CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(GLUT REQUIRED)
if(OpenGL_FOUND) # never true, but printed as true
link_directories(${OpenGL_LIBRARY_DIRS})
include_directories(${OpenGL_INCLUDE_DIR})
endif(OpenGL_FOUND)
if(GLUT_FOUND)
link_directories(${GLUT_LIBRARY_DIR})
include_directories(${GLUT_INCLUDE_DIR})
endif(GLUT_FOUND)
# print all vars because wtf
get_cmake_property(_v VARIABLES)
foreach(_v ${_v})
message(STATUS "${_v}=${${_v}}")
endforeach()
add_executable(main main.c)
target_link_libraries(main ${GLUT_LIBRARY} ${OPENGL_LIBRARY})
The main.c is just a dummy including two headers:
#include <gl.h>
#include <glut.h>
int main()
{
return 0;
}
Now, cmake . runs fine and for debugging purposes prints all variables. I took the code from somewhere, I do not know enough about cmake to know whether it's doing what I think it is. Anyway, running make returns
main.c:1:10: fatal error: 'gl.h' file not found
#include <gl.h>
^
1 error generated.
The header gl.h is actually present in /System/Library/Frameworks/OpenGL.framework/Headers and as such should be found by cmake, especially since glut.h is in the same structure (simply replace OpenGL with GLUT) and is found just fine. Also, what is confusing to me is that the block in if(GLUT_FOUND)... is never executed (try to put a message statement into it), but among the printed variables it says OPENGL_FOUND=TRUE. But removing the if-condition does not change anything.
The actual question: What the hell is going on? Why does a) cmake not find the header unless specifically included, b) the if-block not execute although OPENGL_FOUND prints as TRUE, c) no such problems occur with glut.h? Spent hours on this and can't fathom why.
It's common to do
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#endif
You can see this being done in one form or another in glfw, glew, sfml and others
I'm surprised that you found OpenGL headers in /System/Library/Frameworks in OS X 10.10. I don't think they have been installed there in quite a few Xcode releases. The most recent header files with Xcode 6.1 on 10.10 should be in:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/OpenGL.framework/Headers
You don't really need to know this path, unless you want to go look at the headers. I believe the compiler automatically uses the SDK that matches the OS you're compiling on. If for some reason you wanted to build for a different platform, you can override that logic with the -isysroot compiler option.
With header files that come from a framework, the naming you use in your #include statement is:
#include <FrameworkName/HeaderFileName.h>
The compiler will resolve this to the actual pathname of the header within the framework.
Therefore, if you want to use the current OpenGL header, which is gl3.h, from the OpenGL framework, the correct include statement is:
#include <OpenGL/gl3.h>
This will give you access to the Core Profile of the highest supported OpenGL version (which is 3.x or 4.x if you have a reasonably new Mac). Or if you want to use OpenGL 2.1 with legacy features:
#include <OpenGL/gl.h>
As pointed out bei pmr, CMake variables are case-sensitive, so the variable OPENGL_FOUND must be queried.
Also, as PeterT wrote, the header is included as #include <OpenGL/gl.h> on OS X.
I ended up coming to this question after updating qt installed from homebrew and had the same error messages. Going off of Reto's comment, I updated CMAKE_OSX_SYSROOT to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk and everything went back to working as expected.

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>

Importing CUnit sources

i'm having a problem to use Unit test in C, i've tried to install CUnit in my computer and after include the lib.
i've followed steeps to install the CUnit:
1 - download the sources
2 - configure it using "./configure --prefix='/lib' "
3 - make (only make)
4 - sudo make install
and this is my test source file, it's not making tests, but i can't compile this, i got this error before "CUnit.h: No such file or directory":
#include "CUnit.h"
#include <stdlib.h>
#include <stdio.h>
int main(){
print("Hello");
return 0;
}
I want to know, how can i install CUnit to use in my test source files!
Thanks in advance.
EDIT
HAHA, i got this!
i just run configure without parameters, like that:
"./configure"
As shown in the code example you should use something like this :
#include <CUnit/CUnit.h>
because every CUnit includes are located in a CUnit subdirectory (in general in /usr/local/include/CUnit)
What about adding -I/lib/include flag to include header files installed in /lib/include/CUnit and -lcunit -L/lib/CUnit/lib for linking with the installed libraries?
gcc test_file_source.c -I/lib/include -lcunit -L/lib/CUnit/lib -o testing

Resources