One for the experts:
I'm trying to think of a way to analyze video and compose a single image, stitching the differences between every X frames together. For example, a camera is panning from left to right. I want to build a new stand alone image using frames from the video. The problem is, I do not know if the camera is moving west to east, east to west, north to south, etc.. Is there any known method for determining camera movement from a sequence of images? Bonus points for somewhat accurate assemblage (crops) from said camera movement.
Luke
Comparing images to determine camera movement
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Comparing images to determine camera movement
Make a small image of something complex in the middle of the first frame, then look for that image in the next frame.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Comparing images to determine camera movement
I see what you're saying. In the case of automating that approach I won't know what is interesting. What if I were to take a crop of the center of the image and compare to the next? Assuming that works (and if sometimes it doesn't, that's fine), what's the best approach to compare the small image to the next larger image? I've seen a few examples here in the forums but I'm not sure if there's a preferred method for my application. My next question is do you have any advice for measuring the XY offset to the match in the sub-image compare?anthony wrote:Make a small image of something complex in the middle of the first frame, then look for that image in the next frame.
Thanks very much
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Comparing images to determine camera movement
The best match score and location will be returned by the compare function. But you can also use the returned match score image to seek the max value. In both cases, the location will be the offset of the upper left corner of the smaller image with respect to the upper left corner of the larger image.
see viewtopic.php?f=1&t=14613&p=51076&hilit ... ric#p51076
but you now need to add subimage-search http://www.imagemagick.org/script/comma ... age-search to the command line to make it distinguish from two same size image compares.
see also http://www.imagemagick.org/script/compare.php and http://www.imagemagick.org/Usage/compare/
there is also a new metric for comparison ncc -- normalized cross correlation, but it may be slower than rmse
see http://www.imagemagick.org/script/comma ... php#metric
see viewtopic.php?f=1&t=14613&p=51076&hilit ... ric#p51076
but you now need to add subimage-search http://www.imagemagick.org/script/comma ... age-search to the command line to make it distinguish from two same size image compares.
see also http://www.imagemagick.org/script/compare.php and http://www.imagemagick.org/Usage/compare/
there is also a new metric for comparison ncc -- normalized cross correlation, but it may be slower than rmse
see http://www.imagemagick.org/script/comma ... php#metric
Re: Comparing images to determine camera movement
That was hidden in plain sight. Got it! I'm hoping my center crop with known coords will be sufficient to use justfmw42 wrote:The best match score and location will be returned by the compare function. But you can also use the returned match score image to seek the max value. In both cases, the location will be the offset of the upper left corner of the smaller image with respect to the upper left corner of the larger image.
see viewtopic.php?f=1&t=14613&p=51076&hilit ... ric#p51076
Code: Select all
compare -metric rmse largeimage smallimage resultimages
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Comparing images to determine camera movement
you now need to add -subimage-search with recent versions of IM for two images that are not the same size
needed as of IM 6.6.3-7
needed as of IM 6.6.3-7