From 1f560662861974eaeaab864db549b4919bbd860a Mon Sep 17 00:00:00 2001 From: Upervision <147962352+Upervision@users.noreply.github.com> Date: Tue, 7 May 2024 17:09:13 +0800 Subject: [PATCH] Create camera's data collection --- camera's data collection | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 camera's data collection diff --git a/camera's data collection b/camera's data collection new file mode 100644 index 0000000..10561ee --- /dev/null +++ b/camera's data collection @@ -0,0 +1,17 @@ +class Capture(object): +''' +Capture object +:param deviceID: device ID of your capture device, defaults to 0 +:type deviceID: :obj:`int` +Example +>>> import pygr +>>> cap = pygr.Capture() +''' +def __init__(self, deviceID=0): # ID为0, 表示从默认的摄像头读取视频数据 +self.deviceID = deviceID +self.capture = cv2.VideoCapture(self.deviceID) # +def read(self): +_, frame = self.capture.read() # 调用默认摄像头捕获一帧图像 +frame = cv2.bilateralFilter(frame, 5, 50, 100) # 对捕获到的图像进行双边滤波 +image = Image.fromarray(frame) # 转换图像数据格式 +return image