D
D
Dima_kras2018-09-29 12:34:08
Python
Dima_kras, 2018-09-29 12:34:08

How to cut rectangle from image and rotate horizontally on OpenCv + python?

Good afternoon, there is a picture, the coordinates of a rectangular area are known. It is necessary to cut out the area and tighten it to a horizontal position. How to do it?
I understand how to cut a rectangle if it is not rotated
imageCut=image[y1:y2,x1:x2]
But how to cut a rectangle by 4 points?
And then how to trust?
5baf46c783ac9649117026.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AAEgorovich, 2018-10-01
@AAEgorovich

First you need to rotate around the center of the rectangle, taking into account the size of the rectangle (see cv2.getRotationMatrix2D and cv2.warpAffine, example: https://stackoverflow.com/questions/22041699/rotat... and then cut.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question