1 Reply Latest reply on Jun 30, 2015 10:12 AM by kikedev

    Can't capture snapshot from a webcam with OpenCV on UBILINUX


      Hi all,


      I'm a kind new in embedded systems and I have a problem when trying to capture a snapshot from a webcam in python with this simple script on Ubilinux (last version: ubilinux-edison-150309).


      import cv2.cv as cv
      capture = cv.CaptureFromCAM(0)
      img = cv.QueryFrame(capture)
      cv.SaveImage("camera.jpg", img)


      the "camera.jpg" file has nothing inside and no error is prompted.

      When I connect the usb camera ( a LifeCam HD-5000 from Microsoft ) this is what I get:

      enrique@ubilinux:~/instalables$  dmesg | tail -7

      enrique@ubilinux: ~-instalables_453.png

      enrique@ubilinux:~/instalables$  lsusb


      enrique@ubilinux:~/instalables$ ls /sys/module/ | grep video


      enrique@ubilinux:~/instalables$ lsmod

      enrique@ubilinux: ~-instalables_454.png

      I installed the opencv package through pip, but when I tried to install python-opencv through package manager I've got this : (according to Dave https://communities.intel.com/thread/60092 )

      enrique@ubilinux:~/instalables$ sudo apt-get install opencv-dev

      Reading package lists... Done

      Building dependency tree   

      Reading state information... Done

      E: Unable to locate package opencv-dev

      Even after an apt-get update.



      I realized that the correct package name is libopencv-dev, however the problem persists


      Please I dont wanna get out from Ubilinux.

      Ubilinux rocks!






      Message was edited by: Enrique Soto Mendoza

        • 1. Re: Can't capture snapshot from a webcam with OpenCV on UBILINUX

          Hi I just solved this, It was a permission problem, this is what I did:


          To be sure that my webcam is taking photos with ffmpeg

          enrique@ubilinux:~/workspaces$ ffmpeg -f video4linux2 -i /dev/v4l/by-id/usb-Microsoft_Microsoft®_LifeCam_HD-5000-video-index0 -vframes 1 test.jpeg


          The ffmpeg program is only provided for script compatibility and will be removed

          in a future release. It has been deprecated in the Libav project to allow for

          incompatible command line syntax improvements in its replacement called avconv

          (see Changelog for details). Please use avconv instead.

          [video4linux2 @ 0x8c1a800] Cannot open video device /dev/v4l/by-id/usb-Microsoft_Microsoft®_LifeCam_HD-5000-video-index0 : Permission denied

          /dev/v4l/by-id/usb-Microsoft_Microsoft®_LifeCam_HD-5000-video-index0: Permission denied


          enrique@ubilinux:~/workspaces$ ls -l /dev/video0

          crw-rw---T 1 root video 81, 0 Jun 30 15:17 /dev/video0

          So, obviously It was a permission issue. So I added my user to video group:

          enrique@ubilinux:~/workspaces$ sudo usermod -a -G video enrique

          logout and login again, and  thats all.