首页 > 其他分享 >OpenCV自带dnn的Example研究(1)— classification

OpenCV自带dnn的Example研究(1)— classification

时间:2022-12-25 12:03:12浏览次数:62  
标签:classification -- dnn googlenet OpenCV classes template

​https://docs.opencv.org/master/examples.html​​下的



OpenCV自带dnn的Example研究(1)— classification_参数配置


6个文件,看看在最新的OpenCV中,它们是如何发挥作用的。


在配置使用的过程中,需要注意使用较高版本的VS避免编译器兼容问题;由于DNN程序的运行依赖于训练成功的模型,因此需要预先下载准备;此外如果出现各种报错,需要对症下药。


此外,由于需要使用common.hpp文件,所以需要引入dnn目录到include中



OpenCV自带dnn的Example研究(1)— classification_参数配置_02


用到的数据集都放在:


链接:https://pan.baidu.com/s/1WPoXU3VodErPHZo6Yc21xA 


提取码:01no 


如果你没找到,那一定是我忘了。


=====================================================================================友善的分割线============================


注意,这个例子是有官方文档的


​https://docs.opencv.org/master/d5/de7/tutorial_dnn_googlenet.html​



它推荐的调用的模式为:


​​/example_dnn_classification      --model     =bvlc_googlenet.caffemodel 
--config
=bvlc_googlenet.prototxt
--width
=
224
--height
=
224
--classes
=classification_classes_ILSVRC2012.txt
--input
=space_shuttle.jpg
--mean
=
"104 117 123"​​



从参数中,我们可以看出,这里的模型为caffemodel,模型的参数配置为prototxt,而 classification_classes_ILSVRC2012.txt应该是和训练类型相关的,它长这样:



OpenCV自带dnn的Example研究(1)— classification_html_03



按照文档中说明,打开参数配置



OpenCV自带dnn的Example研究(1)— classification_html_04


在当前项目属性页->调试->命令参数下面:


​​--model     =e     :     /     template
/bvlc_googlenet.caffemodel
--config
=e
:
/
template
/bvlc_googlenet.prototxt
--width
=
224
--height
=
224
--classes
=e
:
/
template
/classification_classes_ILSVRC2012.txt
--input
=E
:
/
template
/dogvscat1K
/cat.
1.jpg
--mean
=
"104 117 123"
--rgb
​​



识别的结果,肯定是没有问题的。我没看看tabby cat这个来自哪里?


OpenCV自带dnn的Example研究(1)— classification_参数配置_05

就来自上面的分类文件。



OpenCV自带dnn的Example研究(1)— classification_参数配置_06



OpenCV自带dnn的Example研究(1)— classification_html_07



OpenCV自带dnn的Example研究(1)— classification_分割线_08


肯定是有正确的也会有失败的。我相信随着模型的不断完善,特别是对特定领域内数据的专门训练,肯定在判断的结果上能够有提升的方法。


仅仅凭借几张照片还看不出结果,必须依据科学的方法来做。

代码中


mean subtraction ​​(-104, -117, -123)​​ for each blue, green and red channels 


这句可能和项目本身是有关系的,这里先不做追究。
 

标签:classification,--,dnn,googlenet,OpenCV,classes,template
From: https://blog.51cto.com/jsxyhelu2017/5968072

相关文章