ci2v searches videos for frames most similar to an image.
- python
- numpy
- opencv
- scikit-image
ci2v just needs an input image and a target video:
$ python ci2v.py --image path/to/image --video path/to/video
Results are formatted by:
- rank
- frame number
- similarity score between 0 and 1
Sample output:
--results:
#1 381 : 0.773894658419
--time taken:
0:00:12.341023
ci2v can optionally save matched frames as images:
example: save the five best-matching frames from a video
$ python ci2v.py --image path/to/image --video path/to/video --number 5 --output matched_frame.jpg
You can refine a ci2v search with these options:
Path to an image file.
Supported formats: .bmp
.jpeg
.jpg
.jp2
.png
.pbm
.pgm
.ppm
.tiff
.tif
Path to an ffmpeg
-compatible video file.
Number of best matches to return.
Break search when similarity level equals or exceeds this level.
Save matched frames as images
Output images are appended with their rank match number, <filename>_n.<ext>
.
See --image
for supported formats.
Search recursively through the specified directory for video files and process each one.
ci2v is built around OpenCV and scikit-image, and uses the latter's Structural similarity index function to compare an input image to a video frame.
Because ssim
can be slow with large images, ci2v rescales images to 10x10px greyscale arrays. This means ci2v can search a video at around 200fps and still find acceptable matches.