Fork me on GitHub

随笔 - 997  文章 - 5  评论 - 181  阅读 - 300万 

一 概念

OpenCV是一个开源的计算机视觉和机器学习软件库。它可以使用pip命令行中的以下命令安装:“pip install opencv-python”

这个做视觉处理,非常的方便。

 

二  源码解析

复制代码
import cv2
cap = cv2.VideoCapture(2)  # /dev/video0
while(True):
    ret, frame = cap.read()  # ret==True/False: read successfully or not; frame: image
    if not ret:
        print("Failed to read the image.")
        break
    # display image
    cv2.imshow('Video', frame)
    # press ESC key to exit
    key = cv2.waitKey(1)
    if key == 27:
        break
cap.release()
复制代码

 

三 重点解析

1 此处,cap = cv2.VideoCapture(0) 的功能就是读取来自 /dev/video2 这个端口的视频流。

可以通过命令:ls -l /dev | grep video 

来查看你所处的端口号。

2 通过插拔该设备,使用命令:lsusb 来查看该设备的产品号和ID号,笔者的如下所示:

Bus 002 Device 003: ID 0bda:9281 Realtek Semiconductor Corp.

这就是你想要的设备。
记住 0bda:9281  这个位置的数字, 0bda 是设备的 idVendor ,9281是设备的 idProduct 。

四 参考

1 https://blog.csdn.net/qq_40157728/article/details/105510025

posted on   虚生  阅读(930)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
历史上的今天:
2018-08-16 python中numpy.ndarray.shape的用法
点击右上角即可分享
微信分享提示