1 | initial version |

Hi,

You could try to estimate the homography with a Ransac approach to try to not take into account the inliers.

These are my results (not as good as yours) using calcOpticalFlowPyrLK, findHomography (with CV_RANSAC) and warpPerspective.

Optical flow:

Inliers:

Warp perspective:

Final image:

The mean estimated motion:

```
Mean x = 80.03 ; Mean y = 2.18
```

By the way, when you said:

Remap every image in new image by cylindrical equations (as shown in "Image Alignment and Stitching: A Tutorial" by Richard Szeliski).

Is it the section 2.3 Cylindrical and Spherical Coordinates page 15 ?

2 | No.2 Revision |

Hi,

You could try to estimate the homography with a Ransac approach to try to not take into account the inliers.

These are my results (not as good as yours) using calcOpticalFlowPyrLK, findHomography (with CV_RANSAC) and warpPerspective.

~~Optical flow:~~__Optical flow__:

~~Inliers:~~__Inliers__:

~~Warp perspective:~~__Warp perspective__:

~~Final image:~~__Final image__:

The mean estimated motion:

```
Mean x = 80.03 ; Mean y = 2.18
```

By the way, when you said:

Remap every image in new image by cylindrical equations (as shown in "Image Alignment and Stitching: A Tutorial" by Richard Szeliski).

Is it the section 2.3 Cylindrical and Spherical Coordinates page 15 ?

__Edit__:

This time I only display the second image with the displacement estimated (no warping).

It is a little bit better I think:

3 | No.3 Revision |

Hi,

You could try to estimate the homography with a Ransac approach to try to not take into account the inliers.

These are my results (not as good as yours) using calcOpticalFlowPyrLK, findHomography (with CV_RANSAC) and warpPerspective.

~~__Optical flow__:~~**Optical flow:**

~~__Inliers__:~~**Inliers:**

~~__Warp perspective__:~~**Warp perspective:**

~~__Final image__:~~**Final image:**

The mean estimated motion:

```
Mean x = 80.03 ; Mean y = 2.18
```

By the way, when you said:

Remap every image in new image by cylindrical equations (as shown in "Image Alignment and Stitching: A Tutorial" by Richard Szeliski).

Is it the section 2.3 Cylindrical and Spherical Coordinates page 15 ?

~~__Edit__:~~**Edit:**

This time I only display the second image with the displacement estimated (no warping).

It is a little bit better I think:

4 | No.4 Revision |

Hi,

~~You could ~~It is not clear for me if you use findHomography + Ransac or if you try ~~to estimate the homography with a Ransac approach to try to not take into account the inliers.~~the two approaches independently.

**Optical flow:**

**Inliers:**

**Warp perspective:**

**Final image:**

The mean estimated ~~motion:~~motion (I use the inliers returned by findHomography and I just average the corresponding motion vectors):

`Mean x = 80.03 px ; Mean y = `~~2.18
~~2.18 px

By the way, when you said:

Is it the section 2.3 Cylindrical and Spherical Coordinates page 15 ?

**Edit:**

This time I only display the second image with the displacement estimated (no warping).

It is a little bit better I think:

5 | No.5 Revision |

Hi,

It is not clear for me if you use findHomography + Ransac or if you try the two approaches independently.

These are my results (not as good as ~~yours) ~~yours but I don't need to threshold the vectors manually, in fact I use the result of findHomography+Ransac to keep the inliers) using calcOpticalFlowPyrLK, findHomography (with CV_RANSAC) and warpPerspective.

**Optical flow:**

**Inliers:**

**Warp perspective:**

**Final image:**

The mean estimated motion (I use the inliers returned by findHomography and I just average the corresponding motion vectors):

```
Mean x = 80.03 px ; Mean y = 2.18 px
```

By the way, when you said:

Is it the section 2.3 Cylindrical and Spherical Coordinates page 15 ?

**Edit:**

This time I only display the second image with the displacement estimated (no warping).

It is a little bit better I think:

**Edit2:**

I think I made a mistake with warpPerspective: I forgot to inverse the homography H when I applied it to the second image.

The result:

6 | No.6 Revision |

Hi,

It is not clear for me if you use findHomography + Ransac or if you try the two approaches independently.

These are my results (not as good as yours but I don't need to threshold the vectors manually, in fact I use the result of findHomography+Ransac to keep the inliers) using calcOpticalFlowPyrLK, findHomography (with CV_RANSAC) and warpPerspective.

**Optical flow:**

**Inliers:**

**Warp perspective:**

**Final image:**

The mean estimated motion (I use the inliers returned by findHomography and I just average the corresponding motion vectors):

```
Mean x = 80.03 px ; Mean y = 2.18 px
```

By the way, when you said:

Is it the section 2.3 Cylindrical and Spherical Coordinates page 15 ?

**Edit:**

This time I only display the second image with the displacement estimated (no warping).

It is a little bit better I think:

**Edit2:**

I think I made a mistake with warpPerspective: I forgot to inverse the homography H when I applied it to the second image.

The result:

Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.