【问题标题】:OpenCV training to detect static imageOpenCV训练检测静态图像
【发布时间】:2014-04-29 19:45:44
【问题描述】:

我想检测我的国家的国旗。但是我在训练方面遇到了麻烦。我有 1 个正样本和 4 个负样本。这是我的文件夹结构:

/negative
   /img
      img1.jpg
      img2.jpg
      img3.jpg
      img4.jpg

/positive
     flag.jpg

这就是我调用 create_samples 的方式:

opencv_createsamples -img positive/flag.jpg -vec flag.vec

但是命令没有完成并且出现弹出窗口说出现了错误。这是 create_samples 命令的输出:

Info file name: (NULL)
Img file name: positive/flag.jpg
Vec file name: flag.vec
BG  file name: (NULL)
Num: 1000
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 40
Max x angle: 1.1
Max y angle: 1.1
Max z angle: 0.5
Show samples: FALSE
Width: 24
Height: 24
Create training samples from single image applying distortions...

任何人都可以指导我完成 OpenCV 中静态图像(1 个图像)的 haar 训练过程吗?我正在运行 Windows 7 Ultimate x64

编辑

这行得通:

opencv_createsamples -img positive/flag.jpg -vec flag.vec -num 0

我猜问题出在 -num 0 参数

【问题讨论】:

  • 你试过 -num 1 参数吗?也尝试提供 -w 和 -h 参数...

标签: opencv


【解决方案1】:

Haar 不是检测国家国旗的最佳选择,最好使用颜色检测

COLOR_MIN = np.array([20, 80, 80],np.uint8)

COLOR_MAX = np.array([40, 255, 255],np.uint8)
但如果你还是坚持哈尔

创建样本:

$ <opencv_createsamples> -vec <binary_description> -image <positive_image> -bg <negative_description>    

训练级联:

$ <opencv_traincascade> -data <cascade> -vec <binary_description> -bg     <negative_description>    

【讨论】:

    猜你喜欢
    • 2011-05-06
    • 1970-01-01
    • 1970-01-01
    • 2018-06-14
    • 2016-03-29
    • 2019-09-14
    • 2019-09-18
    • 2014-01-22
    • 1970-01-01
    相关资源
    最近更新 更多