首页 > 解决方案 > 如何从 colab 中的实时网络摄像头生成图像帧以进行实时草图检测

问题描述

def Sketch(image):

  grey_img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

  #reducing the noise in the image

  blur_img = cv2.GaussianBlur(grey_img, (5,5), 0)

 #Edge extraction

  edge_img = cv2.Canny(blur_img, 10,70 )

  ret, mask = cv2.threshold(edge_img, 70,255,cv2.THRESH_BINARY_INV)


**cap = cv2.VideoCapture(0)
while True:
  ret, frame = cap.read()
  cv2_imshow(Sketch(frame))
#release the camera and close the window
cap.release()**

粗体代码不起作用,因为它是为 jupyter notebook 定义的,但我正在尝试在 Google Colab 中运行它。此代码从实时网络摄像头拍摄的视频中生成图像帧,并更新出现在实时网络摄像头中的图像。谁能告诉我 colab 中用于构建实时草图的替换代码是什么。很抱歉无法正确解释。简而言之,我想说的就是使用网络摄像头在 Google Colab 上制作一个实时草图检测器。

标签: python-3.xgoogle-colaboratorywebcamreal-time-updates

解决方案


推荐阅读