File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 7272 size = (int (capture .get (cv2 .CAP_PROP_FRAME_WIDTH )), int (capture .get (cv2 .CAP_PROP_FRAME_HEIGHT )))
7373 out = cv2 .VideoWriter (video_save_path , fourcc , video_fps , size )
7474
75+ ref , frame = capture .read ()
76+ if not ref :
77+ raise ValueError ("未能正确读取摄像头(视频),请注意是否正确安装摄像头(是否正确填写视频路径)。" )
78+
7579 fps = 0.0
7680 while (True ):
7781 t1 = time .time ()
7882 # 读取某一帧
79- ref ,frame = capture .read ()
83+ ref , frame = capture .read ()
84+ if not ref :
85+ break
8086 # 格式转变,BGRtoRGB
8187 frame = cv2 .cvtColor (frame ,cv2 .COLOR_BGR2RGB )
8288 # 转变成Image
98104 if c == 27 :
99105 capture .release ()
100106 break
107+
108+ print ("Video Detection Done!" )
101109 capture .release ()
102- out .release ()
110+ if video_save_path != "" :
111+ print ("Save processed video to the path :" + video_save_path )
112+ out .release ()
103113 cv2 .destroyAllWindows ()
104114
105115 elif mode == "fps" :
You can’t perform that action at this time.
0 commit comments