0

In this answer described how to get picture from two images so intersection (common part of them) will be coloured black — https://stackoverflow.com/a/31258083/4767232

How can I get this result not as picture but as a rect (e.g. left=100, top=50, bottom=200, right=300)?

Alexander Ukhov
  • 458
  • 6
  • 10
  • I don't know if you can get from `warpPerspective` pure rect with parameters (height, width, x, y) because of angle. You can find on mask max contours, and this will be your left, top, bottom and right corner. You can also using Harris Corner Detection on mask for get 4 corners. – Nejc Galof May 04 '18 at 10:28

1 Answers1

0

The position of intersection can be obtained by transforming zero point by the H matrix.

val p0 = MatOfPoint2f(org.opencv.core.Point(0.0, 0.0))
val result = Mat()
Core.transform(p0, result, H)

(and getting size of the rect is trivial)

Alexander Ukhov
  • 458
  • 6
  • 10