[英]how to train two objects with different sizes in openCv
I try to train the licence plate car and licence plate motorcycle with OpenCv version 2.4.10. 我尝试使用OpenCv版本2.4.10训练牌照汽车和牌照摩托车。
I have a 235 images positives and a 300 negative images. 我有235张正像和300张负像。
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. 对于正像,牌照车的实际尺寸为40 cm x 13 cm,而牌照摩托车的实际尺寸为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
// detectMultiScale 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!");
}
Since these two types of plates are of different aspect ratios, you can try to train a different classifier for each type. 由于这两种类型的板的纵横比不同,因此您可以尝试为每种类型训练不同的分类器。 On paper, that is more accurate.
在纸上,这更准确。
Your problem may come from a missing minus sign before h
in createsamples
您的问题可能来自
createsamples
h
之前的减号丢失
Try the following: 请尝试以下操作:
createsamples -info c:\harrkit\HAARKITV10\povitivos\info.txt -vec vetor\veiculos_64x24.vec -num 235 -w 64 -h 24
It should work because createsamples
a collection of positives with fix width and height (64x64). 它应该起作用,因为
createsamples
具有固定宽度和高度(64x64)的一组正值。
You must change your "h" and "w" parameters to train the second type of your objects , those parameters can cause problem especially if they don't match with your object's size. 您必须更改“ h”和“ w”参数来训练对象的第二种类型,这些参数可能会引起问题,尤其是当它们与对象的大小不匹配时。 Also , can you put your console, we must take a look on your errors to figure out the origin of your problem!
此外,您能否放置控制台,我们必须查看您的错误以找出问题的根源!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.