OpenCV row (high) and column (wide) parameter order problem _OPENCV

Source: Internet
Author: User

I've met a couple of times before. Due to a row and column error causing the pointer to go out of bounds, here are some of the things I've summarized:


Condition one (definition iplimage*):

IPLIMAGE*DST = NULL;
DST =cvcreateimage (cvsize), ipl_depth_8u, 3);

The DST created here is 480 rows and 600 columns, preceded by a row.

Situation two (definition mat):

Mat DST;
DST =mat (CV_8UC3);

The DST created here is also 480 rows and 600 columns, but the first column.

Situation three (defining areas of interest):

Rectroi_rect;
roi_rect.x=10;
roi_rect.y=20;

This represents the coordinate (x,y) of the upper-left pixel of the defined area of interest (rectangle) (10,20), which is in row 20th, column 10th.

These details are important, and when you traverse a picture using nested for loops, there is a good chance that if you don't pay attention to the details of the rows and columns, there is a high likelihood of errors in the pointer crossing.


--------------------------------------------------------------------------------------------------------------- --------------------

2016.11.03 Supplements

--------------------------------------------------------------------------------------------------------------- --------------------

Yesterday, the lab students found the following situation:

Use

Mat img = Mat (cv::size (), CV_8UC3);

The img defined is 600 rows, 480 columns.

And the situation I mentioned above two is defined by 480 lines, 600 columns ... Note the use of cv::size.

Special attention should be paid here.

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.