У меня есть следующий код:
Rect rect = Imgproc.boundingRect(screenCnt2f);
// do transpose
Mat destImage = new Mat(new Size(rect.width, rect.height), orig.type());
Mat src = orderPointsClockwise(screenCnt2f);
dst = new MatOfPoint2f(new Point(0, 0), new Point(rect.width - 1, 0),
new Point(rect.width - 1, rect.height - 1), new Point(0, rect.height - 1));
Mat transform = Imgproc.getPerspectiveTransform(src, dst);
Imgproc.warpPerspective(orig, destImage, transform, destImage.size());
Если у меня есть пиксель в местоположении x, y,
Как я могу вычислить местоположение того же пикселя в destImage
?
Так что, если Point p
содержит значения x, y, я бы хотел метод newPointLocation
:
Point pp = newPointLocation(p, tranform);
, чтобы pp
содержал тот же пиксель в destImage
Тот же код с warpAffine
:
Point center = new Point(src.width() / 2, src.height() / 2);
Mat rotImage = Imgproc.getRotationMatrix2D(center, angle, 1.0);
// 1.0 means 100 % scale
Size size = new Size(src.width(), src.height());
Imgproc.warpAffine(src, src, rotImage, size, Imgproc.INTER_LINEAR + Imgproc.CV_WARP_FILL_OUTLIERS);
Point pp = newPointLocation(p, rotImage);