Page 1 of 1
Comparing images to determine camera movement
Posted: 2011-01-23T16:59:39-07:00
by bigtable
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
Re: Comparing images to determine camera movement
Posted: 2011-01-23T17:24:11-07:00
by anthony
Make a small image of something complex in the middle of the first frame, then look for that image in the next frame.
Re: Comparing images to determine camera movement
Posted: 2011-01-24T15:56:41-07:00
by bigtable
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.
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?
Thanks very much
Re: Comparing images to determine camera movement
Posted: 2011-01-24T16:02:56-07:00
by fmw42
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
Re: Comparing images to determine camera movement
Posted: 2011-01-24T16:39:18-07:00
by bigtable
fmw42 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
That was hidden in plain sight. Got it! I'm hoping my center crop with known coords will be sufficient to use just
Code: Select all
compare -metric rmse largeimage smallimage resultimages
I'll give it a go and post an example in case someone needs a full working example someday. This is being used in conjunction with
http://popartmachine.com/ (Vangobot), a painting robot.
Re: Comparing images to determine camera movement
Posted: 2011-01-24T18:04:24-07:00
by fmw42
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