(formerly) The problem of OpenCV width in Java

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.