Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

摄像头//视频 #5

Open
SnailDUDUDU opened this issue Dec 9, 2021 · 1 comment
Open

摄像头//视频 #5

SnailDUDUDU opened this issue Dec 9, 2021 · 1 comment

Comments

@SnailDUDUDU
Copy link

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

@stevephone
Copy link

stevephone commented Mar 4, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants