我正在尝试使用dlib机器学习库进行对象检测。
虽然我按照说明操作,一切看似正常,但我无法在原始图像上检测到我的对象。即使我在纯黑图像上测试,它也会检测到一个对象,这是不应该发生的。此外,如果我将一张训练过的图像粘贴到黑色的图像上,它会检测到很多对象,这同样不应该发生。
我没有修改train_object_detector.cpp文件,它是原始的。
这是我的样本图像
我使用imglab创建了XML文件。
<?xml version='1.0' encoding='ISO-8859-1'?><?xml-stylesheet type='text/xsl' href='image_metadata_stylesheet.xsl'?><dataset><name>imglab dataset</name><comment>Created by imglab tool.</comment><images> <image file='totaldata/1.jpg'> <box top='0' left='1' width='61' height='64'/> </image> <image file='totaldata/2.jpg'> <box top='0' left='1' width='63' height='65'> <label>1</label> </box> </image> <image file='totaldata/3.jpg'> <box top='1' left='0' width='61' height='61'> <label>1</label> </box> </image> <image file='totaldata/4.jpg'> <box top='0' left='0' width='59' height='63'> <label>1</label> </box> </image> <image file='totaldata/5.jpg'> <box top='2' left='1' width='59' height='60'> <label>1</label> </box> </image> <image file='totaldata/6.jpg'> <box top='0' left='2' width='60' height='62'> <label>1</label> </box> </image></images></dataset>
纯黑图像检测的截图
纯黑图像和一张训练图像检测的截图。
以防万一,这是cpp文件的链接。
http://dlib.net/train_object_detector.cpp.html
提前感谢您。
回答:
您不应该裁剪训练图像。您需要提供与测试时使用的图像相似的训练图像。
在这种情况下,图像窗口的特征向量的一部分是从图像外部区域提取的(因为您的对象被裁剪得非常紧),并且由于图像外部被假定为黑色,它学会了您的对象总是被黑色像素包围。