vid port check
Former-commit-id: b095021827709c4c9ba94f83db11e27d2f43f5b2
This commit is contained in:
18
vid_chk.py
Normal file
18
vid_chk.py
Normal file
@ -0,0 +1,18 @@
|
||||
import cv2
|
||||
|
||||
flag = False
|
||||
vidId = 1
|
||||
cap = cv2.VideoCapture(vidId, cv2.CAP_DSHOW)
|
||||
while not flag:
|
||||
suc,im = cap.read()
|
||||
cv2.imshow("image",im)
|
||||
k = cv2.waitKey(0)
|
||||
if k & 0xff == ord('q'):
|
||||
cap.release()
|
||||
cv2.destroyAllWindows()
|
||||
flag=True
|
||||
else:
|
||||
vidId+=1
|
||||
cap.release()
|
||||
cap.open(vidId, cv2.CAP_DSHOW)
|
||||
print(f"使用摄像头索引: {vidId}")
|
Reference in New Issue
Block a user