Logitech Quickcam 3000 for Business

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
joshuanekl
Posts: 5
Joined: Sun Nov 15, 2009 3:19 am

Logitech Quickcam 3000 for Business

Post by joshuanekl »

I received the following error with my Logitech Quickcam 3000 for business

Code: Select all

$ sudo -u www-data zmu -d /dev/video0 -q -v
Error, failed to query crop /dev/video0: Invalid argument
$ sudo -u www-data ./zmu -d /dev/video0 -q -v -V1
Error, failed to get channel 0 attributes: Invalid argument
After debugging the code, I found it failing on the following statement.

Code: Select all

vidioctl( vid_fd, VIDIOC_G_CROP, &crop )
After looking at the V4L2 documentation, it appears that only devices which support cropping need to implement VIDIOC_G_CROP. Since my camera apparently does not support cropping, this fails.

Looking through the code, the results of this call is never used, it is only displayed as diagnostic information when the verbose flag is set. Therefore, I patched the code to display this information if it succeeds, or ignore it if it fails.

The next point of failure was the call to vidioctl( vid_fd, VIDIOC_S_FMT, &v4l2_data.fmt) with v4l2_data.fmt.fmt.pix.field = V4L2_FIELD_ANY; My fix was to comment out this assignment to leave the current camera settings alone.

When trying to use the web interface's 'Probe' function, it fails to match the machine parseable output from zmu. The 'S:' for available "standards" was missing the colon. Apparently, my device returns 0 standards as a result of the call to vidioctl( vid_fd, VIDIOC_ENUMSTD, &standard ). The code assumed at least one standard would be returned, and the last one would have an extra forward slash at the end. The code following this while loop replaces the last '/' with a pipe '|', but since no standards were appended, the pipe '|' replaced the colon ':' From what I gathered from the V4L2 documents, USB video webcams rarely return standards, so I don't think my camera is mis-behaving by not returning any. I patched the code as seen below to only substitute a pipe '|' if the last character is a forward slash '/'. Also, in the regular expression, I had to change the S:([^|]+) from '+' to '*' so it matches 0 or more occurrences, not one or more occurrences.

Probing still doesn't work, I think the 'arp -a' command is now the culprit. It is located in /usr/sbin/arp on my system (Ubuntu 9.10). I'm suspecting the script is running under a environment that does not have /usr/sbin in its path. I haven't had time to look at this further and come up with a suitable fix.

My camera is now working with these modifications. Thanks for the software.

Josh

Code: Select all

 diff -ur orig/ZoneMinder-1.24.2/src/zm_local_camera.cpp ZoneMinder-1.24.2/src/zm_local_camera.cpp
--- orig/ZoneMinder-1.24.2/src/zm_local_camera.cpp      2009-05-20 19:14:21.000000000 -0400
+++ ZoneMinder-1.24.2/src/zm_local_camera.cpp   2009-11-14 22:06:43.424748327 -0500
@@ -380,7 +380,7 @@
         v4l2_data.fmt.fmt.pix.height = height;
         v4l2_data.fmt.fmt.pix.pixelformat = palette;
         //v4l2_data.fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
-        v4l2_data.fmt.fmt.pix.field = V4L2_FIELD_ANY;
+        //v4l2_data.fmt.fmt.pix.field = V4L2_FIELD_ANY;
 
         if ( vidioctl( vid_fd, VIDIOC_S_FMT, &v4l2_data.fmt ) < 0 )
             Fatal( "Failed to set video format: %s", strerror(errno) );
@@ -841,7 +841,7 @@
                     sprintf( output+strlen(output), "%s/", standard.name );
             }
             while ( standardIndex++ >= 0 );
-            if ( !verbose )
+            if ( !verbose && output[strlen(output)-1] == '/')
                 output[strlen(output)-1] = '|';
       
             if ( verbose )
@@ -910,15 +910,29 @@
             crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
             if ( vidioctl( vid_fd, VIDIOC_G_CROP, &crop ) < 0 )
             {
-                Error( "Failed to query crop: %s", strerror(errno) );
-                if ( verbose )
-                    sprintf( output, "Error, failed to query crop %s: %s\n", queryDevice, strerror(errno) );
-                else
-                    sprintf( output, "error%d\n", errno );
-                return( false );
-            }
-            if ( verbose )
-                sprintf( output+strlen(output), "  Current: %d x %d\n", crop.c.width, crop.c.height );
+               if(errno != EINVAL) 
+               {
+                    Error( "Failed to query crop: %s", strerror(errno) );
+                    if ( verbose )
+                        sprintf( output, 
+                               "Error, failed to query crop %s: %s\n", 
+                               queryDevice, strerror(errno) );
+                    else
+                        sprintf( output, "error%d\n", errno );
+
+                    return( false );
+               } 
+               else if ( verbose )
+               {
+                    Info( "Does not support VIDIOC_G_CROP");
+               } 
+            } 
+           else 
+           {
+               if ( verbose )
+                   sprintf( output+strlen(output), "  Current: %d x %d\n", 
+                       crop.c.width, crop.c.height );
+           }
 
             struct v4l2_input input;
             int inputIndex = 0;
diff -ur orig/ZoneMinder-1.24.2/web/skins/classic/views/monitorprobe.php ZoneMinder-1.24.2/web/skins/classic/views/monitorprobe.php
--- orig/ZoneMinder-1.24.2/web/skins/classic/views/monitorprobe.php     2009-05-28 04:45:50.000000000 -0400
+++ ZoneMinder-1.24.2/web/skins/classic/views/monitorprobe.php  2009-11-08 23:26:49.384248637 -0500
@@ -48,7 +48,7 @@
     $preferredFormats = array( '422P', 'YUYV', 'BGR3' );
     foreach ( $output as $line )
     {
-        if ( !preg_match( '/^d:([^|]+).*S:([^|]+).*F:([^|]+).*I:(\d+)\|(.+)$/', $line, $deviceMatches ) )
+        if ( !preg_match( '/^d:([^|]+).*S:([^|]*).*F:([^|]+).*I:(\d+)\|(.+)$/', $line, $deviceMatches ) )
             die( "Can't parse command output '$line'" );
         $standards = split('/',$deviceMatches[2]);
         $preferredStandard = false; 
brycenesbitt
Posts: 10
Joined: Sat May 07, 2011 11:10 pm

Re: Logitech Quickcam 3000 for Business

Post by brycenesbitt »

Thanks for the patch. I'm getting a similar error with a Logitech Webcam C260:

Code: Select all

xxxxx:~$ zmu -d /dev/video0 -q -v
Error, failed to query crop /dev/video0: Invalid argument

xxxxx:~$ zmu -d /dev/video0 -q -v -V1
Video Device: /dev/video0
Video Capabilities
  Name: UVC Camera (046d:081a)
  Type: 1
    Can capture
  Video Channels: 1
  Audio Channels: 0
  Maximum Width: 0
  Maximum Height: 0
  Minimum Width: 48
  Minimum Height: 32
Window Attributes
  X Offset: 0
  Y Offset: 0
  Width: 352
  Height: 288
Picture Attributes
  Palette: 0 - Unknown
  Colour Depth: 0
  Brightness: 33924
  Hue: 0
  Colour :8224
  Contrast: 8224
  Whiteness: 0
Channel 0 Attributes
  Name: Camera 1
  Channel: 0
  Flags: 0
  Type: 2 - Camera
  Format: 0 - PAL
I hope minor patches and fixes like yours get applied to the trunk revision!
Note that the -V1 option is not documented at http://www.zoneminder.com/wiki/index.php/Zmu
Post Reply