我尝试运行下面的代码,但出现错误。我正在为名为“ Mat :: at”的OpenCV函数创建包装器,并试图使用“ G ++”将其编译为Ubuntu Trusty上的“ .so”。我在下面列出了我的.cpp文件的内容和我的.hpp文件的错误以及我的编译命令。对于将C ++ OpenCV函数作为C指针返回的任何帮助,我将不胜感激。因为那是我的目标。谢谢。
错误:
error: cannot convert ‘cv::Point_<int>’ to ‘cv::Point*
{aka cv::Point_<int>*}’ in return
return self->at<Point>(row, col);
(我也得到正常的“ Contol到达非空函数错误的结尾”)
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)
编译命令:
g++ -Wall -shared -fPIC -o c-binding.so c-binding.cpp
编辑RedX:
Point* cv_create_Point(int x, int y) {
return new Point(x, y);
}
最佳答案
它应该是return &self->at<Point>(row, col);
因为该函数需要Point *
关于c++ - 我在C++中遇到错误-错误:无法将“cv::Point_ <int>”转换为“cv::Point * {aka cv::Point_ <int> *}”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22356340/