### How to find the best match between two curves, part-to-whole

Hey all

I'm currently facing the following problem:

**given:** two curves, both approximated by sample points. One of them is slightly bigger than the other, in my case, the small curve has 20 sample points and the large one 25. They are not uniformly distributed, but the sample points are in a certain range (-> point x1 in range 0-9, point x2 in range 10-19 etc)

**what I need:** The best match between the two curves under the assumption that the small curve is a subset of the bigger curve.

I thought about a sliding-window algorithm, but I don't know how to make it rotation invariant. I need only translation and rotation, no scaling.

I already tried

```
estimateRigidTransform(Mat pointSetA, Mat pointSetB, bool fullAffine)
```

but this works only with point sets that are of equal size and the pairs of points must be corresponding (x1 with y1, x2 with y2, etc).

```
findHomography()
```

is no option, because it also calculates the perspective transform which I don't need.

Here is an image for clarification:

(The image is only a sample, I didn't count the points..)

Does anyone know an elegant algorithm for this? Or any ideas how to write my own?

Thanks in advance for any help!
Isa