I am trying to view the response returned from an opencv function knn. I've tried using the cout function like most examples show, but this doesnt work in the Android NDK.
The response should be 3 values, [1,2,3], and when I do response.cols, the answer is 3 so I know that the data is in there, but I cannot find the correct format to print out or inspect the data to see if the right response has been returned.
The value "response" returned from knn->findNearest is of format OutputArray.
I've tried the below methods, but they output weird data:
int K=3;
Mat response;
Mat dist;
knn->findNearest(testFeature, K, noArray(), response, dist);
int *responseToInt = (int*)response.data;
int nearestNeighbors[3];
for(int i = 0; i < response.cols; i++){
nearestNeighbors[i] = responseToInt[i];
}
output:
nearestNeighbors[0] = 1077936128
nearestNeighbors[1] = 1077936128
nearestNeighbors [2] = 1077936128
int K=3;
Mat response;
Mat dist;
knn->findNearest(testFeature, K, noArray(), response, dist);
uchar* responseToChar = response.data;
char nearestNeighbors[3] = "";
for(int i = 0; i < response.cols; i++){
nearestNeighbors[i] = responseToChar[i];
}
output:
nearestNeighbors[0] = \0
nearestNeighbors[1] = \0
nearestNeighbors[2] = @