J
J
jallvar2019-04-05 19:59:27
Video processing
jallvar, 2019-04-05 19:59:27

How to find a frame from a video?

Hello. I need an optimal solution to find a picture in a video.
There are a number of images with alleged videos where they were taken from. Image - frame from video.
The frame may be of poorer quality, with watermarks and other interference. The frame itself is a different size.
I thought of the Go through the video for each frame. Getting it phash or dhash. In turn, do the same with the desired frame. And compare their hash sums in a loop.
The trouble is. That the total number of frames mb 100 thousand and more. If you're lucky, the desired frame will be at the beginning, and if not? That's trouble. Hang on a bunch of threads and wait about 5 minutes.
What's wrong with waiting 5 minutes?
I have about 5 thousand image-video pairs in the queue.
And I don't want to overload my computer too much.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Mirilaczvili, 2019-04-06
@2ord

You can do an offline search like this:
For each extracted video frame, calculate its hash (phash or dhash) and write it, along with the video file ID and frame number, to a table in the SQLite DBMS.
Then you run a query to find candidate frames using the Hamming distance:

SELECT video_id, frame_num
FROM hashes_table
WHERE hamming_distance(image_hash, frame_hash) < N;

Other ways are suggested in opencv-finding-picture-frame-in-video

A
Arseny Kravchenko, 2019-04-06
@Arseny_Info

Calculate the embeddings of all frames, put them in a database like https://github.com/spotify/annoy or https://github.com/facebookresearch/faiss, and use it to search.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question