?
Solved

How to handle Blank Frame when recording a video

Posted on 2006-06-01
4
Medium Priority
?
182 Views
Last Modified: 2010-04-01
Hi Experts,
I have record a video avi, but some time I get a blank frame at first. I need to remove this but I don't know how to check if bitmap frame is blank or not. Please help me with checking for this.

Thanks in advance!
0
Comment
Question by:CongUan
  • 2
2 Comments
 
LVL 4

Accepted Solution

by:
e_tadeu earned 2000 total points
ID: 16806398
int blackR = 0;
int blackG = 0;
int blackB = 0;

int sum = 0;
for (int y = 0; y < height; ++y) {
  for (int x = 0; x < width; ++x) {
    sum += abs(pixelAt(x,y).red() - blackR);
    sum += abs(pixelAt(x,y).green() - blackG);
    sum += abs(pixelAt(x,y).blue() - blackB);
  }
}

if (sum == 0) {
  // this frame is blank, discard it
}

Got it ?
0
 
LVL 4

Expert Comment

by:e_tadeu
ID: 16806981
Basically, the algorithm above will work if your "blank frame" is really black, with all pixels zeroed. Maybe your blank frame is not really black.. in this case, you can test for a threshold, e.g.:

if (sum <= width*height*3) {
  // this frame is blank, discard it
}

Or, for example, if the frame is blue, you can change your constants:

int blackR = 0;
int blackG = 0;
int blackB = 255;

Just change the pixelAt(x,y).red() for whatever method you use to get the pixels values!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question