perogram

Why mat.submat copy unexpected region? Resolved!

f:id:peroon:20181116192349j:plain

  • I wanted to copy eyeblow region, but copied unexpected region
  • I noticed that cropped region is mirrored by green line
  • I checked docs
submat(int rowStart, int rowEnd, int colStart, int colEnd) 
          Extracts a rectangular submatrix.
  • parameter order is y, y, x, x!
  • I wrote like this, and it works!
            Mat sub = new Mat();
            int xStart = (int)cutRegion.x;
            int xEnd = (int)cutRegion.y;
            int yStart = (int)cutRegion.z;
            int yEnd = (int)cutRegion.w;
            im.submat(yStart, yEnd, xStart, xEnd).copyTo(sub);

Learning OpenCV 3: Computer Vision in C++ with the OpenCV Library (English Edition)

Learning OpenCV 3: Computer Vision in C++ with the OpenCV Library (English Edition)