Ask Your Question
1

Compare value of a 1x1 Mat to an int

asked 2015-08-21 22:35:05 -0600

nbun gravatar image

updated 2015-08-21 23:44:12 -0600

I want to compare a 1x1 Mat to an int to see if it passes a threshold. I do not know how to do this on android.

public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    rgbMat = inputFrame.rgba();
    bgrPixel= rgbMat.submat(1,2,1,2).clone();
    grayPixel = new Mat();
    Imgproc.cvtColor(bgrPixel, grayPixel, Imgproc.COLOR_RGBA2GRAY, 1);
    return rgbMat;
}
edit retag flag offensive close merge delete

Comments

How would I take grayVal and sample it over and over again till it reaches the right int?

nbun gravatar imagenbun ( 2015-08-22 04:41:07 -0600 )edit

sorry, i do not understand. ?? what is 'the right int' ?

berak gravatar imageberak ( 2015-08-22 04:42:52 -0600 )edit

I want the loop run until grayVal get hits the right value

nbun gravatar imagenbun ( 2015-08-22 16:27:10 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2015-08-21 23:56:28 -0600

berak gravatar image

updated 2015-08-21 23:59:09 -0600

how about this:

rgbMat = inputFrame.rgba();
grayMat = inputFrame.gray();
double [] grayPixel = grayMat.get(1,1);
int grayVal = (int)grayPixel[0];    // now do your comparison

return rgbMat;
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-08-21 22:35:05 -0600

Seen: 982 times

Last updated: Aug 21 '15