I'm getting an Error in C++ - error: cannot convert ‘cv::Point_<int>’ to ‘cv::Point* {aka cv::Point_<int>*}’ in return

StackOverflow https://stackoverflow.com/questions/22356340

  •  13-06-2023
  •  | 
  •  

Question

I'm try to run the code below and I'm getting an error. I'm creating an wrapper for an OpenCV function called 'Mat::at' and I'm trying to get it to compile to an '.so' on Ubuntu Trusty using 'G++'. I listed the contents of my '.cpp' file my '.hpp' file my error and my compile command below. I would appreciate any help on returning this C++ OpenCV function as a C pointer. Because that is my goal. Thank you.

Error:

 error: cannot convert ‘cv::Point_<int>’ to ‘cv::Point* 
    {aka cv::Point_<int>*}’ in return
 return self->at<Point>(row, col); 

(I also get the normal "Contol reaches end of non-void function error")

Cpp:

 Point* cv_Mat_at_Point(Mat* self, int row, int col) {
   return self->at<Point>(row, col);
 }

Hpp:

 Point* cv_Mat_at_Point(Mat* self, int row, int col)

Compile Command:

 g++ -Wall -shared -fPIC -o c-binding.so c-binding.cpp

Edit for RedX:

Point* cv_create_Point(int x, int y) {
    return new Point(x, y);
}
Was it helpful?

Solution

it should be return &self->at<Point>(row, col);

since the function is expecting Point*

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top