Trouble using opencv in homemade class

asked 2020-03-09 06:32:08 -0600

Kebsox gravatar image

Hi everyone,

I got some difficulties to work with opencv in a class. I want to create a librairy to perform some camera analisys in C++.

To do that I create a simple class with a header CCamera.h:

#ifndef CCAMERA_H
#define CCAMERA_H
#include <opencv2/core/core.hpp>

class CCamera
{
public:
void CannyEdgeDetector();
};

#endif // CCAMERA_H

a CCamera.cpp

#include "CCamera.h"

void CCamera::CannyEdgeDetector()
{

}

And a main .cpp

#include "CCamera.h"
int main(int argc, char* argv[])
{
CCamera loop;
while(1){
}
return 0;
}

Something really simple but it's not working. I got several error. in the main i got "unknow type name CCamera" and in the .cpp : "use of undeclrared identifier 'CCamera'"

But if i remove the line "#include <opencv2 core="" core.hpp="">" in my header the class work fine. But i really need to import opencv in my header to declare a function using Mat. By example : I need to declare void CannyEdgeDetector(const cv::Mat&, cv::Mat&, int);

I think I do not uderstand something about opencv and his inclusion. Do you have an idea to solve my problem?

Thx for your time!

edit retag flag offensive close merge delete

Comments

Don't you miss one error : cannot find include opencv2/core/core.hpp

LBerger gravatar imageLBerger ( 2020-03-09 10:02:28 -0600 )edit
1

Open cv is working fine. If I put everythings in a simple file it's work well.

Kebsox gravatar imageKebsox ( 2020-03-09 11:52:49 -0600 )edit
1

Even if OpenCV works for you elsewhere, I'd change the include to opencv2/core. hpp, which AFAIK is correct

mvuori gravatar imagemvuori ( 2020-03-09 12:35:03 -0600 )edit