Ask Your Question

Revision history [back]

Trouble using opencv in homemade class

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!