@@ -102,17 +102,20 @@ def detect(self, srcimg):
102
102
103
103
if __name__ == "__main__" :
104
104
parser = argparse .ArgumentParser ()
105
- parser .add_argument ("--imgpath" , type = str , default = 'bus.jpg' , help = "image path" )
105
+ parser .add_argument ("--imgpath" , type = str , default = '/home/wangbo/Desktop/data/yolo/yolov34-cpp-opencv-dnn-master/ bus.jpg' , help = "image path" )
106
106
parser .add_argument ('--net_type' , default = 'yolov5s' , choices = ['yolov5s' , 'yolov5l' , 'yolov5m' , 'yolov5x' ])
107
+ parser .add_argument ('--confThreshold' , default = 0.5 , type = float , help = 'class confidence' )
108
+ parser .add_argument ('--nmsThreshold' , default = 0.5 , type = float , help = 'nms iou thresh' )
109
+ parser .add_argument ('--objThreshold' , default = 0.5 , type = float , help = 'object confidence' )
107
110
args = parser .parse_args ()
108
111
109
- yolonet = yolov5 (args .net_type )
112
+ yolonet = yolov5 (args .net_type , confThreshold = args . confThreshold , nmsThreshold = args . nmsThreshold , objThreshold = args . objThreshold )
110
113
srcimg = cv2 .imread (args .imgpath )
111
114
dets = yolonet .detect (srcimg )
112
115
srcimg = yolonet .postprocess (srcimg , dets )
113
116
114
117
winName = 'Deep learning object detection in OpenCV'
115
- cv2 .namedWindow (winName , 0 )
118
+ cv2 .namedWindow (winName , cv2 . WINDOW_NORMAL )
116
119
cv2 .imshow (winName , srcimg )
117
120
cv2 .waitKey (0 )
118
121
cv2 .destroyAllWindows ()
0 commit comments