Solved

# How to handle Blank Frame when recording a video

Posted on 2006-06-01
Medium Priority
182 Views
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.

0
Question by:CongUan
• 2

LVL 4

Accepted Solution

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

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

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
Course of the Month16 days, 18 hours left to enroll