# findHomography + perspectiveTransform --> exceeds target Rect

Hi all,

I develop with python, with numpy and openCV (3.1.0).

I have a SRC array of 2D points, which I wish to warp into a rectangle region.

```
SRC.T = array([[209 210 239 274 307 337 366 404 427 461 484 489 493]
[330 309 339 304 310 332 353 311 348 324 337 317 296]])
```

I've calculated the required homography (H) as following:

```
H, _ = findHomography(rect_src, rect_dst)
```

Where:

```
rect_src = array([[209, 282], [209, 330], [484, 337], [493, 296]])
rect_dst = array([[209, 296], [209, 353], [493, 353], [493, 296]])
```

I got the following homography matrix (which I've verifying manually it makes sense..):

```
H = [[ 5.81755130e-01 -1.21849288e-01 7.21264687e+01]
[ -1.46583486e-01 6.99605042e-01 5.90321609e+01]
[ -3.49962434e-04 -5.83010949e-04 1.00000000e+00]]
```

I've then warped the SRC points with the above homography matrix, hoping all SRC points will utilize the rect_dst region:

```
DST = perspectiveTransform(SRC, H).astype(int)
```

I got the following DST points:

```
DST.T = array([[209 209 236 267 299 330 363 397 429 462 493 493 493]
[353 327 363 318 324 351 378 320 370 335 353 324 296]])
```

Unfortunately, the DST points exceed the rect_dst region, so I didn't get the desired outcome...

Attached you may find a debug image, where SRC points are in blue and DST points are in yellow (please ignore the red and the green points).

Can you please advise me where did I go wrong and how to obtain the desired feature?

Thanks ahead, Shahar

I wish that all the blue points (SRC) will reside inside the yellow rectangle. Is there a way to obtain that? Desirably, they should get arranged in 3 parallel rows.