Re: uvcvideo: IR camera lights only every second frame

2018-11-01 Thread Ricardo Ribalda Delgado
Hi
On Tue, Oct 30, 2018 at 4:49 PM Kieran Bingham
 wrote:
>
> Hi Jiri,
>
> On 30/10/2018 14:36, Jiri Slaby wrote:
> > Hi,
> >
> > I have a Dell Lattitude 7280 with two webcams. The standard one works
> > fine (/dev/video0). The other one is an IR camera (/dev/video1). The
> > camera proper works fine and produces 340x374 frames. But there is an IR
> > led supposed to light the object. The video is 30fps, but the LED seems
> > to emit light only on half of the frames, i.e. on every second frame (15
> > fps). This makes the video blink a lot. The two consecutive frames look
> > like:
> > https://www.fi.muni.cz/~xslaby/sklad/mpv-shot0002.jpg
> > https://www.fi.muni.cz/~xslaby/sklad/mpv-shot0003.jpg
> >
> > Do you have any ideas what to check/test?
>
> I have an HP Spectre with IR camera, and it also 'flashes' alternate frames.
>
> I assumed this was something to do with controlling the lighting for
> face recognition some how.

I think Kieran is right here. A very common way of detecting what is
close to the camera is using NIR LEDs due to how directional they are.

The algorithm is more or less:

You have a camera with a NIR filter (the rbg camera) and a camera without.

You alternate the NIR LEDs and substract both images. The results are
the object on the front.

You use that information to get what is in on the front of the RGB
camera (unaffected by the NIR leds).

Around 10 years ago we were using this approach for segmentation of
body parts. It worked like a charm for getting biometrical parameters
and detect gestures

https://repositorio.uam.es/bitstream/handle/10486/664236/biometric_morales_LNCS_2009_ps.pdf?sequence=3=y

Cheers!

>
> I'm fairly sure we don't control the 'IR flash' from the UVC.
>
> I wonder if there is a control parameter for the IR led in the
> extension-units?
>
> --
> Regards
>
> Kieran
>
>
>
> > $ v4l2-ctl  --all -d /dev/video2
> > Driver Info (not using libv4l2):
> > Driver name   : uvcvideo
> > Card type : Integrated_Webcam_HD: Integrate
> > Bus info  : usb-:00:14.0-5
> > Driver version: 4.18.15
> > Capabilities  : 0x84A1
> > Video Capture
> > Metadata Capture
> > Streaming
> > Extended Pix Format
> > Device Capabilities
> > Device Caps   : 0x0421
> > Video Capture
> > Streaming
> > Extended Pix Format
> > Priority: 2
> > Video input : 0 (Camera 11: ok)
> > Format Video Capture:
> > Width/Height  : 340/374
> > Pixel Format  : 'YUYV'
> > Field : None
> > Bytes per Line: 680
> > Size Image: 254320
> > Colorspace: sRGB
> > Transfer Function : Default (maps to sRGB)
> > YCbCr/HSV Encoding: Default (maps to ITU-R 601)
> > Quantization  : Default (maps to Limited Range)
> > Flags :
> > Crop Capability Video Capture:
> > Bounds  : Left 0, Top 0, Width 340, Height 374
> > Default : Left 0, Top 0, Width 340, Height 374
> > Pixel Aspect: 1/1
> > Selection: crop_default, Left 0, Top 0, Width 340, Height 374
> > Selection: crop_bounds, Left 0, Top 0, Width 340, Height 374
> > Streaming Parameters Video Capture:
> > Capabilities : timeperframe
> > Frames per second: 30.000 (30/1)
> > Read buffers : 0
> >
> >
> >
> >
> >
> > $ lsusb -vs 1:3
> > Bus 001 Device 003: ID 0bda:5691 Realtek Semiconductor Corp.
> > Device Descriptor:
> >   bLength18
> >   bDescriptorType 1
> >   bcdUSB   2.00
> >   bDeviceClass  239 Miscellaneous Device
> >   bDeviceSubClass 2
> >   bDeviceProtocol 1 Interface Association
> >   bMaxPacketSize064
> >   idVendor   0x0bda Realtek Semiconductor Corp.
> >   idProduct  0x5691
> >   bcdDevice   60.12
> >   iManufacturer   3 CNFGE16N5214300025C2
> >   iProduct1 Integrated_Webcam_HD
> >   iSerial 2 0001
> >   bNumConfigurations  1
> >   Configuration Descriptor:
> > bLength 9
> > bDescriptorType 2
> > wTotalLength 1041
> > bNumInterfaces  4
> > bConfigurationValue 1
> > iConfiguration  4 USB Camera
> > bmAttributes 0x80
> >   (Bus Powered)
> > MaxPower  500mA
> > ** UNRECOGNIZED:  28 ff 42 49 53 54 00 01 06 06 10 00 00 00 00 00 01
> > 07 f4 01 02 08 f4 01 03 09 f4 01 04 0a f4 01 05 0b f4 01 06 0c e8 03
> > Interface Association:
> >   bLength 8
> >   bDescriptorType11
> >   bFirstInterface 0
> >   bInterfaceCount 2
> >   bFunctionClass 14 Video
> >   bFunctionSubClass   3 Video Interface Collection
> >   bFunctionProtocol   0
> >   iFunction

Re: uvcvideo: IR camera lights only every second frame

2018-10-30 Thread Laurent Pinchart
Hello,

On Tuesday, 30 October 2018 17:48:12 EET Kieran Bingham wrote:
> On 30/10/2018 14:36, Jiri Slaby wrote:
> > Hi,
> > 
> > I have a Dell Lattitude 7280 with two webcams. The standard one works
> > fine (/dev/video0). The other one is an IR camera (/dev/video1). The
> > camera proper works fine and produces 340x374 frames. But there is an IR
> > led supposed to light the object. The video is 30fps, but the LED seems
> > to emit light only on half of the frames, i.e. on every second frame (15
> > fps). This makes the video blink a lot. The two consecutive frames look
> > like:
> > https://www.fi.muni.cz/~xslaby/sklad/mpv-shot0002.jpg
> > https://www.fi.muni.cz/~xslaby/sklad/mpv-shot0003.jpg
> > 
> > Do you have any ideas what to check/test?
> 
> I have an HP Spectre with IR camera, and it also 'flashes' alternate frames.
> 
> I assumed this was something to do with controlling the lighting for
> face recognition some how.
> 
> I'm fairly sure we don't control the 'IR flash' from the UVC.
> 
> I wonder if there is a control parameter for the IR led in the
> extension-units?

[snip]

> >   VideoControl Interface Descriptor:
> > bLength18
> > bDescriptorType36
> > bDescriptorSubtype  2 (INPUT_TERMINAL)
> > bTerminalID11
> > wTerminalType  0x0201 Camera Sensor
> > bAssocTerminal  0
> > iTerminal   0
> > wObjectiveFocalLengthMin  0
> > wObjectiveFocalLengthMax  0
> > wOcularFocalLength0
> > bControlSize  3
> > bmControls   0x
> >   VideoControl Interface Descriptor:
> > bLength11
> > bDescriptorType36
> > bDescriptorSubtype  5 (PROCESSING_UNIT)
> >   Warning: Descriptor too short
> > bUnitID 9
> > bSourceID  11
> > wMaxMultiplier  0
> > bControlSize2
> > bmControls 0x
> > iProcessing 0
> > bmVideoStandards 0x09
> >   None
> >   SECAM - 625/50
> >   VideoControl Interface Descriptor:
> > bLength 9
> > bDescriptorType36
> > bDescriptorSubtype  3 (OUTPUT_TERMINAL)
> > bTerminalID 8
> > wTerminalType  0x0101 USB Streaming
> > bAssocTerminal  0
> > bSourceID  10
> > iTerminal   0
> >   VideoControl Interface Descriptor:
> > bLength25
> > bDescriptorType36
> > bDescriptorSubtype  6 (EXTENSION_UNIT)
> > bUnitID12
> > guidExtensionCode {45b5da73-23c1-4a3d-a368-610f078c4397}
> > bNumControl 0
> > bNrPins 1
> > baSourceID( 0)  9
> > bControlSize0
> > iExtension  0

This extension unit is strange, it exposes no control.

> >   VideoControl Interface Descriptor:
> > bLength27
> > bDescriptorType36
> > bDescriptorSubtype  6 (EXTENSION_UNIT)
> > bUnitID10
> > guidExtensionCode {1229a78c-47b4-4094-b0ce-db07386fb938}
> > bNumControl 2
> > bNrPins 1
> > baSourceID( 0) 12
> > bControlSize2
> > bmControls( 0)   0x00
> > bmControls( 1)   0x06
> > iExtension  0

This one exposes two controls, which are likely used to control the IR light. 
I however suspect that the controls merely expose an indirect way to read/
write internal registers, so we would really need to capture a USB trace when 
using the device in Windows (assuming that the machine is shipped with 
software that can control the IR light).

[snip]

-- 
Regards,

Laurent Pinchart





Re: uvcvideo: IR camera lights only every second frame

2018-10-30 Thread Kieran Bingham
Hi Jiri,

On 30/10/2018 14:36, Jiri Slaby wrote:
> Hi,
> 
> I have a Dell Lattitude 7280 with two webcams. The standard one works
> fine (/dev/video0). The other one is an IR camera (/dev/video1). The
> camera proper works fine and produces 340x374 frames. But there is an IR
> led supposed to light the object. The video is 30fps, but the LED seems
> to emit light only on half of the frames, i.e. on every second frame (15
> fps). This makes the video blink a lot. The two consecutive frames look
> like:
> https://www.fi.muni.cz/~xslaby/sklad/mpv-shot0002.jpg
> https://www.fi.muni.cz/~xslaby/sklad/mpv-shot0003.jpg
> 
> Do you have any ideas what to check/test?

I have an HP Spectre with IR camera, and it also 'flashes' alternate frames.

I assumed this was something to do with controlling the lighting for
face recognition some how.

I'm fairly sure we don't control the 'IR flash' from the UVC.

I wonder if there is a control parameter for the IR led in the
extension-units?

--
Regards

Kieran



> $ v4l2-ctl  --all -d /dev/video2
> Driver Info (not using libv4l2):
> Driver name   : uvcvideo
> Card type : Integrated_Webcam_HD: Integrate
> Bus info  : usb-:00:14.0-5
> Driver version: 4.18.15
> Capabilities  : 0x84A1
> Video Capture
> Metadata Capture
> Streaming
> Extended Pix Format
> Device Capabilities
> Device Caps   : 0x0421
> Video Capture
> Streaming
> Extended Pix Format
> Priority: 2
> Video input : 0 (Camera 11: ok)
> Format Video Capture:
> Width/Height  : 340/374
> Pixel Format  : 'YUYV'
> Field : None
> Bytes per Line: 680
> Size Image: 254320
> Colorspace: sRGB
> Transfer Function : Default (maps to sRGB)
> YCbCr/HSV Encoding: Default (maps to ITU-R 601)
> Quantization  : Default (maps to Limited Range)
> Flags :
> Crop Capability Video Capture:
> Bounds  : Left 0, Top 0, Width 340, Height 374
> Default : Left 0, Top 0, Width 340, Height 374
> Pixel Aspect: 1/1
> Selection: crop_default, Left 0, Top 0, Width 340, Height 374
> Selection: crop_bounds, Left 0, Top 0, Width 340, Height 374
> Streaming Parameters Video Capture:
> Capabilities : timeperframe
> Frames per second: 30.000 (30/1)
> Read buffers : 0
> 
> 
> 
> 
> 
> $ lsusb -vs 1:3
> Bus 001 Device 003: ID 0bda:5691 Realtek Semiconductor Corp.
> Device Descriptor:
>   bLength18
>   bDescriptorType 1
>   bcdUSB   2.00
>   bDeviceClass  239 Miscellaneous Device
>   bDeviceSubClass 2
>   bDeviceProtocol 1 Interface Association
>   bMaxPacketSize064
>   idVendor   0x0bda Realtek Semiconductor Corp.
>   idProduct  0x5691
>   bcdDevice   60.12
>   iManufacturer   3 CNFGE16N5214300025C2
>   iProduct1 Integrated_Webcam_HD
>   iSerial 2 0001
>   bNumConfigurations  1
>   Configuration Descriptor:
> bLength 9
> bDescriptorType 2
> wTotalLength 1041
> bNumInterfaces  4
> bConfigurationValue 1
> iConfiguration  4 USB Camera
> bmAttributes 0x80
>   (Bus Powered)
> MaxPower  500mA
> ** UNRECOGNIZED:  28 ff 42 49 53 54 00 01 06 06 10 00 00 00 00 00 01
> 07 f4 01 02 08 f4 01 03 09 f4 01 04 0a f4 01 05 0b f4 01 06 0c e8 03
> Interface Association:
>   bLength 8
>   bDescriptorType11
>   bFirstInterface 0
>   bInterfaceCount 2
>   bFunctionClass 14 Video
>   bFunctionSubClass   3 Video Interface Collection
>   bFunctionProtocol   0
>   iFunction   5 Integrated Webcam
> Interface Descriptor:
>   bLength 9
>   bDescriptorType 4
>   bInterfaceNumber0
>   bAlternateSetting   0
>   bNumEndpoints   1
>   bInterfaceClass14 Video
>   bInterfaceSubClass  1 Video Control
>   bInterfaceProtocol  0
>   iInterface  5 Integrated Webcam
>   VideoControl Interface Descriptor:
> bLength13
> bDescriptorType36
> bDescriptorSubtype  1 (HEADER)
> bcdUVC   1.00
> wTotalLength  107
> dwClockFrequency   15.00MHz
> bInCollection   1
> baInterfaceNr( 0)   1
>   VideoControl Interface Descriptor:
> bLength18
> bDescriptorType36
> bDescriptorSubtype  2 (INPUT_TERMINAL)
> bTerminalID 1
> wTerminalType  0x0201 Camera Sensor