Different channels in opencv

156 Views Asked by At

I am quite new to OpenCV, I am trying to understand some concepts in it.

I have declared two Mat objects mRgba and mRgb

mRgba = new Mat(height,width, CvType.CV_8UC4);
mRbg = new Mat(height, width, CvType.CV_8UC3);

@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    mRgba = inputFrame.rgba();
    mRbg = inputFrame.rgba();

    Log.i(TAG, "mRgba.channels() : " +   mRgba.channels());
    Log.i(TAG, "mRbg.channels() : " +   mRbg.channels());
}

I get the ouput of both as four channels. How to get a 3 channel Mat ?

1

There are 1 best solutions below

0
On BEST ANSWER

The docs don't help.

Your assignments turn mRgba and MRgb into exact copies of inputFrame.rgba(), which is why you are not getting the results you want.

How you dump the alpha channel I don't know, I'd just write a loop and do it element by element. Crete mRgb with zeros then assign from mRgba.