hpc203 / YOLOP-opencv-dnn

使用OpenCV部署全景驾驶感知网络YOLOP,可同时处理交通目标检测、可驾驶区域分割、车道线检测,三项视觉感知任务,包含C++和Python两种版本的程序实现。本套程序只依赖opencv库就可以运行, 从而彻底摆脱对任何深度学习框架的依赖。

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

摄像头//视频

SnailDUDUDU opened this issue · comments

你好,请问如果想将此项目用在摄像头上或者视频中,我应该怎么修改代码呢,谢谢!

@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()