How to convert cv::Mat*& to cv::Mat& ?

968 views
Skip to first unread message

Roman

unread,
Sep 8, 2011, 12:39:23 PM9/8/11
to android-opencv
Hi,
Im stuck with really stupid problem for C++ users, but last I use C++
many years ago, and forgot almost everything:)
How to convert cv::Mat*& to cv::Mat& or edit the JNI call? I have math
´s addresses pointer from JNI call, but it´s not suitable for
detection.

Part of code:

JNIEXPORT void JNICALL
Java_org_opencv_samples_tutorial4_Sample4View_FindFeatures(JNIEnv*
env, jobject thiz, jlong addrGray, jlong addrRgba)

{
Mat* pMatGr=(Mat*)addrGray;
Mat* pMatRgb=(Mat*)addrRgba;

int minobjsize = 30;
vector<Rect> faces;
cascade.detectMultiScale( pMatGr, faces, 1.1, 2,
CV_HAAR_DO_CANNY_PRUNING,Size(40, 40),Size(80, 80) );

And error:

Compile++ thumb : mixed_sample <= jni_part.cpp
I:/Android/OpenCVAndroid/samples/tutorial-4-mixed/jni/jni_part.cpp: In
function 'void
Java_org_opencv_samples_tutorial4_Sample4View_FindFeatures(JNIEnv*,
_jobject*, jlong, jlong)':
I:/Android/OpenCVAndroid/samples/tutorial-4-mixed/jni/jni_part.cpp:36:
error: no matching function for call to
'cv::CascadeClassifier::detectMultiScale(cv::Mat*&,
std::vector<cv::Rect_<int> >&, double, int, int, cv::Size, cv::Size)'
../../OpenCV-2.3.1/share/OpenCV/../../include/opencv2/objdetect/
objdetect.hpp:336: note: candidates are: virtual void
cv::CascadeClassifier::detectMultiScale(const cv::Mat&,
std::vector<cv::Rect_<int> >&, double, int, int, cv::Size, cv::Size)
../../OpenCV-2.3.1/share/OpenCV/../../include/opencv2/objdetect/
objdetect.hpp:343: note: virtual void
cv::CascadeClassifier::detectMultiScale(const cv::Mat&,
std::vector<cv::Rect_<int> >&, std::vector<int>&,
std::vector<double>&, double, int, int, cv::Size, cv::Size, bool)
I:/Android/OpenCVAndroid/samples/tutorial-4-mixed/jni/jni_part.cpp:56:
error: invalid initialization of reference of type 'cv::Mat&' from
expression of type 'cv::Mat*'
../../OpenCV-2.3.1/share/OpenCV/../../include/opencv2/core/core.hpp:
2415: error: in passing argument 1 of 'void cv::circle(cv::Mat&,
cv::Point, int, const cv::Scalar&, int, int, int)'
make: *** [/cygdrive/i/Android/OpenCVAndroid/samples/tutorial-4-mixed/
obj/local/armeabi-v7a/objs/mixed_sample/jni_part.o] Error 1

Thanks a lot!
Roman

Leonid Beynenson

unread,
Sep 8, 2011, 3:53:29 PM9/8/11
to android-opencv
Hi Roman,

Just try
cascade.detectMultiScale( (*pMatGr), ....

--- it should help.

Sincerely yours,
Leonid Beynenson

Roman

unread,
Sep 8, 2011, 4:15:03 PM9/8/11
to android-opencv
Hi Leonid,
thanks a lot! Works like charm:)

Roman
Reply all
Reply to author
Forward
0 new messages