How to handle Blank Frame when recording a video

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

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    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.

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now