0

I'm using OpenCV 2.4.2 VideoCapture class to grab frames from multiple videos and my aim is to compare the frames between videos to retrieve similar videos (visually similar).

I'm facing two issues.

  1. The videos contain blank/black frames. I can loop over each individual frame (while capturing the video) and check the pixels etc. to detect these frames. Is there a faster and more efficient way to somehow do this? I have more than 1k videos and each video has around 5k-20k frames [I'm capturing 1 frame per second]. I'm coding in C++.

  2. Comparing two huge matrices to check how "similar" they are. I eventually compute a huge matrix for each video where the rows correspond to the number of the frames, and the cols correspond to the dimensionality of the descriptor being computed on each frame. If I need to compare two videos for similarity, the simplest thing I found was to compute Euclidean matrix. But again, horribly inefficient if I scale up to 1000s of videos.

Any advice and suggestion will be appreciated.

Thanks,

Uni
  • 45
  • 2
  • 5
  • For #1 you could use a probabilistic test. Choose n random pixel locations and check if all of those are black in a frame. If they all are, declare the image to be blank. The higher your n, the higher your precision (your recall will be perfect), the lower n is the faster it will run – Hammer Jul 30 '13 at 16:51
  • Thanks for the feedback. I resolved this by computing mean of the B,G,R channels and adding a condition. It worked and didn't slow down the program at all. Issue # 2 still remains unresolved. – Uni Aug 02 '13 at 00:18

1 Answers1

0

Concerning the first problem, I think cv::countNonZero is the most suitable method, it works very fast as well. cv::countNonZero returns the number of non-zero elements in input single-channel array.

FutureJJ
  • 2,368
  • 1
  • 19
  • 30
Andrey Smorodov
  • 10,649
  • 2
  • 35
  • 42
  • I think cv::countNonZero works only for a single channel image right? I have an RGB (or rather, BGR) image. – Uni Aug 01 '13 at 21:32
  • You can split your image with cv::split function, then check only one channel (I think it will be enough). – Andrey Smorodov Aug 02 '13 at 05:55