False positive (FP) decreasing methods

asked 2017-06-16 20:22:04 -0600

gunner gravatar image

updated 2017-06-17 15:01:46 -0600

Eduardo gravatar image

Hello Everyone! I made object detection for fire extinguisher usinng LBP cascade training. Have 5000 positives (1000 initial) and 5000 negatives. Everything works fine but i have one problem. I get a little bit too much FP. Yes i took about 500 pictures of environment and also downloaded from internet pictures that are best for my example (walls, tiles,etc..) and put it all in negatives folder. But it still doesn't do it. I am thinking about implementing some kind of algorithm in my code that will help me to decrease FP. My idea is some kind of "time filter" that will eliminate positives that last less than x frames (for example 4 frames --> x=4). Is it good idea and is it doable?

Here is my .cpp detector code:

#include <highgui.h>
#include <iostream>
#include <stdio.h>
#include <cv.h>
#include<string>

using namespace std;
using namespace cv;
using namespace std;

int main() {
    cvNamedWindow("fire_extinguisher detecting camera", 1);
    // Capture images from any camera connected to the system
    CvCapture* capture = cvCaptureFromAVI("/home/painkiller/Desktop/video/13.mp4");

    // Load the trained model
    CascadeClassifier fire_extinguisherDetector;
    fire_extinguisherDetector.load("src/fire_extinguisher.xml");

    if (fire_extinguisherDetector.empty()) {
        printf("Empty model.");
        return 0;
    }

    char key;
    while (true) {
        // Get a frame from the camera
        Mat frame = cvQueryFrame( capture );

        stringstream x,y;
        std::vector<Rect> fire_extinguishers;

        // Detect fire_extinguisher
        fire_extinguisherDetector.detectMultiScale(frame, fire_extinguishers, 1.1, 30,
                0 | CV_HAAR_SCALE_IMAGE, Size(250, 700));

        for (int i = 0; i < (int) fire_extinguishers.size(); i++) {
            Point pt1(fire_extinguishers[i].x, fire_extinguishers[i].y);
            Point pt2(fire_extinguishers[i].x + fire_extinguishers[i].width,
                    fire_extinguishers[i].y + fire_extinguishers[i].width);

            x << fire_extinguishers[i].x;
            string strx = x.str();

            y << fire_extinguishers[i].x;
            string stry = y.str();

            // Draw a rectangle around the detected fire_extinguisher
            rectangle(frame, pt1, pt2, Scalar(0, 0, 255), 2);
            putText(frame, strx + " is x and " + stry + " is y", pt1, FONT_HERSHEY_PLAIN, 1.0,
                    Scalar(255, 0, 0), 2.0);

        }

        // Show the transformed frame
        if (!frame.empty())
        imshow("fire_extinguisher detecting camera", frame);

        // Read keystrokes, exit after ESC pressed
        key = cvWaitKey(10);
        if (char(key) == 27) {
            break;
        }
    }

    return 0;
}
edit retag flag offensive close merge delete

Comments

some kind of "time filter" -- sure that's doable. but if you already need 40 minNeighbours for the detection, you're getting too many positives all in all, meaning, your classifier is not soo good.

berak gravatar imageberak ( 2017-06-17 01:22:51 -0600 )edit

yeah i made the minNeigbours number so big (30) so it gives me the smallest number of FP. But it isn't so bad really, it works with 3 minnegbours too. But i need to decrease the number of FP as much as possible. Anyways can you explain me time filtering or give me some link about that, i searched google and found nothing..?

gunner gravatar imagegunner ( 2017-06-17 06:32:47 -0600 )edit

have you tried training a haar cascade instead of lbp ? they're usually more accurate (more patterns to check against)

berak gravatar imageberak ( 2017-06-18 03:08:24 -0600 )edit

@berak I tried to train haar cascade. After 22 hours it was on stage 2 (I guess one reason is big number of samples..?) So i gave up on it. I will please you one more time about time filtering because i want to implement it and it was my first question in this post.

gunner gravatar imagegunner ( 2017-06-20 14:15:45 -0600 )edit