Solved

# How to handle Blank Frame when recording a video

Posted on 2006-06-01
180 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

LVL 4

Accepted Solution

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

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

### Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generatâ€¦
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more â€¦
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

#### Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!