-
Capture images with sq11 on a rpi3
Challenge
Connect the cheap sq11 micro cameras to rpi! SQ11
Prerequisites
- RPI3 running Raspbian GNU/Linux 9 (stretch)
- One or more sq11 micro cameras
- fswebcam
Description
When connecting the sq11 to rpi through usb, for the first time, you may notice the
dmesg
output as shown below.[ 1465.185248] usb 1-1-port2: over-current change [ 1465.441253] usb 1-1-port2: over-current change [ 1465.697251] usb 1-1-port2: over-current change ...
There are multiple reasons why we get
usb 1-1-port2: over-current change
.- You are not providing enough energy to rpi (“max_usb_current=1” might be a case)! I would suggest you use at least a 5V-2A plug.
- The camera is not open yet :) Hold the power button until the led is blue. Then click the “M” button once and the led should blink red periodically. Check the
dmesg
. (It doesn’t matter if a micro sd is inserted to the camera or not)
The
dmsg
output will look like:[ 1468.548203] usb 1-1.4: new high-speed USB device number 8 using dwc_otg [ 1468.678775] usb 1-1.4: config 1 interface 3 has no altsetting 1 [ 1468.678994] usb 1-1.4: New USB device found, idVendor=1908, idProduct=3272 [ 1468.679005] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 1468.679014] usb 1-1.4: Product: GENERAL - AUDIO [ 1468.679022] usb 1-1.4: Manufacturer: Generic [ 1468.683358] uvcvideo: Found UVC 1.00 device GENERAL - AUDIO (1908:3272) [ 1468.684619] uvcvideo 1-1.4:1.0: Entity type for entity Extension 4 was not initialized! [ 1468.684636] uvcvideo 1-1.4:1.0: Entity type for entity Processing 3 was not initialized! [ 1468.684647] uvcvideo 1-1.4:1.0: Entity type for entity Camera 1 was not initialized! [ 1468.685060] input: GENERAL - AUDIO: GENERAL - UVC as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/input/input4 [ 1468.693374] usb-storage 1-1.4:1.4: USB Mass Storage device detected [ 1468.698635] scsi host0: usb-storage 1-1.4:1.4 [ 1469.748786] scsi 0:0:0:0: Direct-Access Buildwin Media-Player 1.00 PQ: 0 ANSI: 4 [ 1469.749801] sd 0:0:0:0: Attached scsi generic sg0 type 0 [ 1469.750660] sd 0:0:0:0: [sda] Attached SCSI removable disk
Notice that the camera is now found as a
UVC
device and is attached to the/dev/video0
file.lsusb
output is like:Bus 001 Device 008: ID 1908:3272 GEMBIRD 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. SMC9514 Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
and the video list looks like:
pi@monitor:~ $ v4l2-ctl --list-devices GENERAL - AUDIO: GENERAL - UVC (usb-3f980000.usb-1.4): /dev/video0
Next step is to take a picture by using
fswebcam
sudo apt-get install -y fswebcam
and …
fswebcam -i 0 -d v4l2:/dev/video0 --no-banner --jpeg 95 --save test1.jpg --- Opening v4l2:/dev/video0... /dev/video0 opened. Adjusting resolution from 384x288 to 320x240. --- Capturing frame... GD Error: gd-jpeg: JPEG library reports unrecoverable error: Not a JPEG file: starts with 0x31 0xcdCaptured frame in 0.00 seconds. --- Processing captured image... Disabling banner. Setting output format to JPEG, quality 95 Writing JPEG image to 'test1.jpg'.
The
GD Error
shown above is a topic “here” and the solution is to include ` -S 2`. This way, fswebcam will skip 2 frames and the outut will look like:--- Opening v4l2:/dev/video0... /dev/video0 opened. Adjusting resolution from 384x288 to 320x240. --- Capturing frame... Skipping 2 frames... Capturing 1 frames... Captured 3 frames in 0.08 seconds. (37 fps) --- Processing captured image... Disabling banner. Setting output format to JPEG, quality 95 Writing JPEG image to 'test1.jpg'.
Enjoy!