OpenCV nMatToBitmap Assertion Failed

The assertion error is telling you that one or more of the following tests is failing:

src.dims == 2
info.height == (uint32_t)src.rows
info.width == (uint32_t)src.cols

I'm guessing info contains the dimensions of the destination bitmap. In that case, either your source Mat is not 2 dimensions or the dimensions of the destination bitmap don't match the dimensions of the source Mat.

These two lines

12-05 21:08:55.486: E/CameraBridge(6658): Mat type: Mat [ 144*192*CV_8UC3, isCont=true, isSubmat=false, nativeObj=0x1024c0, dataAddr=0x44783010 ]
12-05 21:08:55.486: E/CameraBridge(6658): Bitmap type: 384*288

suggest that your Mat is 144x192 and your bitmap is 384x288. It looks like one is portrait and the other landscape plus your bitmap is twice the resolution of your Mat.


I don't have enough rep to comment so I'll provide an answer instead:

When working with the 'onCameraFrame' method - this assertion is thrown if the 'mat' you return doesn't match the size of the frame used to display the output.

In other words - if you're resizing for some sort of processing, make sure to return it to the original size before throwing it back to the display.

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

    Mat resizeImage = new Mat();
    Size sz = new Size(800, 600); // Scale up to 800x600
    Imgproc.resize(mRgba, resizeImage, sz);

    // Do some sort of processing here on resized image.

    Mat afterResize = new Mat();
    Size szAfter = new Size(640, 480); // Scale back down to 640x480 (original dim.)
    Imgproc.resize(resizeImage, afterResize, szAfter);

    return afterResize;
}