diff --git a/03-Open-Camera/cv2_capture_live_video_from_camera.py b/03-Open-Camera/cv2_capture_live_video_from_camera.py index 275c14f..dee6cbe 100644 --- a/03-Open-Camera/cv2_capture_live_video_from_camera.py +++ b/03-Open-Camera/cv2_capture_live_video_from_camera.py @@ -1,22 +1,22 @@ -import cv2 +import cv2 as cv # 1.打开摄像头 -capture = cv2.VideoCapture(2) +capture = cv.VideoCapture(2) # 2.获取捕获的分辨率 width, height = capture.get(3), capture.get(4) print(width, height) # 以原分辨率的一倍来捕获, # 参数1可以直接写数字,或者OpenCV符号表示 -capture.set(cv2.CAP_PROP_FRAME_WIDTH, width * 2) -capture.set(cv2.CAP_PROP_FRAME_HEIGHT, height * 2) +capture.set(cv.CAP_PROP_FRAME_WIDTH, width * 2) +capture.set(cv.CAP_PROP_FRAME_HEIGHT, height * 2) while(True): # 获取一帧 ret, frame = capture.read() # 将这帧转换为灰度图 - gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) + gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY) - cv2.imshow('frame', gray) - if cv2.waitKey(1) == ord('q'): + cv.imshow('frame', gray) + if cv.waitKey(1) == ord('q'): break
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: