opencvのトレーニングカスケード分類器で使用されるopencv_createsamples.exeおよびopencv_traincascade.exeのパラメーターの詳細な説明



Detailed Description Parameters Opencv_createsamples



新しいターゲットを識別するために分類器をトレーニングする方法を参照してください。 ここに
キーノート:
OpenCVには、カスケード分類子をトレーニングできる2つのプログラムがあります。opencv_haartrainingとopencv_traincascadeです。 Opencv_traincascadeは、OpenCV 2.xAPIを使用してC ++で記述された新しいプログラムです。 2つの主な違いは、opencv_traincascadeがHaar [Viola2001]およびLBP [Liao2007](ローカルバイナリパターン)機能をサポートし、他の機能を簡単に追加できることです。 Haar機能と比較すると、LBP機能は整数機能であるため、トレーニングと検出のプロセスはHaar機能よりも数倍高速です。検出用のLBPおよびHaar機能の精度は、トレーニングプロセス中のトレーニングデータの品質とトレーニングパラメータに依存します。 Haar機能と同じ精度でLBPの分類器をトレーニングすることが可能です。
opencv_traincascadeとopencv_haartrainingによって出力される分類ファイルの形式は同じではありません。新しいカスケード検出インターフェース(objdetectモジュールのCascadeClassifierクラスを参照)は両方の形式をサポートしていることに注意してください。 Opencv_traincascadeは、選択したカスケード分類子を古い形式でエクスポートできます。ただし、トレーニングプロセスが中断され、トレーニングプロセスが再開された後、opencv_traincascadeとopencv_haartrainingは、中断前とは異なるファイル形式をロードできません。
opencv_traincascadeプログラムは、TBBを使用してマルチスレッドを処理します。マルチコア並列コンピューティングアクセラレーションを使用する場合は、TBBを使用してOpenCVをコンパイルします。
トレーニング関連のヘルパーもいます。
opencv_createsamplesは、トレーニング用の陽性サンプルデータとテストデータを準備するために使用されます。 Opencv_createsamplesは、opencv_haartrainingおよびopencv_traincascadeプログラムでサポートできるポジティブサンプルデータを生成できます。その出力は、画像をバイナリで保存する* .vec拡張子のファイルです。
opencv_performanceは、分類器の品質を評価するために使用できますが、opencv_haartrainingによって出力された分類器のみを評価します。ラベル付けされた画像のセットを読み込み、分類子を実行して、検出されたオブジェクトの数、失敗したチェックの数、誤検知の数、その他の情報などのパフォーマンスを報告します。
opencv_haartrainingは非推奨となるプログラムであるため、以下では紹介しませんが、主にopencv_traincascadeを紹介します。 opencv_createsamplesプログラムは、opencv_traincascadeのトレーニングサンプルを準備するために使用されるため、これも紹介されます。
opencv_createsamples.exeパラメーターの説明:
コマンドライン引数:

-vec Output file with positive samples for training. He should have a .vec file extension. -info This is the name of the file that specifies the input sample collection, including the file name and the location of the sample target in the image (for example, a .dat created by itself) File). -img This is an alternative to -info (one must be provided). With -img, you can provide a positive example of a single crop. Using -img In the mode, multiple outputs are produced, all from this one input. -bg A description file of the background image containing a series of image file names that will be randomly selected from the background of the crop body. -num The number of positive samples generated. -bgcolor Background color (currently grayscale) background color indicates transparent color. Because image compression can cause color deviation, color tolerance Can be specified by -bgthresh. All pixels between bgcolor-bgthresh and bgcolor+bgthresh are set to Transparent pixels. -bgthresh -inv If this flag is specified, the color of the foreground image will be reversed. -randinv If this flag is specified, the color will be flipped randomly. -maxidev The maximum value of the brightness gradient of the pixels in the foreground sample. -maxxangle The maximum rotation angle of the X axis must be in radians. -maxyangle The maximum rotation angle of the Y axis must be in radians. -maxzangle The maximum rotation angle of the Z axis must be in radians. -show Very useful debugging options. If this option is specified, each sample will be displayed. If you press the Esc key, the program will continue to create samples. This is no longer displayed. -w The width of the output sample, in pixels. -h The height of the output sample, in pixels.

Opencv_createsamplesを使用して、vecポジティブサンプルファイルに保存されているポジティブサンプルを表示および確認することもできます。この場合、-vec、-w、および-hパラメーターを指定するだけで済みます。 Opencv_createsamplesは、ポジティブサンプル画像を1つずつ表示します。
vecファイルの例は、opencv / data / vec_files /trainingfaces_24-24.vecにあります。これは、ウィンドウサイズが-w 24 -h24の顔分類器をトレーニングするために使用できます。



opencv_traincascade.exeパラメーターの説明:
以下は、opencv_traincascadeへのコマンドライン引数であり、目的ごとにグループ化されています。

General parameters: -data The directory name, if it does not exist, will create it to store the trained classifier. -vec The name of the vec file containing the positive sample (generated by the opencv_createsamples program). -bg The background description file, that is, the description file containing the negative sample file name. -numPos The number of positive samples used for each level of classifier training is typically less than the number of examples provided. -numNeg The number of negative samples used for each level of classifier training can be greater than the number of pictures specified by -bg. -numStages The number of stages of the trained classifier. -precalcValBufSize The cache size is used to store pre-computed feature values ​​in megabytes. -precalcIdxBufSize The cache size is used to store pre-computed feature indices in megabytes. The larger the memory, the shorter the training time. -baseFormatSave This parameter is only valid when using Haar features. If this parameter is specified, the cascade classifier will be stored in the old format. Cascading parameters: -stageType Stage parameters. Currently only the BOOST classifier is supported as a level type. -featureType Type of feature: HAAR - Haar-like feature LBP - Local texture mode feature. -w -h The size of the training sample (in pixels). Must be created with training samples (created using the opencv_createsamples program) The dimensions are the same. Boosted classifier parameters: -bt Type of Boosted classifier: DAB - Discrete AdaBoost, RAB - Real AdaBoost, LB - LogitBoost, GAB - Gentle AdaBoost。 -minHitRate The minimum detection rate that each level of the classifier expects. The total detection rate is approximately min_hit_rate^number_of_stages. The default value of 0.995 corresponds to 99.5%. -maxFalseAlarmRate The maximum false positive rate that each level of the classifier expects. The total false positive rate is approximately max_false_alarm_rate^number_of_stages. The default value of 0.50 corresponds to 50%. -weightTrimRate A good value is 0.95. -maxDepth The maximum depth of the weak classifier tree. Note that this is not the depth of the cascader. A good value is 1, which is a binary tree (stumps). -maxWeakCount The maximum number of weak classifiers in each level. Similar to -maxDepth, the parameter -maxWeakCount is passed directly to the cascade classification Boosting, while setting the maximum of the weak cascade that can be used to form each strong classifier (ie, each stage of the classifier) Quantity. The default value for this parameter is 100, but this does not mean that the weak classifier will definitely use this number. Class Haar feature parameters: -mode The parameter -mode is used with the class Haar feature to select the type of Haar feature used in the training process. BASIC only uses the top right Features, ALL uses all top right features and 45 degree rotation features. LBP characteristic parameters: The LBP feature has no parameters.

opencv_traincascadeプログラムのトレーニングが終了すると、トレーニングされたカスケード分類子は、-dataで指定されたディレクトリにあるcascade.xmlファイルに保存されます。このディレクトリ内の他のファイルは、トレーニングの中間結果です。トレーニングプログラムが中断された場合、トレーニングプログラムを再実行すると、最初から再トレーニングすることなく、以前のトレーニング結果が読み取られます。トレーニングが終了したら、これらの中間ファイルを削除できます。



これら2つのプログラムを使用しているときに問題が発生した場合は、いくつかの問題と解決策を参照してください。 ここに

この記事の複製先: カスケード分類器トレーニング