4 Replies Latest reply on Jun 30, 2016 12:57 PM by lroberts

    UVC Video modules and OpenCV on ubilinux (Debian)

    David_J_Hunt

      Hi all,

       

      I've seen many questions on UVC Video and OpenCV on ubilinux, so I got some time today to look into it.

       

      For UVC video

      There's 4 kernel modules needed, they're in the attached compressed tar file. Install the videobuf2 modules first, then the uvcvideo module.

       

      You should then see your USB Video Camera recognised. I see this when I insert my Logitech Webcam:

      root@ubilinux:~/opencv# dmesg | tail -7

      [ 1467.224080] usb 1-1: new high-speed USB device number 5 using dwc3-host

      [ 1467.247634] usb 1-1: New USB device found, idVendor=046d, idProduct=082d

      [ 1467.247665] usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=1

      [ 1467.247686] usb 1-1: Product: HD Pro Webcam C920

      [ 1467.247705] usb 1-1: SerialNumber: E6C98FCF

      [ 1467.257304] uvcvideo: Found UVC 1.00 device HD Pro Webcam C920 (046d:082d)

      [ 1467.259871] input: HD Pro Webcam C920 as /devices/pci0000:00/0000:00:11.0/dwc3-host.2/usb1/1-1/1-1:1.0/input/input5

      root@ubilinux:~/opencv#

       

      For OpenCV:

       

      apt-get udpate

      apt-get install opencv-dev

       

      And that's about it.

       

      Testing It All

      I then compiled the following program to see if it worked. It's a snipet of code found in another post on this forum here, thanks to 0gravity.  I created a new file, called it test.cpp

       

      #include <iostream>

      #include "opencv2/opencv.hpp"

      using namespace std;

      using namespace cv;

       

      int main() {

        VideoCapture cap(0);

        if(!cap.isOpened()) {

        cout << "I'm blind..." << endl;

        return -1;

        }

        cout << "I can see!" << endl;

        return 0;

      }

       

      And compiled using

      g++ test.cpp `pkg-config opencv --cflags --libs` -o test

       

      Then, when running the resulting 'test' app:

       

      root@ubilinux:~/opencv# ./test

      I can see!

      root@ubilinux:~/opencv#