I have been searching but could not find something clear for my doubt.
I am trying to define my own class in c++, my class uses the libraries from opencv.
I create a file.h file where I just declare the functions, with its guards.
I create a file.cpp file where I explain how the functions look like. In this program I used all the includes I would use in a normal opencv program. (I thought it was right) + the include file.h.
Normally I compile my opencv programs like:
g++ -o program.cpp `pkg-config --cflags opencv` `pkg-config --libs opencv`
Now I try to compile my file.cpp by the same way in order to use the class in oder main file but I obtain an error.
The next step, once I would have the compiled class would be:
g++ -o programMain.cpp compiledClass.o `pkg-config --cflags opencv` `pkg-config --libs opencv`
Any help/advice would be nice since it is the first time I am managing with such a big program.
#ifndef _NAMES_H
#define _NAMES_H
class segmentator {
public:
void search(Mat img,
vector<std::vector<cv::Point> >&contours,
vector<int>&similarity);
void similar(vector<std::vector<cv::Point> >&contours,
vector<std::vector<cv::Point> >&contours2,
vector<int>&similarity);
vector<Mat*> separate(Mat img,
Mat img2,
vector<std::vector<cv::Point> >&contours,
vector<std::vector<cv::Point> >& contours2,
vector<int> idx);
};
#endif
This is my file segmentator.h.
In segmentator.c I have:
#include <stdio.h>
#include <stdlib.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <sstream>
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "segmentator.h"
void segmentator::search(/*parameters*/){/*CODE*/}
void segmentator::similar(/*parameters*/){/*CODE*/}
vector<Mat*> separate(/*parameters*/){/*CODE*/}
And then I am compiling like this
g++ -o segmentator.cpp `pkg-config --cflags opencv`
and it is not recognising the extensions of opencv library.
I moved the question with the new problem that appeared to: Not possible to compile. Headers files.Enclosed own objects definition