Passing Camera frame in android as a Mat [closed]

asked 2014-01-21 03:42:36 -0600

bginer gravatar image

updated 2014-01-21 03:43:23 -0600

In the openCV implementation of Android part I have a method called onCameraFrame() which returns the input frame

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
mNativeDetector.match(inputFrame.rgba());
return inputFrame.rgba();
}

and in the jni side I am receiving it as

Mat mMat1 = (*((Mat*)inputMat));

But when i try to compare it I get this error

OpenCV Error: Assertion failed (type == src2.type() && src1.cols == 
src2.cols && (type == CV_32F || type == CV_8U)) in void 
cv::batchDistance(cv::InputArray, cv::InputArray, cv::OutputArray, int, 
cv::OutputArray, int, int, cv::InputArray, int, bool), file 
/home/reports/ci/slave/50-SDK/opencv/modules/core/src/stat.cpp, line 1797

How to solve this error and pass the Cameraframe mats for comparison ?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-23 03:26:02.380033

Comments

it looks like you can use cv::batchDistance() only with 1-channel Mat's ( like a single channels, or grayscale ) . what you are passing in is a 4 chan rgba Mat.

ofc. you could call:

mNativeDetector.match(inputFrame.gray());

but no idea, if that's what you wanted.

berak gravatar imageberak ( 2014-01-21 04:03:31 -0600 )edit

I tried both it doesnt work

bginer gravatar imagebginer ( 2014-01-21 05:31:23 -0600 )edit
1

there's 2 inputarrays. check the other one, too.

berak gravatar imageberak ( 2014-01-21 05:33:23 -0600 )edit

@berak : What input array ? I dont get it ?

bginer gravatar imagebginer ( 2014-01-21 23:13:12 -0600 )edit
1

Check all your arguments that you are passing to the batchDistance() function. It seems that there is still a parameter with wrong dimensions! Just loop in debug through your code, before executing the exact line, look at which values your input elements have, maybe print their type to be sure.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-01-23 06:41:39 -0600 )edit