OpenCV and JNI Mat passing problem

633 views
Skip to first unread message

Radek Chudziak

unread,
Apr 17, 2012, 11:01:07 AM4/17/12
to android...@googlegroups.com
I slightly changed the code of the Tutorial 2 Advanced Mix Java + Native. The C++ code looks as follows

#include <jni.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/video/tracking.hpp>
#include <opencv2/contrib/contrib.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <vector>


using namespace std;
using namespace cv;


extern "C" {
JNIEXPORT
void JNICALL Java_com_droidnova_android_tutorial2d_Panel_FindFeatures(JNIEnv* env, jobject thiz, jlong addrGray, jlong addrRgba)
{


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




   
for (int i = 0; i <  pMatRgb.rows; i++) {


   
}


}


}


It is not doing anything but I want to iterate through rows of the mat. But here it is a pointer to the mat and I get the following error message: error: request for member 'rows' in 'pMatRgb', which is of non-class type 'cv::Mat*'

How to convert it into Mat so I will be able to run the above code?

dschaudel

unread,
Apr 17, 2012, 12:31:29 PM4/17/12
to android...@googlegroups.com


for (int i = 0; i <  (*pMatRgb).rows; i++)

peppschmier

unread,
Apr 18, 2012, 2:34:03 AM4/18/12
to android...@googlegroups.com
or you can use: i < pMatRgb->rows;
in fact: you have do dereference the pointer at first!
Reply all
Reply to author
Forward
0 new messages