Debugger, my side is responsible for converting the data in the buffer into bitmp in JNI. Test with 320*240 image test is normal, but others use the image width of 270, the image appears dislocation (no, not good understanding).
The first thing to think about is the OpenCV image width problem (which is actually the problem, but I debug the wrong place).
Begin to change the width of the bitmap image to be divisible by 4, resulting in incorrect images and occasional crashes ...
The width of the bitmap and input buffers is then changed to be divisible by 4, resulting in an oblique stripe of no data.
Then I use raw data test, found that the code is normal. Finally, it suddenly occurred to me that the input buffer is OPENCV data, the width of the data is forced to be 4 whole except. Thus the width of the bitmap is changed to the required input (e.g. 270), the width of the buffer is recalculated and converted to an integer multiple of 4. The image is normal and the program does not crash ...
int widthcv= (int((width-1)/4.0+1) *4);
began to confuse the width of the OpenCV and the bitmap so that it was debugged for a while. And the first thing that I didn't think anyone else gave me was OPENCV generated data, resulting in width not necessarily the original data width.
Try to pay attention to it later ...
(formerly) The problem of OpenCV width in Java