0

I am using the Knn findNearest function in OpenCV, which takes in the following parameters:

Mat response;
Mat dist;

knn->findNearest(testFeature, K, noArray(), response, dist);

The output returned from response and dist is of type OutputArray.

How do I access the results of response and dist in this format? Ideally I would like to convert to Mat int.

Ber12345
  • 89
  • 1
  • 12

1 Answers1

0

If you want to copy the mat data into cpp array you can do like this. I assume the Mat data you want to return is of float type.

int size=response.rows*response.cols*resonse.channels();
float* outArr=new float[size];
std::memcpy(outArr,response.data,size*sizeof(float));

you need to delete outArr after copying it to JNIArray.

hariprasad
  • 838
  • 1
  • 8
  • 16