public Mat(Mat m, Rect roi) - opencv4android Version 2.4.1 (Bug #2063)


Added by Ruoxi Wang over 12 years ago. Updated over 12 years ago.


Status:Done Start date:2012-06-18
Priority:Normal Due date:
Assignee:Andrey Pavlenko % Done:

0%

Category:java bindings
Target version:2.4.2
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

  • This constructor is not functioning properly.
  • I have to swap the value of x and y, also width and height, of ROI, to make it work as it should, like this:
            int temp = roi.width;
            roi.width = roi.height;
            roi.height = temp;
    
            temp = roi.x;
            roi.x = roi.y;
            roi.y = temp;
    
  • In Mat.java I found the constructor code :
    public Mat(Mat m, Rect roi)
    {

        nativeObj = n_Mat(m.nativeObj, roi.x, roi.x + roi.width, roi.y, roi.y + roi.height);

        return;
    }

Where the description for n_Mat is:

long org.opencv.core.Mat.n_Mat(long m_nativeObj, int rowRange_start, int rowRange_end, int
colRange_start, int colRange_end)

I then tried to display image.rows (in c++) for a image with a width of 547 and a height of 289, the result is 289.

  • So i reckon the constructor should actually be:

public Mat(Mat m, Rect roi)
    {

        nativeObj = n_Mat(m.nativeObj, roi.y, roi.y + roi.height, roi.x, roi.x + roi.width);

        return;
    }

BTW, I am using opencv4android version 2.4.1 (with eclipse).


Associated revisions

Revision dc93c219
Added by Andrey Pavlenko over 12 years ago

fix for #2063 ( Mat(Mat m, Rect roi) returns wrong sub-mat)

Revision 5c25d821
Added by Andrey Pavlenko about 11 years ago

Merge pull request #2063 from vpisarev:ocl_moments

History

Updated by Kirill Kornyakov over 12 years ago

Andrey, could you please check it?

  • Category set to java bindings
  • Assignee set to Andrey Pavlenko

Updated by Andrey Pavlenko over 12 years ago

Thanks for reporting! Fixed in r8705, targeted to coming 2.4.2.

  • Status changed from Open to Done
  • Target version set to 2.4.2

Also available in: Atom PDF