I have a snippet code from colorblobdetection but I don't know what is the purpose of CvType.CV_8UC4. The Link here does not really explain how does it works.
public void onCameraViewStarted(int width, int height) {
mRgba = new Mat(height, width, CvType.CV_8UC4);
mDetector = new ColorBlobDetector();
mSpectrum = new Mat();
mBlobColorRgba = new Scalar(255);
mBlobColorHsv = new Scalar(255);
SPECTRUM_SIZE = new Size(200, 64);
CONTOUR_COLOR = new Scalar(255,0,0,255);
}
OpenCV types can be read the following:
CV_
8U
: Unsigned int 8-bitC4
: Four channels.Thus mRgba = new Mat(height, width, CvType.CV_8UC4);
creates a Matrix with four color channels and values in the range 0 to 255.
This makes a specific form of Matrix.
Where 8u
means each element will be unsigned (only positive) integers, 8-bit.
The reason there are 4 channels (like 4 slices that layer together to make an image of different colours) is to make up the image. The first 3 in this are R, G, B, and the last is Alpha, which is a value between 0 and 1 representing transparency. When these slices combine you get the correct combination of colours.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With