dhruvvyas90
Posts: 25
Joined: Thu Nov 21, 2013 2:36 pm

Problems with 2 USB Cameras and Rpi 2

Tue Jun 30, 2015 12:14 pm

I'm running a Ubuntu 14.04 LTS on my RPi 2. I've OpenCV 2.4.9 installed on it. While running a simple camera capture program works fine.

Here is a code for it.

Code: Select all

import numpy as np
import cv2
from time import time

cap = cv2.VideoCapture(0)
cap2 = cv2.VideoCapture(1)
frame_count = 0
while(True):
    # Capture frame-by-frame
    start_t = time()
    ret, frame = cap.read()
    #ret2, frame2 = cap2.read()
    end_t = time()
    time_diff = (end_t - start_t)
    print 'Diff is : %f ms\n' % (time_diff * 1000)

cap.release()
cap2.release()
cv2.destroyAllWindows()
But if I remove comments from the line

Code: Select all

#ret2, frame2 = cap2.read()
to enable getting feeds from the other camera, it takes a lot of time to capture a frame (10 sec or something). Has anyone faced similar problem ? I tested the same program on my ubuntu 15.04 laptop. It works fine on my laptop.

Additional info :

Output of lsusb.

Code: Select all

Bus 001 Device 006: ID 046d:0825 Logitech, Inc. Webcam C270
Bus 001 Device 005: ID 046d:082b Logitech, Inc. 
Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Output of dmesg | tail

Code: Select all

[email protected]:~/opencv-exp$ dmesg | tail
[  232.894415] usb 1-1.2: reset high-speed USB device number 4 using dwc_otg
[  236.346374] usb 1-1.2: reset high-speed USB device number 4 using dwc_otg
[  245.562299] usb 1-1.2: reset high-speed USB device number 4 using dwc_otg
[ 1421.092574] usb 1-1.2: reset high-speed USB device number 4 using dwc_otg
[ 1448.449098] usb 1-1.2: reset high-speed USB device number 4 using dwc_otg
[ 1797.956648] uvcvideo: Non-zero status (-5) in status completion handler.
[ 2117.334545] usb 1-1.2: reset high-speed USB device number 4 using dwc_otg
[ 2121.682477] usb 1-1.2: reset high-speed USB device number 4 using dwc_otg
[ 2138.670181] usb 1-1.2: reset high-speed USB device number 4 using dwc_otg
[ 2369.394190] usb 1-1.2: reset high-speed USB device number 4 using dwc_otg
Update :

While forcing webcam resolutions to 320x240 by

Code: Select all

cap.set(3, 320);
cap.set(4, 240);
cap2.set(3, 320);
cap2.set(4, 240); 
It works fine. Does it have anything to do with v4l2 or something ?

Return to “Beginners”