I am using OpenCV 3.2 with Netbeans 8.0 on Ubuntu 16(LTS).
CvQuadEdge2D was quite useful in OpenCV 2 but appears to be gone from OpenCV 3. The closest I could find was
struct CV_EXPORTS QuadEdge
{
QuadEdge();
QuadEdge(int edgeidx);
bool isfree() const;
int next[4];
int pt[4];
};
in imageproc.hpp. However
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <windows.h>
#include <string.h>
#include <cv.hpp>
#include <highgui.h>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
int main(){
struct CV_EXPORTS QuadEdge* edge
}
results in QuadEdge being "undefined".
In OpenCV 3 the concept behind CvQuadEdge2D is in Edge.
Now you can navigate through edges using getEdge. You can get the list of the vertices of all edges using getEdgeList
QuadEdge itself is a protected member of the class Subdiv2d, so you cannot access it. You should use the new Edge interface.
Related
I'm using openCV-3.2.0 and getting an identifier undefined error when initializing the line :
CvRTrees rtrees;
I think i have added all the necessary header files. So why am i getting this error?
#include <stdio.h>
#include<conio.h>
#include <opencv/cv.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/cvaux.h>
#include <opencv/ml.h>
#include <opencv2/core/core.hpp>
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <math.h>
#include <windows.h>
#include <string>
#include <stdlib.h>
#include <exception>
#include <array>
#include "opencv2/ml/ml.hpp"
using namespace std;
using namespace cv;
This class exists in OpenCV 2.4.x, However it is not available in newer versions of OpenCV like 3.2.0. Check here the list of all cv::ml classes for OpenCV 3.2.0. I suggest you to use RTrees instead. To do this you do not need to include all headers, just include the machine learning module:
#include "opencv2/ml/ml.hpp"
This question already has an answer here:
Is there C++ API for Delaunay triangulation in OpenCV?
(1 answer)
Closed 5 years ago.
I have installed OpenCV 3.2.0 on Ubuntu 16 and am developing using C++ in NetBeans 8.2. I am trying the following code which worked perfectly with OpenCV 2.
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <cv.hpp>
#include <highgui.h>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/imgproc/imgproc_c.h>
#include <vector>
#include <set>
#include <map>
vector< Triangle > CTwoDTriangulation::delaunayDiv(const vector< Point_<T> > & vP, cv::Rect boundRect,
vector<Triangle>& triangles, int& numTriangles, bool lookRight)
{
CvSubdiv2D* subdiv;
int numPts=vP.size();
CvPoint newPoint;
CvMemStorage *storage;
storage = cvCreateMemStorage(0);
subdiv = cvCreateSubdivDelaunay2D( boundRect, storage );
for (size_t e = 0; e<numPts; e++)
{
newPoint=vP.at(e);
if (newPoint.x<(boundRect.x + boundRect.width) && newPoint.y<(boundRect.y + boundRect.height))
cvSubdivDelaunay2DInsert(subdiv, vP.at(e));
}
}
With OpenCV 3, I get the following errors.
../../DraculaFiles/TwoDTriangulation.cpp:4278:60: error: there are no arguments to ‘cvCreateSubdivDelaunay2D’ that depend on a template parameter, so a declaration of ‘cvCreateSubdivDelaunay2D’ must be available [-fpermissive]
subdiv = cvCreateSubdivDelaunay2D( boundRect, storage );
I tried typing cv:: and seeing what functions are available. But I saw nothing similar to CreateSubdivDelaunay2D. I have also done a Google search to see what has replaced cvCreateSubdivDelaunay2D in OpenCV 3 but could not find anything.
cvCreateSubdivDelaunay2D became legacy (so does the whole c-interface for delauny triangulation) and has been removed.
For OpenCV 3 you can refer to the cv::SubDiv class instead.
I'm trying to follow this tutorial for object detection but I stuck at the beginning.
Until now my code is this:
#include <stdio.h>
#include <stdlib.h>
#include <opencv2/opencv.hpp>
#include <fstream>
#include <iostream>
#include <string>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
using namespace cv;
using namespace std;
int main() {
Ptr<DescriptorExtractor> extractor = DescriptorExtractor::create("SURF");
//Mat training_descriptors(1, extractor->descriptorSize(), extractor->descriptorType());
extractor->descriptorSize();
return 0;
}
The following line extractor->descriptorSize(); gives a Segmentation fault (core dumped) and I don't know why. Do you have any ideas?
I found out that the nonfree module of OpenCV was not installed. After installation I included the nonfree library #include <opencv2/nonfree/nonfree.hpp> and then called cv::initModule_nonfree();. The problem is solved.
Im trying to use NormalBayesClassifier in my code to apply bag of words. The pre-training matrix is ready and given to the trainme matrix. I am using it as follows:
NormalBayesClassifier classifier;
classifier.train(trainme, labels);
And I am getting the following error:
error C2065: 'NormalBayesClassifier' : undeclared identifier
I have added all the correct libraries and all other opencv functions work, including the features2d functions.
Here are my libraries:
#include <stdafx.h>
#include <stdlib.h>
#include <cv.hpp>
#include <cxcore.hpp>
#include <highgui.h>
#include <iostream>
#include "opencv2/nonfree/features2d.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include <fstream>
#include <windows.h>
using namespace cv;
using namespace std;
That should cover the NormalBayesClassifier function, then why am I getting this error?
According to the documentation, the class for the Normal Bayes Classifier is actually called CvNormalBayesClassifier.
The corresponding header file is:
#include "opencv2/ml/ml.hpp"
I am using VS 2008 with OpenCV 2.1 installed as per the installation guide. FeatureDetector/SurfFeatureDetector are listed as classes in the documentation, but they are considered "syntax error : identifier 'SurfFeatureDetector"
This is pretty much the entirety of my code.
#include "cv.h"
#include "highgui.h"
Ptr<FeatureDetector> *detect = new SurfFeatureDetector();
I've tried a bunch of random combinations to get this to work. How can I initialize a featuredetector?
You're declaring a pointer to a cv::Ptr -- you really should just have the cv::Ptr. Change your code to
#include "cv.h"
#include "highgui.h"
using namespace cv;
Ptr<FeatureDetector> detect = new SurfFeatureDetector();
and it should work.
I think you have installation problem, try resinstalling from here: sourceforge.net/projects/opencvlibrary/files/opencv-win/2.2
anther other option is that your precompiler already has __OPENCV_OLD_CV_H__ defined.
Try undefining it before #include "cv.h"
When you type #include "cv.h"
It automatically should include featurs2d. in fact cv.h includes the following:
#include "opencv2/core/core_c.h"
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/video/tracking.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/flann/flann.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/legacy/compat.hpp"
You need the OpenCV 2.x style C++ include. See below
#include "opencv2/features2d/features2d.hpp"
#include "cv.h"
#include "highgui.h"
using namespace cv;
Ptr<FeatureDetector> detect = new SurfFeatureDetector();
You need to:
#include <opencv2/nonfree/nonfree.hpp>
(from here: http://answers.opencv.org/question/411/feature-detector-crash/)