1

我正在尝试使用 haar 训练来训练级联。我使用了以下参数。

C:\opencv\opencv_bin\bin>opencv_haartraining -data haar -vec train.vec  -bg neg.
txt -numPos 1000 -numNeg 2000 -nstages 10 -mem 2000 -mode all -w 30 -h 32

但我收到以下错误

Data dir name: haar
Vec file name: train.vec
BG  file name: neg.txt, is a vecfile: no
Num pos: 2000
Num neg: 2000
Num stages: 10
Num splits: 1 (stump as weak classifier)
Mem: 2000 MB
Symmetric: TRUE
Min hit rate: 0.995000
Max false alarm rate: 0.500000
Weight trimming: 0.950000
Equal weights: FALSE
Mode: BASIC
Width: 30
Height: 32
Applied boosting algorithm: GAB
Error (valid only for Discrete and Real AdaBoost): misclass
Max number of splits in tree cascade: 0
Min number of positive samples per cluster: 500
Required leaf false alarm rate: 0.000976563

Tree Classifier
Stage
+---+
|  0|
+---+


Number of features used : 234720

Parent node: NULL

*** 1 cluster ***
OpenCV Error: Unspecified error (Vec file sample size mismatch) in icvGetHaarTra
iningDataFromVec, file C:\Downloads\Software\OpenCV-2.2.0-win\OpenCV-2.2.0\modul
es\haartraining\cvhaartraining.cpp, line 1929
terminate called after throwing an instance of 'cv::Exception'
  what():  C:\Downloads\Software\OpenCV-2.2.0-win\OpenCV-2.2.0\modules\haartrain
ing\cvhaartraining.cpp:1929: error: (-2) Vec file sample size mismatch in functi
on icvGetHaarTrainingDataFromVec


This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

C:\opencv\opencv_bin\bin>cmd |as.txt
'as.txt' is not recognized as an internal or external command,
operable program or batch file.

我正在使用一个 vec 文件,它有 1000 个从互联网下载的样本,并且有 2000 个负样本。

4

2 回答 2

0

“Vec 文件样本大小不匹配” - 尝试检查站点的样本大小。vec 文件可能不是 30x32 图像的文件(您尝试将其作为 -w 30 -h 32 传递)。

这只是一个猜测。试试看。并尝试使用 traincascade 对象。它在 $OpencvDir$/apps/traincascade/ 中。像任何其他对象一样编译它。它也可用于 LBP 和 HOG。

希望这可以帮助。

问候, Prasanna S

于 2013-06-10T05:46:04.743 回答
0

The ratio of w and h is different from the setting in info.txt. You should modify w's and h's of all images in info.txt int 30:32.

于 2019-03-15T06:29:54.907 回答