opencv createsamples没有错误,但没有找到样本 [英] opencv createsamples has no error, but no samples found

查看:2243
本文介绍了opencv createsamples没有错误,但没有找到样本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这个教程,我正处于从我的正面图像创建大量样本的阶段。

 这是命令:

perl bin / createsamples.pl positives.txt negatives.txt示例1500 \C:\opencv_built\bin\Release\opencv_createsamples.exe -bgcolor 0 -bgthresh 0 -maxxangle 1.1 \ -maxyangle 1.1 maxzangle 0.5 - maxidev 40 -w 80 -h 40

这是我得到的输出,正图片:

  C:\opencv_built\bin\Release\opencv_createsamples.exe -bgcolor 0 -bgthresh 0 -max 
xangle 1.1 \ -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 40 -img 60inclin
ation_315azimuth.jpg -bg tmp -vec samples0inclination_315azimuth.jpg.vec -num 62

信息文件名:(NULL)
映像文件名:60inclination_315azimuth.jpg
Vec文件名:samples0inclination_315azimuth.jpg.vec
BG文件名:tmp
:62
BG颜色:0
BG阈值:0
反转:FALSE
最大强度偏差:40
最大x角度:1.1
最大y角度:1.1
最大z角度:0.5
显示样品:FALSE
宽度:80
高度:40
从单幅图像应用扭曲创建训练样本...
Done

这些消息似乎成功了,所以我进入了samples文件夹,期望看到1500个样本,没有什么!我注意到信息文件是< NULL> ,这与这有什么关系吗?似乎没有任何错误,出了什么问题?



编辑



命令包含一切的绝对路径,例如

  perl bin / createsamples.pl C:\my_work\code\opencv -haar-classifier-training-master\positive_images \ C:\my_work\code\opencv-haar-classifier-training-master\positive_images \ samples 1500 \C:\opencv_built\bin \Release\opencv_createsamples.exe -bgcolor 0 -bgthresh 0 -maxxangle 1.1 \ -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 40

但仍然没有运气!

解决方案

我会尽量解释一下我做了什么,希望它会解决你的问题。



首先NULL后的-info是正常的。正如在OpenCV的opencv_createcamples的官方文档中所说,你需要输入一个图像(-img)或一个图像集合(-info),我会让你阅读文档以便进一步理解,但在这个例子中,你不需要需要它。



其次,你不需要在这个命令中放置绝对路径;这里是我的命令:

  perl bin / createsamples.pl positives.txt negatives.txt samples 1500opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 -maxzangle 0.5 -maxidev 40 -w 42 -h 40

这样做一定要在您下载的gitHub目录的根目录(父的一个bin)确保你的positives.txt和负面。 txt在此目录中。还复制粘贴opencv_createsamples.exe从OpenCV目录在这一个。



这样做我现在解释的主要问题:项目是开发Ubuntu的开始,它适用于mac轻松,但我认为你必须在Windows下。如果你还没有下载Cygwin,因为它主要使用Linux命令。



正如我所说的,我被一个类似的问题阻止,所以我试图直接使用opencv_createsample的perl脚本,看看问题是否来自那里和我注意到,问题是来自这样的事实,我的positives.txt和negatives.txt是在Windows格式,而不是Unix所以Perl脚本不是能够正确读取



Windows和linux之间的区别很大,Cygwin不能弥补这个差距,因此可能会出现其他编码问题。



我刚刚在我的电脑上安装了一个Ubuntu vm。

这是一个非常简单的方法来解决这个问题,

使用TBB安装Opencv(很多教程的互联网,最好的是来自 OpenCV网站)。



我下载了gitHub 分类器培训,然后我按照给出的命令运行良好。


I'm using this tutorial, and I'm on the stage of creating lots of samples from my positive images. I'm using Windows.

This is the command:

perl bin/createsamples.pl positives.txt negatives.txt samples 1500\  "C:\opencv_built\bin\Release\opencv_createsamples.exe -bgcolor 0 -bgthresh 0 -maxxangle 1.1\   -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 40"

And this is what I get as output, for each of the positive images:

C:\opencv_built\bin\Release\opencv_createsamples.exe -bgcolor 0 -bgthresh 0 -max
xangle 1.1\   -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 40 -img 60inclin
ation_315azimuth.jpg -bg tmp -vec samples0inclination_315azimuth.jpg.vec -num 62

Info file name: (NULL)
Img file name: 60inclination_315azimuth.jpg
Vec file name: samples0inclination_315azimuth.jpg.vec
BG  file name: tmp
Num: 62
BG color: 0
BG threshold: 0
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: 80
Height: 40
Create training samples from single image applying distortions...
Done

The messages seemed successful so I went into the samples folder expecting to see 1500 samples, but there's nothing there! I noticed the info file is <NULL>, does that have anything to do with this? There doesn't seem to be any error, what went wrong?

Edit

I've changed the command to include absolute paths for everything, eg

perl bin/createsamples.pl C:\my_work\code\opencv-haar-classifier-training-master\positive_images\ C:\my_work\code\opencv-haar-classifier-training-master\positive_images\ samples 1500\  "C:\opencv_built\bin\Release\opencv_createsamples.exe -bgcolor 0 -bgthresh 0 -maxxangle 1.1\   -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 40"

But still no luck!

解决方案

I had a similar problem I'll try to explain what I did, I hope it will solve you problem.

First of all the NULL after -info is normal. As said in the official documentation of OpenCV for opencv_createcamples you need to either input an image (-img) or a collection of images (-info) I'll let you read the documentation for further understanding, but for this example you don't need it.

Secondly you don't need to put absolute paths in this command; here is my command:

perl bin/createsamples.pl  positives.txt negatives.txt samples 1500 "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 -maxzangle 0.5 -maxidev 40 -w 42 -h 40"

to do this be sure to be at the root of the gitHub directory you have download (the parent one of bin) be sure that your positives.txt and negatives. txt are in this directory. Also copy paste the opencv_createsamples.exe from OpenCV directory in this one.

This done I'll now explain the main problems: The project was developped for Ubuntu at the beginning so it works for mac easily but I think you must be under Windows. If you hadn't already please download Cygwin because it uses mainly Linux commands.

As I said I was blocked with a similar problem, so I tried to use opencv_createsample directly instead of the perl script to see if the problem was coming from there and I noticed that the problem was coming from the fact that my positives.txt and negatives.txt were under Windows format and not Unix so the Perl script wasn't able to read them properly.

The difference between windows and linux are big and Cygwin doesn't bridge the gap so there might be other encoding problems. So what I did is surely not the fastest way to resolve the problem, but it is an easy one.

I just installed an Ubuntu vm on my PC

Installed Opencv with TBB ( a lot of tutorials internet, the best is the one from the OpenCV site).

I Downloaded the gitHub Classifier training and then I followed the commands given and it worked well.

这篇关于opencv createsamples没有错误,但没有找到样本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆