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..