python-3.x - 如何从 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 上制作一个实时草图检测器。
解决方案
推荐阅读
- javascript - 使用 $state.go 和调用函数路由到新控制器
- bash - 使用 curl 将输入数据流式传输到 Unix 管道的问题
- mysql - 简单考勤表 SQL schema 架构建议
- r - 在R闪亮中,如果视图想要切换它,如何创建操作按钮来转置矩阵?
- python - 如何更改 tkinter 窗口的背景颜色
- ruby-on-rails - 向控制器添加关注点会导致 AbstractController::ActionNotFound
- netlogo - 使用 Netlogo 进行网络建模
- c++ - 有什么方法可以使用原始字节向量作为增强序列化的存档吗?
- javascript - 如何使用 Netlify Lambda 函数隐藏 API 密钥
- ios - URLSession dataTask 无错误无数据返回,导致 SwiftyStoreKit.ReceiptError 错误 1