[英]OpenCv c++ Create a C wrapper for basic print mat function?
I can create and print a matrix like this: 我可以创建和打印这样的矩阵:
Mat M(2,2, CV_8UC3, Scalar(0,0,255));
cout << "M = " << endl << " " << M << endl << endl;
My C wrapper for the C++ functions is this: 我的C ++函数的C包装器是这样的:
Mat* cv_printmat(Mat* mat) {
return cout << "Matrix = " << endl << " " << *mat << endl << endl;
}
Not sure where to go from here...I need to declare "Mat* mat" as is ...an opaque pointer for my purpose...but getting this error 不知道从哪里开始...我需要声明“Mat * mat”,因为我的目的是一个不透明的指针...但是得到这个错误
In file included from /usr/include/c++/4.8/ios:44:0,
from /usr/include/c++/4.8/istream:38,
from /usr/include/c++/4.8/sstream:38,
from /usr/include/c++/4.8/complex:45,
from /usr/local/include/opencv2/core/cvstd.inl.hpp:48,
from /usr/local/include/opencv2/core.hpp:1256,
from /usr/local/include/opencv2/opencv.hpp:46,
from opencv_generated.hpp:1,
from cl-opencv-glue.cpp:1:
/usr/include/c++/4.8/bits/basic_ios.h:115:7: note:
candidate is: std::basic_ios<_CharT, _Traits>::operator
void*() const [with _CharT = char; _Traits = std::
char_traits<char>] <near match>
operator void*() const
^
/usr/include/c++/4.8/bits/basic_ios.h:115:7: note:
no known conversion for implicit ‘this’ parameter from ‘void*’ to ‘cv::Mat*’
compiling with this: 用这个编译:
g++ -Wall -shared -fPIC -o libcl-opencv-glue.so cl-opencv-glue.cpp
any help is much appreciated=). 任何帮助非常感谢=)。
Edit...new error 编辑...新错误
opencv-glue.cpp :150:58 error:invalid user-defined conversion from
‘std::basic_ostream<char>::__ostream_type {aka std
::basic_ostream<char>}’ to ‘cv::Mat*’ [-fpermissive]
return cout << "M = " << endl << " " << *mat << endl << endl;
^
In file included from /usr/include/c++/4.8/ios:44:0,
from /usr/include/c++/4.8/istream:38,
from /usr/include/c++/4.8/sstream:38,
from /usr/include/c++/4.8/complex:45,
from /usr/local/include/opencv2/core/cvstd.inl.hpp:48,
from /usr/local/include/opencv2/core.hpp:1256,
from /usr/local/include/opencv2/opencv.hpp:46,
from opencv_generated.hpp:1,
from opencv-glue.cpp:1:
/usr/include/c++/4.8/bits/basic_ios.h:115:7: note: candidate is:
std::basic_ios<_CharT, _Traits>::operator void*() const [with _
CharT = char; _Traits = std::char_traits<char>] <near match>
operator void*() const
^
/usr/include/c++/4.8/bits/basic_ios.h:115:7: note:
no known conversion for implicit ‘this’ parameter from
‘void*’ to ‘cv::Mat*’
Your return data type is cv::Mat*, whereas the return data type for std::cout is void*. 您的返回数据类型是cv :: Mat *,而std :: cout的返回数据类型是void *。 Not sure what your goal is, but this should compile if you are just trying to print.
不确定你的目标是什么,但如果你只是想打印,这应该编译。
void cv_printmat(Mat* mat) {
cout << "Matrix = " << endl << " " << *mat << endl << endl;
}
int main(int argc, char* argv[]){
cv::Mat M(2,2, CV_8UC3, cv::Scalar(0,0,255));
cv_printmat(&M);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.