YOLOP-opencv-dnn
YOLOP-opencv-dnn copied to clipboard
摄像头//视频
你好,请问如果想将此项目用在摄像头上或者视频中,我应该怎么修改代码呢,谢谢!
@SnailDUDUDU 做以下修改即可: if name == "main": parser = argparse.ArgumentParser() parser.add_argument('--confThreshold', default=0.25, type=float, help='class confidence') parser.add_argument('--nmsThreshold', default=0.45, type=float, help='nms iou thresh') parser.add_argument('--objThreshold', default=0.5, type=float, help='object confidence') args = parser.parse_args()
# yolonet = yolop(confThreshold=args.confThreshold, nmsThreshold=args.nmsThreshold, objThreshold=args.objThreshold)
# srcimg = cv2.imread(args.imgpath)
# outimg = yolonet.detect(srcimg)
#
# winName = 'Deep learning object detection in OpenCV'
# cv2.namedWindow(winName, 0)
# cv2.imshow(winName, outimg)
# cv2.waitKey(0)
# cv2.destroyAllWindows()
yolonet = yolop(confThreshold=args.confThreshold, nmsThreshold=args.nmsThreshold, objThreshold=args.objThreshold)
input_video = cv2.VideoCapture("你的视频文件或摄像头号")
while cv2.waitKey(1) < 0:
grabbed, srcimg = input_video.read()
if not grabbed:
break
print('get images!')
outimg = yolonet.detect(srcimg)
winName = 'Deep learning object detection in OpenCV'
cv2.namedWindow(winName, 0)
cv2.imshow(winName, outimg)
cv2.destroyAllWindows()