Reputation:
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:
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
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*’
Upvotes: 0
Views: 630
Reputation: 1412
Your return data type is cv::Mat*, whereas the return data type for std::cout is 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);
}
Upvotes: 2