Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Object detection not working

Hello everybody! I Am working on my masters degree. My first task is to do bananadetector by following this tutorial:

http://technobium.com/object-detection-with-opencv/ Did whole tutorial but in the end, detector doesn't work. It shows red rectangle saying "banana" in the wrong places, it doesn't recognize bananas. Total disaster. I have been trying to make it work for more than 10 days, but nothing helped. For training I made 1400 positives and 3000 negatives and used next commands to train model:

opencv_createsamples -info positives.txt -num 1200 -w 60 -h 80 -vec training.vec

opencv_traincascade -data data -vec training.vec -bg negatives.txt -numPos 1000 -numNeg 1000 -numStages 10 -nsplits 2 -w 60 -h 80 -featureType LBP -minhitrate 0.999 -maxfalsealarm 0.5

I have 3 more days to solve this till monday.

PLEASE, any help I am literally begging..

Object detection not working

Hello everybody! I Am working on my masters degree. My first task is to do bananadetector by following this tutorial:

http://technobium.com/object-detection-with-opencv/ Did whole tutorial but in the end, detector doesn't work. It shows red rectangle saying "banana" in the wrong places, it doesn't recognize bananas. Total disaster. I have been trying to make it work for more than 10 days, but nothing helped. For training I made 1400 positives and 3000 negatives and used next commands to train model:

opencv_createsamples -info positives.txt -num 1200 -w 60 -h 80 -vec training.vec

opencv_traincascade -data data -vec training.vec -bg negatives.txt -numPos 1000 -numNeg 1000 -numStages 10 -nsplits 2 -w 60 -h 80 -featureType LBP -minhitrate 0.999 -maxfalsealarm 0.5

Here is my BananaDetector.cpp file

include <highgui.h>

include <iostream>

include <stdio.h>

include <cv.h>

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

int main() {

cvNamedWindow("Brezel detecting camera", 1);
// Capture images from any camera connected to the system
CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);

// Load the trained model
CascadeClassifier brezelDetector;
brezelDetector.load("src/brezel.xml");

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

char key;
while (true) {

    // Get a frame from the camera
    Mat frame = cvQueryFrame(capture);

    std::vector<Rect> brezels;

    // Detect brezels
    brezelDetector.detectMultiScale(frame, brezels, 1.1, 30,
            0 | CV_HAAR_SCALE_IMAGE, Size(200, 320));

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

        // Draw a rectangle around the detected brezel
        rectangle(frame, pt1, pt2, Scalar(0, 0, 255), 2);
        putText(frame, "Brezel", pt1, FONT_HERSHEY_PLAIN, 1.0,
                Scalar(255, 0, 0), 2.0);

    }

    // Show the transformed frame
    imshow("Brezel detecting camera", frame);

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

return 0;

}

I have 3 more days to solve this till monday.

PLEASE, any help I am literally begging..

click to hide/show revision 3
No.3 Revision

updated 2017-05-19 06:17:02 -0600

berak gravatar image

Object detection not working

Hello everybody! I Am working on my masters degree. My first task is to do bananadetector by following this tutorial:

http://technobium.com/object-detection-with-opencv/ Did whole tutorial but in the end, detector doesn't work. It shows red rectangle saying "banana" in the wrong places, it doesn't recognize bananas. Total disaster. I have been trying to make it work for more than 10 days, but nothing helped. For training I made 1400 positives and 3000 negatives and used next commands to train model:

opencv_createsamples -info positives.txt -num 1200 -w 60 -h 80 -vec training.vec

opencv_traincascade -data data -vec training.vec -bg negatives.txt -numPos 1000 -numNeg 1000 -numStages 10 -nsplits 2 -w 60 -h 80 -featureType LBP -minhitrate 0.999 -maxfalsealarm 0.5

Here is my BananaDetector.cpp file

include <highgui.h>

include <iostream>

include <stdio.h>

include <cv.h>

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

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

std; int main() {

{

    cvNamedWindow("Brezel detecting camera", 1);
 // Capture images from any camera connected to the system
 CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);

 // Load the trained model
 CascadeClassifier brezelDetector;
 brezelDetector.load("src/brezel.xml");

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

 char key;
 while (true) {

     // Get a frame from the camera
     Mat frame = cvQueryFrame(capture);

     std::vector<Rect> brezels;

     // Detect brezels
     brezelDetector.detectMultiScale(frame, brezels, 1.1, 30,
             0 | CV_HAAR_SCALE_IMAGE, Size(200, 320));

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

         // Draw a rectangle around the detected brezel
         rectangle(frame, pt1, pt2, Scalar(0, 0, 255), 2);
         putText(frame, "Brezel", pt1, FONT_HERSHEY_PLAIN, 1.0,
                 Scalar(255, 0, 0), 2.0);

     }

     // Show the transformed frame
     imshow("Brezel detecting camera", frame);

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

 return 0;
}

}

I have 3 more days to solve this till monday.

PLEASE, any help I am literally begging..

Object detection not working

Hello everybody! I Am working on my masters degree. My first task is to do bananadetector by following this tutorial:

http://technobium.com/object-detection-with-opencv/ Did whole tutorial but in the end, detector doesn't work. It shows red rectangle saying "banana" in the wrong places, it doesn't recognize bananas. Total disaster. I have been trying to make it work for more than 10 days, but nothing helped. For training I made 1400 positives and 3000 negatives and used next commands to train model:

opencv_createsamples -info positives.txt -num 1200 -w 60 -h 80 -vec training.vec

opencv_traincascade -data data -vec training.vec -bg negatives.txt -numPos 1000 -numNeg 1000 -numStages 10 -nsplits 2 -w 60 -h 80 -featureType LBP -minhitrate 0.999 -maxfalsealarm 0.5

Here is my BananaDetector.cpp file

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

include <highgui.h>

include <iostream>

include <stdio.h>

include <cv.h>

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

int main() { {

cvNamedWindow("Brezel detecting camera", 1);
 // Capture images from any camera connected to the system
 CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);

 // Load the trained model
 CascadeClassifier brezelDetector;
 brezelDetector.load("src/brezel.xml");

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

 char key;
 while (true) {

     // Get a frame from the camera
     Mat frame = cvQueryFrame(capture);

     std::vector<Rect> brezels;

     // Detect brezels
     brezelDetector.detectMultiScale(frame, brezels, 1.1, 30,
             0 | CV_HAAR_SCALE_IMAGE, Size(200, 320));

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

         // Draw a rectangle around the detected brezel
         rectangle(frame, pt1, pt2, Scalar(0, 0, 255), 2);
         putText(frame, "Brezel", pt1, FONT_HERSHEY_PLAIN, 1.0,
                 Scalar(255, 0, 0), 2.0);

     }

     // Show the transformed frame
     imshow("Brezel detecting camera", frame);

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

 return 0;
}

}

I have 3 more days to solve this till monday.

PLEASE, any help I am literally begging..

Object detection not working

Hello everybody! I Am working on my masters degree. My first task is to do bananadetector by following this tutorial:

http://technobium.com/object-detection-with-opencv/ Did whole tutorial but in the end, detector doesn't work. It shows red rectangle saying "banana" in the wrong places, it doesn't recognize bananas. Total disaster. I have been trying to make it work for more than 10 days, but nothing helped. For training I made 1400 positives and 3000 negatives and used next commands to train model:

opencv_createsamples -info positives.txt -num 1200 -w 60 -h 80 -vec training.vec

opencv_traincascade -data data -vec training.vec -bg negatives.txt -numPos 1000 -numNeg 1000 -numStages 10 -nsplits 2 -w 60 -h 80 -featureType LBP -minhitrate 0.999 -maxfalsealarm 0.5

Here is my BananaDetector.cpp file

include <highgui.h>

include <iostream>

include <stdio.h>

include <cv.h>

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

int main() {

cvNamedWindow("Brezel cvNamedWindow("Banana detecting camera", 1);
// Capture images from any camera connected to the system
CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);
cvCaptureFromAVI("/home/painkiller/Desktop/banana.mp4");



// Load the trained model
CascadeClassifier brezelDetector;
brezelDetector.load("src/brezel.xml");
bananaDetector;
bananaDetector.load("src/banana.xml");

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

char key;
while (true) {

    // Get a frame from the camera
     Mat frame = cvQueryFrame(capture);
cvQueryFrame( capture );

    std::vector<Rect> brezels;
bananas;

    // Detect brezels
    brezelDetector.detectMultiScale(frame, brezels, banana
    bananaDetector.detectMultiScale(frame, bananas, 1.1, 30,
            0 | CV_HAAR_SCALE_IMAGE, Size(200, 320));
Size(100,440));

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

        // Draw a rectangle around the detected brezel
banana
        rectangle(frame, pt1, pt2, Scalar(0, 0, 255), 2);
        putText(frame, "Brezel", "Banana", pt1, FONT_HERSHEY_PLAIN, 1.0,
                Scalar(255, 0, 0), 2.0);

    }

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

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

return 0;

}

I have 3 more days to solve this till monday.

PLEASE, any help I am literally begging..

Object detection not working

Hello everybody! I Am working on my masters degree. My first task is to do bananadetector by following this tutorial:

http://technobium.com/object-detection-with-opencv/ Did whole tutorial but in the end, detector doesn't work. It shows red rectangle saying "banana" in the wrong places, it doesn't recognize bananas. Total disaster. I have been trying to make it work for more than 10 days, but nothing helped. For training I made 1400 positives and 3000 negatives and used next commands to train model:

opencv_createsamples -info positives.txt -num 1200 -w 60 -h 80 -vec training.vec

opencv_traincascade -data data -vec training.vec -bg negatives.txt -numPos 1000 -numNeg 1000 -numStages 10 -nsplits 2 -w 60 -h 80 -featureType LBP -minhitrate 0.999 -maxfalsealarm 0.5

Here is my BananaDetector.cpp file

include <highgui.h>

include <iostream>

include <stdio.h>

include <cv.h>

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

int main() {

cvNamedWindow("Banana detecting camera", 1);
// Capture images from any camera connected to the system
CvCapture* capture = cvCaptureFromAVI("/home/painkiller/Desktop/banana.mp4");



// Load the trained model
CascadeClassifier bananaDetector;
bananaDetector.load("src/banana.xml");

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

char key;
while (true) {

    // Get a frame from the camera

    Mat frame = cvQueryFrame( capture );

    std::vector<Rect> bananas;

    // Detect banana
    bananaDetector.detectMultiScale(frame, bananas, 1.1, 30,
            0 | CV_HAAR_SCALE_IMAGE, Size(100,440));

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

        // Draw a rectangle around the detected banana
        rectangle(frame, pt1, pt2, Scalar(0, 0, 255), 2);
        putText(frame, "Banana", pt1, FONT_HERSHEY_PLAIN, 1.0,
                Scalar(255, 0, 0), 2.0);

    }

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

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

return 0;

}

I have 3 more days to solve this till monday.

PLEASE, any help I am literally begging..monday...