What is happening from line #129 to line #133 in this class of the Color blob detection sample app?
SOME CONTEXT:
The camera view in the app looks like this: (Notice that in the camera view, there is a black border around the camera frame)
From Line 114 to 128, the following is happening.
int cols = mRgba.cols();
cols()
gives the number of columns in a matrix. The matrix here is the Mat representing a frame in the live stream of frames being displayed (and not the entire camera view), i.e. it represents the part of the camera view where live stream is being displayed, EXCLUDING the black border of the camera view.int rows = mRgba.rows();
rows()
gives the number of rows in the camera frame, EXCLUDING the black border of the camera view.int xOffset = (mOpenCvCameraView.getWidth() - cols) / 2; int yOffset = (mOpenCvCameraView.getHeight() - rows) / 2;
mOpenCvCameraView.getWidth()
gives the number of rows in the entire camera view, i.e. the camera frame PLUS the black border of the camera view around the frame.(mOpenCvCameraView.getWidth() - cols)
gives the sum of the width of left and right black border of the camera view.(mOpenCvCameraView.getWidth() - cols)/2
orxOffset
gives the width of the black border on one side, i.e. either right or left side, black border of the camera view. Likewise foryOffset
int x = (int)event.getX() - xOffset; int y = (int)event.getY() - yOffset;
getX()
returns the X coordinate of this event for the first pointer index. SogetX()
gives the distance of the touched region from the left extreme side of the camera view, which includes the black border on the left. Soevent.getX()-xOffset
orint x
is the distance of the touched region from the left extreme side of the camera "frame" (which does NOT include the black border of the camera view). Likewise forint y
.
Then are the lines which I have no clue about.