• Recent
    • Docs
    • Github
    • 百度网盘
    • Onedrive
    • Official
    • Shop
    • Register
    • Login

    Cool Pi4 Ubuntu 22.04 上 ssh remote 方式访问USB摄像头的问题与解决

    Scheduled Pinned Locked Moved Ubuntu
    2 Posts 2 Posters 241 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      edwardzhou
      last edited by

      环境: Ubuntu 22.04 0303纯净版

      接上 usb camera 开机,没有登陆桌面

      ssh 登录 coolpi4 (ip: 192.168.5.63)

      ssh 192.168.5.63
      
      python
      
      import cv2
      camera = cv2.VideoCapture(20)
      
      

      得到如下错误
      c5435a3e-0288-4181-b139-88025e6061f6-image.png

      无法打开usb 摄像头。

      接上显示器,鼠标键盘,登录桌面后,在桌面的terminal中,能够正常打开摄像头获取图像。

      此时,到前面的ssh remote 里,发现也能打开摄像头获取头像了。

      好玩的事情出现,当我登出桌面(log out)后, ssh remote 又无法打开摄像头。

      后面猜测可能是权限的问题,便问了chatgpt, 并进行验证

      sudo python
      import cv2
      camera = cv2.VideoCapture(20)
      

      发现在不没有登录桌面的情况下,是能成功打开摄像头。

      还可以加入到video用户组,就不需要提权了.

      sudo usermod -aG video edwardzhou
      # 重新登录
      
      python
      import cv2
      camera = cv2.VideoCapture(20)   # 成功
      

      总结:
      确保当前用户在 video 组里面。

      G 1 Reply Last reply Reply Quote 1
      • G
        george @edwardzhou
        last edited by

        @edwardzhou : good

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post