当前位置:网站首页>【级联分类器训练参数】Training Haar Cascades
【级联分类器训练参数】Training Haar Cascades
2022-07-01 19:24:00 【十年一梦实验室】
Training Haar Cascades
opencv_traincascade -data outputDirectory \
-vec cropped.vec \
-bg negativeImageDirectory/negatives.txt \
-numPos 1000 -numNeg 600 -numStages 20 \
-precalcValBufSize 1024 -precalcIdxBufSize 1024 \
-featureType HAAR \
-minHitRate 0.995 -maxFalseAlarmRate 0.5 \
-w 48 -h 48
opencv_traincascade -data D:\blocks2\classifier \
-vec D:\blocks2\pos_samples.vec \
-bg D:\blocks2\neg.lst \
-numPos 868 -numNeg 8748 -numStages 20 \
-precalcValBufSize 2048 -precalcIdxBufSize 2048 \
-featureType HAAR \
-minHitRate 0.995 -maxFalseAlarmRate 0.5 \
-w 48 -h 48 -mode ALL
命令行参数:
-vec <vec_file_name> :包含用于训练的正样本的输出文件的名称。
-img <image_file_name> :源对象图像(例如,公司徽标)。
-bg <background_file_name> :背景描述文件;包含图像列表,这些图像用作对象随机扭曲版本的背景。
-num <number_of_samples> :要生成的正样本数。
-bgcolor <background_color> :背景颜色(当前假定为灰度图像);背景色表示透明色。由于可能存在压缩伪影,因此可以通过
-bgthresh 指定颜色容差量。 bgcolor-bgthresh 和 bgcolor bgthresh 范围内的所有像素都被解释为透明的。
-bgthresh <background_color_threshold>
-inv :如果指定,颜色将被反转。
-randinv :如果指定,颜色将随机反转。
-maxidev <max_intensity_deviation> :前景样本中像素的最大强度偏差。
-maxxangle <max_x_rotation_angle> :朝向 x 轴的最大旋转角度,必须以弧度表示。
-maxyangle <max_y_rotation_angle> :朝向 y 轴的最大旋转角度,必须以弧度表示。
-maxzangle <max_z_rotation_angle> :朝向 z 轴的最大旋转角度,必须以弧度为单位。
-show :有用的调试选项。如果指定,将显示每个样本。按 Esc 将继续样本创建过程,而不显示每个样本。
-w <sample_width> :输出样本的宽度(以像素为单位)。
-h <sample_height> :输出样本的高度(以像素为单位)。
opencv_traincascade.exe -data ./cascade/ooo/ -vec ./vec/ooo.vec -bg ./neg/nglist.txt -numPos 40 -numNeg 20
https://manpages.ubuntu.com/manpages/bionic/man1/opencv_traincascade.1.html
NAME
opencv_traincascade - transcascade application
SYNOPSIS
opencv_traincascade [options]
DESCRIPTION
traincascade application.
OPTIONS
opencv_traincascade supports the following options:
BASIC OPTIONS
-data cascade_dir_name
-vec vec_file_name
-bg background_file_name
-numPos number_of_positive_samples
The default is 2000.
-numNeg number_of_negative_samples
The default is 1000.
-num Stagesnumber_of_stages
The default is 20.
-precalcValBufSize precalculated_vals_buffer_size_in_Mb
The default is 256.
-precalcIdxBufSize precalculated_idxs_buffer_size_in_Mb
The default is 256.
-baseFormatSave
CASCADE OPTIONS
-stageType
The default is BOOST.
-featureType
Set feature type . You can select HAAR or LBP. The default is HAAR.
-w sampleWidth
The default is 24.
-h sampleHeight
The default is 24.
BOOST OPTIONS
-bt {DAB|RAB|LB|GAB}
The type of the applied boosting algorithm. You can choose between Discrete
AdaBoost (DAB), Real AdaBoost (RAB), LogitBoost (LB) and Gentle AdaBoost (GAB). The
default is GAB.
-minHitRate min_hit_rate
The default is 0.995.
-maxFalseAlarmRate max_false_alarm_rate
The default is 0.5.
-weightTrimRate weight_trim_rate
The default is 0.95.
-maxDepth max_depth_of_weak_tree
The default is 1.
-maxWeakCount max_weak_tree_count
The default is 100.
HAARFEATURE OPTIONS
-mode <BASIC|CORE|ALL>
The type of the applied haarFeature mode. You can choose between BASIC, ORE and
ALL. The default is BASIC.
EXAMPLES
TODO
SEE ALSO
opencv_haartraing(1), opencv_performance(1)
More information and examples can be found in the OpenCV documentation.
AUTHORS
This manual page was written by Nobuhiro Iwamatsu <[email protected]> for the Debian
project (but may be used by others).
Command line arguments:
-vec <vec_file_name> : Name of the output file containing the positive samples for training.
-img <image_file_name> : Source object image (e.g., a company logo).
-bg <background_file_name> : Background description file; contains a list of images which are used as a background for randomly distorted versions of the object.
-num <number_of_samples> : Number of positive samples to generate.
-bgcolor <background_color> : Background color (currently grayscale images are assumed); the background color denotes the transparent color. Since there might be compression artifacts, the amount of color tolerance can be specified by -bgthresh. All pixels within bgcolor-bgthresh and bgcolor+bgthresh range are interpreted as transparent.
-bgthresh <background_color_threshold>
-inv : If specified, colors will be inverted.
-randinv : If specified, colors will be inverted randomly.
-maxidev <max_intensity_deviation> : Maximal intensity deviation of pixels in foreground samples.
-maxxangle <max_x_rotation_angle> : Maximal rotation angle towards x-axis, must be given in radians.
-maxyangle <max_y_rotation_angle> : Maximal rotation angle towards y-axis, must be given in radians.
-maxzangle <max_z_rotation_angle> : Maximal rotation angle towards z-axis, must be given in radians.
-show : Useful debugging option. If specified, each sample will be shown. Pressing Esc will continue the samples creation process without showing each sample.
-w <sample_width> : Width (in pixels) of the output samples.
-h <sample_height> : Height (in pixels) of the output samples.
Cascade Training
The next step is the actual training of the boosted cascade of weak classifiers, based on the positive and negative dataset that was prepared beforehand.
Command line arguments of opencv_traincascade application grouped by purposes:
Common arguments:
-data <cascade_dir_name> : Where the trained classifier should be stored. This folder should be created manually beforehand.
-vec <vec_file_name> : vec-file with positive samples (created by opencv_createsamples utility).
-bg <background_file_name> : Background description file. This is the file containing the negative sample images.
-numPos <number_of_positive_samples> : Number of positive samples used in training for every classifier stage.
-numNeg <number_of_negative_samples> : Number of negative samples used in training for every classifier stage.
-numStages <number_of_stages> : Number of cascade stages to be trained.
-precalcValBufSize <precalculated_vals_buffer_size_in_Mb> : Size of buffer for precalculated feature values (in Mb). The more memory you assign the faster the training process, however keep in mind that -precalcValBufSize and -precalcIdxBufSize combined should not exceed you available system memory.
-precalcIdxBufSize <precalculated_idxs_buffer_size_in_Mb> : Size of buffer for precalculated feature indices (in Mb). The more memory you assign the faster the training process, however keep in mind that -precalcValBufSize and -precalcIdxBufSize combined should not exceed you available system memory.
-baseFormatSave : This argument is actual in case of Haar-like features. If it is specified, the cascade will be saved in the old format. This is only available for backwards compatibility reasons and to allow users stuck to the old deprecated interface, to at least train models using the newer interface.
-numThreads <max_number_of_threads> : Maximum number of threads to use during training. Notice that the actual number of used threads may be lower, depending on your machine and compilation options. By default, the maximum available threads are selected if you built OpenCV with TBB support, which is needed for this optimization.
-acceptanceRatioBreakValue <break_value> : This argument is used to determine how precise your model should keep learning and when to stop. A good guideline is to train not further than 10e-5, to ensure the model does not overtrain on your training data. By default this value is set to -1 to disable this feature.
Cascade parameters:
-stageType <BOOST(default)> : Type of stages. Only boosted classifiers are supported as a stage type at the moment.
-featureType<{HAAR(default), LBP}> : Type of features: HAAR - Haar-like features, LBP - local binary patterns.
-w <sampleWidth> : Width of training samples (in pixels). Must have exactly the same value as used during training samples creation (opencv_createsamples utility).
-h <sampleHeight> : Height of training samples (in pixels). Must have exactly the same value as used during training samples creation (opencv_createsamples utility).
Boosted classifier parameters:
-bt <{DAB, RAB, LB, GAB(default)}> : Type of boosted classifiers: DAB - Discrete AdaBoost, RAB - Real AdaBoost, LB - LogitBoost, GAB - Gentle AdaBoost.
-minHitRate <min_hit_rate> : Minimal desired hit rate for each stage of the classifier. Overall hit rate may be estimated as (min_hit_rate ^ number_of_stages), [226] §4.1.
-maxFalseAlarmRate <max_false_alarm_rate> : Maximal desired false alarm rate for each stage of the classifier. Overall false alarm rate may be estimated as (max_false_alarm_rate ^ number_of_stages), [226] §4.1.
-weightTrimRate <weight_trim_rate> : Specifies whether trimming should be used and its weight. A decent choice is 0.95.
-maxDepth <max_depth_of_weak_tree> : Maximal depth of a weak tree. A decent choice is 1, that is case of stumps.
-maxWeakCount <max_weak_tree_count> : Maximal count of weak trees for every cascade stage. The boosted classifier (stage) will have so many weak trees (<=maxWeakCount), as needed to achieve the given -maxFalseAlarmRate.
Haar-like feature parameters:
-mode <BASIC (default) | CORE | ALL> : Selects the type of Haar features set used in training. BASIC use only upright features, while ALL uses the full set of upright and 45 degree rotated feature set. See [134] for more details.
Local Binary Patterns parameters: Local Binary Patterns don't have parameters.
Visualising Cascade Classifiers
From time to time it can be useful to visualise the trained cascade, to see which features it selected and how complex its stages are. For this OpenCV supplies a opencv_visualisation application. This application has the following commands:
--image (required) : path to a reference image for your object model. This should be an annotation with dimensions [-w,-h] as passed to both opencv_createsamples and opencv_traincascade application.
--model (required) : path to the trained model, which should be in the folder supplied to the -data parameter of the opencv_traincascade application.
--data (optional) : if a data folder is supplied, which has to be manually created beforehand, stage output and a video of the features will be stored.
An example command can be seen below
opencv_visualisation --image=/data/object.png --model=/data/model.xml --data=/data/result/
边栏推荐
- Niuke programming question -- must brush the string of 101 (brush the question efficiently, draw inferences from one instance)
- 网上开户是安全的吗?新手可以开炒股账户吗。
- leetcode刷题:二叉树03(二叉树的后序遍历)
- 天气预报小程序源码 天气类微信小程序源码
- 联想电脑怎么连接蓝牙耳机?
- leetcode刷题:栈与队列06(前 K 个高频元素)
- Iframe 父子页面通信
- Powerful, easy-to-use, professional editor / notebook software suitable for programmers / software developers, comprehensive evaluation and comprehensive recommendation
- Keras机器翻译实战
- How to create a pyramid with openmesh
猜你喜欢

Data analysts sound tall? Understand these points before you decide whether to transform

深度学习 常见的损失函数

大厂做狼,小厂做狗?

极客DIY开源方案分享——数字幅频均衡功率放大器设计(实用的嵌入式电子设计作品软硬件综合实践)

强大的万年历微信小程序源码-支持多做流量主模式

Detailed explanation and code example of affinity propagation clustering calculation formula based on graph

漏洞复现-.Net-ueditor上传

Importance of EDA tools to chip industry knowledge popularization

Powerful, easy-to-use, professional editor / notebook software suitable for programmers / software developers, comprehensive evaluation and comprehensive recommendation

Vulnerability recurrence - Net ueeditor upload
随机推荐
How to turn off the boot auto start software in win11
latex如何打空格
C # joint halcon Application - Dahua Camera Collection class
【let var const】
Develop those things: easycvr cluster device management page function display optimization
Swiftui 4 new features complete toggle and mixed toggle multiple binding components
如果浏览器被意外关闭,react怎么缓存用户填写的表单?
Is it safe to open an account online? Can a novice open a stock trading account.
Set object value changes null value object
Architect graduation summary
Internship: gradually moving towards project development
math_ Use differentiation to calculate approximate value
leetcode刷题:栈与队列05(逆波兰表达式求值)
Écrire un document de blog
RichView TRVDocParameters 页面参数设置
How to prevent repeated submission of new orders
三菱PLC FX3U脉冲轴点动功能块(MC_Jog)
3D panoramic model display visualization technology demonstration
C # joint Halcon application - Dahua camera acquisition class