背景
我在尝试训练自己的级联检测器,当在windows上写好的txt文件传到ubuntu时由于编码问题出现了如下报错,经过一番网上冲浪,在一个other国家的网站上发现了一个人写的解决方案。
就是这个网站
报错
root@iZ2zef0icee95uw35ttpgmZ:~/test_workspace# opencv_createsamples -img watch.jpg -bg bg.txt -info info/info.lst -pngoutput info -maxxangle 0.5 -maxyangle 0.5 -maxzangle 0.5 -num 500
Info file name: info/info.lst
Img file name: watch.jpg
Vec file name: (NULL)
BG file name: bg.txt
Num: 500
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 40
Max x angle: 0.5
Max y angle: 0.5
Max z angle: 0.5
Show samples: FALSE
Width: 24
Height: 24
Max Scale: -1
Create test samples from single image applying distortions...
Open background image: neg/01.jpg
-------略
Invalid background description file.
Segmentation fault
解决
粘一下我的代码:
root@iZ2zef0icee95uw35ttpgmZ:~/test_workspace# file bg.txt
bg.txt: ASCII text, with CRLF line terminators
root@iZ2zef0icee95uw35ttpgmZ:~/test_workspace# sudo apt install dos2unix
Reading package lists... Done
--------安装信息省略--------
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
root@iZ2zef0icee95uw35ttpgmZ:~/test_workspace# dos2unix bg.txt
dos2unix: converting file bg.txt to Unix format...
root@iZ2zef0icee95uw35ttpgmZ:~/test_workspace# file bg.txt
bg.txt: ASCII text
root@iZ2zef0icee95uw35ttpgmZ:~/test_workspace# opencv_createsamples -img watch.jpg -bg bg.txt -info info/info.lst -pngoutput info -maxxangle 0.5 -maxyangle 0.5 -maxzangle 0.5 -num 2000
Info file name: info/info.lst
Img file name: watch.jpg
Vec file name: (NULL)
BG file name: bg.txt
Num: 2000
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 40
Max x angle: 0.5
Max y angle: 0.5
Max z angle: 0.5
Show samples: FALSE
Width: 24
Height: 24
Max Scale: -1
Create test samples from single image applying distortions...
Open background image: neg/01.jpg
----------
Done