Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

False positive (FP) decreasing methods

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;

}

False positive (FP) decreasing methods

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;

}

click to hide/show revision 3
No.3 Revision

False positive (FP) decreasing methods

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>

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

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

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;
}

}