Motion - Linux Uvc Tracking Patch
You are here: Foswiki>Motion Web>LinuxUvcTrackingPatch (09 Aug 2007, AngelCarpintero)Edit Attach

Patch for support Motion tracking feature with linux-uvc devices

Description of Patch

To enable tracking for Logitech Quickcam Sphere (046d:08c2) which use linux-uvc driver I had written uvc_center and uvc_move function inspired by original lqos_center and lqos_move function.

Installation of Patch

Download the patch file. If it is packed as a gz or tar.gz unpack it first. Then copy it to the motion source directory and issue the command (assuming the patch file is called filename_of_patch_file.diff)

patch < filename_of_patch_file.diff

Then re-build Motion and test the patch.

Change History of Patch

  • 1.0 Initial revision

Discussion and Comments

On my Bus 001 Device 002: ID 046d:08c2 Logitech, Inc.

I get : [1] Failed to move camera!: Input/output error [1] File of type 1 saved to: /usr/local/apache2/htdocs/cam1/01-20060709014719-00.jpg

on kernel log i get: uvcvideo: Failed to query (1) UVC control 1 (unit 9) : -32.

ps: i've set the TRACK_TYPE to 5 do i have to modify something else?


-- FabioYamamoto - 09 Jul 2006

I track down the problem, i can't explain. but here it is:

When vd->formatIn is set to V4L2_PIX_FMT_YUYV the control (pan/tilt) do not respond. if i set to V4L2_PIX_FMT_MJPEG it works. ( But "Motion" is not prepared to accept this format ).

-- FabioYamamoto - 10 Jul 2006

I gonna try to merge your patch with current svn version revision 163 , but the API of uvcvideo has changed so i will introduce some changes.

-- AngelCarpintero - 25 Jan 2007

I have problem with tilting. Panning works ok, but tilt aint. My device is also 046d:08c2 Logitech, Inc. Logitech Sphere and using with V4L2_PIX_FMT_MJPEG ok. Is there any solution in this tilt problem?

-- PeterBowle - 20 Feb 2007

Same problem as PeterBowle :

uvctrack.diff applied to latest daily snapshot : panning OK, tilting KO

everything was allright with 3.6 release sources.

-- JeromeV - 26 Feb 2007

in the version 3.8.1 I get only mad moves - up&down nothing left&right sometimes and not clear. My cam is a 08CC. This I can see, if I start the uvcvideo with tracelevel 15:

LinkStation:/usr/local/src/motion/motion# cat usb_08CC
Linux video capture interface: v2.00
uvcvideo: Adding mapping Brightness to control 00000000-0000-0000-0000-000000000101/2.
uvcvideo: Adding mapping Contrast to control 00000000-0000-0000-0000-000000000101/3.
uvcvideo: Adding mapping Hue to control 00000000-0000-0000-0000-000000000101/6.
uvcvideo: Adding mapping Saturation to control 00000000-0000-0000-0000-000000000101/7.
uvcvideo: Adding mapping Sharpness to control 00000000-0000-0000-0000-000000000101/8.
uvcvideo: Adding mapping Gamma to control 00000000-0000-0000-0000-000000000101/9.
uvcvideo: Adding mapping Backlight Compensation to control 00000000-0000-0000-0000-000000000101/1.
uvcvideo: Adding mapping Gain to control 00000000-0000-0000-0000-000000000101/4.
uvcvideo: Adding mapping Power Line Frequency to control 00000000-0000-0000-0000-000000000101/5.
uvcvideo: Adding mapping Hue, Auto to control 00000000-0000-0000-0000-000000000101/16.
uvcvideo: Adding mapping Pan (relative) to control 63610682-5070-49ab-b8cc-b3855e8d2256/1.
uvcvideo: Adding mapping Tilt (relative) to control 63610682-5070-49ab-b8cc-b3855e8d2256/1.
uvcvideo: Adding mapping Pan/Tilt (reset) to control 63610682-5070-49ab-b8cc-b3855e8d2256/2.
uvcvideo: Adding mapping Exposure, Auto to control 00000000-0000-0000-0000-000000000001/2.
uvcvideo: Adding mapping Exposure (Absolute) to control 00000000-0000-0000-0000-000000000001/4.
uvcvideo: Adding mapping White Balance Temperature, Auto to control 00000000-0000-0000-0000-000000000101/11.
uvcvideo: Adding mapping White Balance Temperature to control 00000000-0000-0000-0000-000000000101/10.
uvcvideo: Probing generic UVC device 1
uvcvideo: Found format MJPEG.
uvcvideo: - 160x120 (30.0 fps)
uvcvideo: - 176x144 (30.0 fps)
uvcvideo: - 320x240 (15.0 fps)
uvcvideo: - 352x288 (15.0 fps)
uvcvideo: - 640x480 (15.0 fps)
uvcvideo: - 960x720 (15.0 fps)
uvcvideo: Found format Uncompressed.
uvcvideo: - 160x120 (30.0 fps)
uvcvideo: - 176x144 (30.0 fps)
uvcvideo: - 320x240 (15.0 fps)
uvcvideo: - 352x288 (15.0 fps)
uvcvideo: - 640x480 (15.0 fps)
uvcvideo: - 960x720 (10.0 fps)
uvcvideo: - 1280x960 (7.5 fps)
uvcvideo: Found a Status endpoint (addr 87).
uvcvideo: Found UVC 1.00 device <unnamed> (046d:08cc)
uvcvideo: Added control 00000000-0000-0000-0000-000000000101/2 to device 1 entity 2
uvcvideo: Added control 00000000-0000-0000-0000-000000000101/3 to device 1 entity 2
uvcvideo: Added control 00000000-0000-0000-0000-000000000101/7 to device 1 entity 2
uvcvideo: Added control 00000000-0000-0000-0000-000000000101/8 to device 1 entity 2
uvcvideo: Added control 00000000-0000-0000-0000-000000000101/1 to device 1 entity 2
uvcvideo: Added control 00000000-0000-0000-0000-000000000101/4 to device 1 entity 2
uvcvideo: Added control 00000000-0000-0000-0000-000000000101/5 to device 1 entity 2
uvcvideo: Added control 63610682-5070-49ab-b8cc-b3855e8d2256/1 to device 1 entity 9
uvcvideo: Added control 63610682-5070-49ab-b8cc-b3855e8d2256/2 to device 1 entity 9
uvcvideo: Added control 00000000-0000-0000-0000-000000000001/2 to device 1 entity 1
uvcvideo: Added control 00000000-0000-0000-0000-000000000001/4 to device 1 entity 1
uvcvideo: Added control 00000000-0000-0000-0000-000000000101/11 to device 1 entity 2
uvcvideo: Added control 00000000-0000-0000-0000-000000000101/10 to device 1 entity 2
uvcvideo: Scanning UVC chain: OT 5 (-> 12 8 10 11 9) <- Unit 4 (-> 13) <- Unit 3 <- Unit 2 <- IT 1
uvcvideo: Found a valid video chain (1 -> 5).
uvcvideo: UVC device initialized.
usbcore: registered new interface driver uvcvideo
USB Video Class driver (v0.1.0)

-- DirkWesenberg - 14 Mar 2007

Sorry, if I lost the format .Interessting is the message if I want to control the camera (also from dmesg = uvcvideo:
  • Just start with <verbatim> and end with </verbatim> when you want to show "ASCII" text without TWiki formatting. -- KennethLavrsen

uvcvideo: Trying format 0x56595559 (VYUY): 640x480.

uvcvideo: Using default frame interval 66666.6 us (15.0 fps).

uvcvideo: Trying format 0x56595559 (VYUY): 640x480.

uvcvideo: Using default frame interval 66666.6 us (15.0 fps).

uvcvideo: Control 0x00980903 not found.

uvcvideo: Control 0x0098090e not found.

uvcvideo: Control 0x0098090f not found.

uvcvideo: Control 0x00980910 not found.

uvcvideo: Control 0x00980911 not found.

uvcvideo: Control 0x00980912 not found.

-- DirkWesenberg - 14 Mar 2007

One information more:

Motion - daily bind from the 14.03 / uvcvideo = daily from 13.03

I have try it in the morning also via a M$ IE and it works better as the Konquerer. The problem of Peter Bowle, I've too. I use the script and html for try from :

with all the buttons at the webpage ( not the last - for testing the first is better ).


up and down at the buttons from the web will move the Cam left and right ! Left and right at the buttons from the webside will NOT move the Cam. I think, there is only a little count error somewhere ?

-- DirkWesenberg - 15 Mar 2007

The HTTP/1.0 204 No Content trick works on all browsers - except some older versions of Konquerer that seems to react the wrong way to this.

-- KennethLavrsen - 15 Mar 2007

Hi I am having a similar problem. I have everything working apart from tilt. Pan is fine but I get no response to tilt. Any help much appreciated

-- PaulMcclung - 17 Mar 2007

Upps - I does not want override the old patch.... I have modified the old patch and split the pan/tilt function into 2 calls. I know it will be going better, but in C I'm a bloody beginner. Feel free to test also and/or change the 2 single calls of the procedure VIDIOC_S_CTRL to one call via VIDIOC_S_EXT_CTRLS .... Tested with the motion of daily from 15.3.07 of motion and the daily of 15.3 of uvcvideo with the Kernel 2.6.20-4 PPC.

There is a small bug in the patch: I'll update later today ( Pan does not work anymore [all pan.tilt value must be in tilt ] ). Pan is working, but not long ... Maybe a small pause must be in ...

I try to rewrite the function - Yesterday Tilt was working w/o any problems, but Pan was going over the limit (first pan was working)... The pan&tilt via picture coordinate is in the first step disabled. At first the normal PAN&TILT must be working. I'm sorry that it is not going faster, but I've no experience with C ( more in Assembler ) ... maybe at the evening, I'll have a result.

-- DirkWesenberg - 28 Mar 2007

The Motion_Logitech_MP_Tracking.diff is now working with uvcvideo ( 03/07) and motion 3.2.8 with a Logitech Sphere MP refresh.

Relative PAN=7777 is also a PANTILT Reset. Also if first only relative working and than the switch to absolut is now working, because I reset the Webcam at first use. The Min & Max is fixed in Code, because the function is not included just now. Also the prgramming is not the best:I know-but it is my first C prog-Part. I hope, I have nothing forgotten, because M$ Controll char is must recopy in a orig track.c file. Have fun !

-- DirkWesenberg - 30 Mar 2007

Thanks , added to current svn trunk , i did some ident on code ... still i didn't check it i'll try to get a webcam or someone that allow me to test one.

-- AngelCarpintero - 31 Mar 2007

Continue: During I try to change the patch about Pan&Tilt I see, that the WebCam Logitech 0x08cc handle also digital zoom. I think that is also hardware controll. In V4L2 I've found the procedure : VIDIOC_S_CROP Does someone have try, to implement this feature ?

-- DirkWesenberg - 18 Apr 2007

The current patch it's already in current beta ( 3.2.8 beta 1) , so new patches will be against this beta version.

-- AngelCarpintero - 21 Apr 2007

I am having a similar problem with uvcvideo with original Logitech Orbit MP (046d:08c2) on Linux 2.6.20-16-generic using Motion 3.2.8 b1 (as well as latest snapshot). If I plug the camera into a USB 2.0 port, YUYV is used in Motion and I get a decent picture with flickering and no tracking. If I plug the camera into a USB 1.1 port, MJPG is used in Motion and the picture has funny colors, but the tracking works. Using the camera with luvcview (v0.2.1), the camera has a clear picture and tracking works with either USB 1.1 or 2.0 and generally get 13-16 fps.

-- BiehlD - 19 Jul 2007

I'm going to commit a patch to svn that fix the color issue, there was a previous patch that fixed that issue already but using libmjpegtools :

But was not very smart to introduce another dependency , so i hope the next commit fix finally the color issue.

Take a look to this new topic :

-- AngelCarpintero - 24 Jul 2007

After applying the patch mentioned in to release 200, I get a seg fault when I run Motion. Motion starts up, and reads the camera controls, then seg faults.

 motion: [1] cap.driver: "uvcvideo"
 motion: [1] cap.card: "UVC Camera (046d:08c2)"
 motion: [1] cap.bus_info: "0000:00:1f.2"
 motion: [1] cap.capabilities=0x04000001
 motion: [1] - VIDEO_CAPTURE
 motion: [1] - STREAMING
 motion: [1] v4l2_select_input: name = "Camera 1", type 0x00000002, status 00000000
 motion: [1] - CAMERA
 motion: [1] Device doesn't support VIDIOC_G_STD 
 motion: [1] Supported palettes:
 motion: [1] 0: MJPG (MJPEG)
 motion: [1] Test palette MJPG (640x480)
 motion: [1] Using palette MJPG (640x480) bytesperlines 0 sizeimage 62933 colorspace 00000008
 motion: [1] found control 0x00980900, "Brightness", range 0,255 
 motion: [1] ^I"Brightness", default 127, current 231
 motion: [1] found control 0x00980901, "Contrast", range 0,255 
 motion: [1] ^I"Contrast", default 32, current 221
 motion: [1] found control 0x00980902, "Saturation", range 0,255 
 motion: [1] ^I"Saturation", default 32, current 221
 motion: [1] found control 0x00980910, "Gamma", range 100,220 
 motion: [1] ^I"Gamma", default 220, current 220
 motion: [1] found control 0x00980913, "Gain", range 0,255 
 motion: [1] ^I"Gain", default 0, current 0
 motion: [1] found control 0x08000000, "Backlight Compensation", range 0,2 
 motion: [1] ^I"Backlight Compensation", default 1, current 1
 motion: [1] found control 0x08000001, "Power Line Frequency", range 0,2 
 motion: [1] ^I"Power Line Frequency", default 2, current 2

Motion v3.2.8 still has the same color issues with the Logitech Orbit MP (046d:08c2). The strange colors appear more as the satuartion is increased. Email me if you need additional info.

-- BiehlD - 02 Aug 2007
You're right my patch segfault , i didn't notice before because seems that my camera ( using uvcvideo ) gets jpegs without problems , so there's no problem with huffman table , strange though. I'll work on this.

-- AngelCarpintero - 06 Aug 2007
I've added the old patch against current svn version ( -r201 )

-- AngelCarpintero - 08 Aug 2007


r201 with mjpeg-color-issue.diff (from messages log)....

motion: [1] ^I"Power Line Frequency", default 2, current 2
motion: [1] Missing huffman table ... fixing
last message repeated 9 times
motion: [1] Removed process id file (pid file).
(motion quits automatically)

r201 with mjpeg2-r201.patch (while patching)...
patching file
patching file video.h
patching file video2.c
Hunk #1 succeeded at 828 with fuzz 2 (offset 42 lines).
patching file video_common.c
Hunk #2 succeeded at 396 (offset -1 lines).

r201 with mjpeg2-r201.patch works and color problem is fixed...Thank You!

-- BiehlD - 09 Aug 2007

Ok , seems that mjpeg-color-issue.diff mess jpeg :-/

So mjpeg2-r201.patch with mjpegtools dependency is in svn trunk until there's not a best approach.

-- AngelCarpintero - 09 Aug 2007

Topic revision: r28 - 09 Aug 2007, AngelCarpintero
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.