How to train two objects with different sizes in openCv [closed]

asked 2015-05-06 10:49:38 -0600

Fabbricio gravatar image

updated 2015-05-07 07:20:34 -0600

I try to train the licence plate car and licence plate motorcycle with OpenCv version 2.4.10.

I have a 235 images positives and a 300 negative images.

For positive images the licence plate car the real size is 40 cm x 13 cm and licence plate motorcycle have real size 20 cm x 17 cm. When tried to train the vectors separately the software works fine, but when I tried to train utilizing the two plates, the software doesn't work.

Here is the utilized code of training.

This code works with a licence plate car, but doesn't works with licence plate motorcycle

 createsamples -info c:\harrkit\HAARKITV10\povitivos\info.txt -vec vetor\veiculos_64x24.vec -num 235 -w 64 -h 24

trainCascade -data cascade -vec c:\harrkit\HAARKITV10\vetor\veiculos_64x24.vec -bg c:\harrkit\HAARKITV10\negativos\negativos.txt -numPos 235 -numNeg 200 -numStages 12  -featureTyp HAAR -minHitRate 0.999 -maxFalseAlarmRate 0.5 -w 64 -h 24

// code detectMultiScale

if (mAbsolutePlateSize == 0) {
     int height = mGray.rows();
    if (Math.round(height * mRelativePlateSize) > 0) {
        mAbsolutePlateSize = Math.round(height * mRelativePlateSize);
    }
    mNativeDetector.setMinFaceSize(mAbsolutePlateSize);
}

MatOfRect mMatPlacas = new MatOfRect();

if (mDetectorType == JAVA_DETECTOR) {
    if (mJavaDetector != null)
        mJavaDetector.detectMultiScale(mGray, mMatPlacas, 1.1, 2, 2, new Size(mAbsolutePlateSize,          mAbsolutePlateSize), new Size()); 
    } else if (mDetectorType == NATIVE_DETECTOR) {
        if (mNativeDetector != null)
            mNativeDetector.detect(mGray, mMatPlacas);
    } else {
    Log.e(TAG, "Detection method is not selected!");
}
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-06 12:25:51.434796

Comments

That is quite normal, since the ratio of the input data is NOT identical, nor will it ever be. This means that before training, your opencv_createsamples application will force the motorcycles numberplates to a form that will never occur in test images and thus it will never be retrieved. Only way to achieve what you want is to use a double model classification.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-05-07 07:23:11 -0600 )edit

My remark stays, it is NOT possible to combine them!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-05-07 07:44:15 -0600 )edit

@Fabruccio, it is simply using two times a single model ... like you said in your own question and which is proved to work ...

StevenPuttemans gravatar imageStevenPuttemans ( 2015-05-07 08:40:50 -0600 )edit

Do You mean, train the objects separately?

Fabbricio gravatar imageFabbricio ( 2015-05-07 09:36:35 -0600 )edit
1

Yes, train a single model for the car numberplates and a single model for the motorbike numberplates!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-05-07 12:26:31 -0600 )edit