[FIX] ZM 1.24.2 "Error, failed to query crop"
| Author |
Message |
|
dclarke
Joined: Wed Feb 10, 2010 4:17 am Posts: 7
|
 [FIX] ZM 1.24.2 "Error, failed to query crop"
A USB camera that doesn't support cropping will produce an error message "Error, failed to query crop: /dev/video0: Invalid argument" from zmu -q -v.
Failures are exhibited in zmu, and other places that rely on LocalCamera::GetCurrentSettings.
The fault is in LocalCamera::GetCurrentSettings.
The error arises from the fact that ioctl VIDIOC_G_CROP returns -1 and errno = EINVAL to indicate that cropping is not supported. (See http://v4l2spec.bytesex.org/spec/r9994.htm). LocalCamera::GetCurrentSettings treats any negative rc from ioctl VIDIOC_G_CROP as grounds for abnormal termination.
The fix is straightforward and short. All changes are in zm_local_camera.cpp as follows:
 |  |  |  | Code: 911,912c911 < int crop_rc = vidioctl( vid_fd, VIDIOC_G_CROP, &crop ); < if ((crop_rc < 0 ) && (errno != EINVAL)) --- > if ( vidioctl( vid_fd, VIDIOC_G_CROP, &crop ) < 0 ) 921,928c920,921 < if ( verbose ) { < if (crop_rc >= 0) { < sprintf( output+strlen(output), " Current: %d x %d\n", crop.c.width, crop.c.height ); < } < else { < sprintf( output+strlen(output), " Current: Cropping is not supported\n"); < } < } --- > if ( verbose ) > sprintf( output+strlen(output), " Current: %d x %d\n", crop.c.width, crop.c.height );
|  |  |  |  |
|
| Wed Feb 10, 2010 4:47 am |
|
|
|
 |
|
whatboy
Joined: Mon Aug 31, 2009 11:31 pm Posts: 283
|
Don't have any USB cammeras but I bookmaked this thread!!!
Thank you very much... I have seen alot of people with this problem... hope it gets in the new version!!!
|
| Wed Feb 10, 2010 5:38 am |
|
 |
|
cordel
Joined: Fri Mar 05, 2004 5:47 pm Posts: 5218 Location: /USA/Washington/Seattle
|
Thank you for this. Unfortunately we don't use webcams so they don't get the attention they need unless someone loans us one. I have marked this in the developer section to look at patching into the trunk.
Thank you for helping out. 
|
| Wed Feb 10, 2010 6:06 am |
|
 |
|
jcglt
Joined: Fri Feb 12, 2010 8:43 am Posts: 5
|
 ZM 1.24.2 "Error, failed to query crop"
dclarke,
Thanks for your post just over. I understand that you give a few lines of code which would correct an error in the "source code" ?
As an ordinary user and quite newbie I don't know if I can correct something and what I should correct and I guess I shall have to wait for an upgraded version of ZM with a corrected packet ?
I posted a new link under the name "Webcam not working" but think it is useless as many other users of webcams are facing the same problem with no easy solution.
Regards, jcglt
|
| Sat Feb 13, 2010 5:09 am |
|
 |
|
dclarke
Joined: Wed Feb 10, 2010 4:17 am Posts: 7
|
It is a bug fix in the source code; I don't see any work-around other than rebuilding from source code. If you're relying on a pre-compiled distribution you're going to have to wait for your distro provider to update.
I know that's not what you wanted to hear, but them's the facts. Sorry.
|
| Sat Feb 13, 2010 5:49 am |
|
 |
|
jcglt
Joined: Fri Feb 12, 2010 8:43 am Posts: 5
|
 ZM 1.24.2 "Error, failed to query crop"
dclarke,
Many thanks again, I can stop fighting this bloody computer and do something more productive. I shall wait for the next release.
Best regards, jcglt
|
| Sat Feb 13, 2010 5:54 am |
|
 |
|
esergim
Joined: Wed Mar 03, 2010 2:06 pm Posts: 3
|
Could you please post a patch?
i'll apreciate.
Thanks.
|
| Fri Mar 05, 2010 4:19 pm |
|
 |
|
celsian
Joined: Tue Mar 09, 2010 11:50 pm Posts: 1
|
I made the changes to zm_local_camera.cpp as the OP has stated. ./configured and make installed. The installation (after having to supply it with many libraries) finally completed successfully. Unfortunately I'm still getting the following when running zmu -d /dev/video0 -q -v:
"Error, failed to query crop capabilities /dev/video0: Invalid argument"
Does getting this error now that I've made the necessary changes mean my camera, Logitech QuickCam Pro 4000 (USB) will not work with Zone Minder?
Btw, if you're curious where this is occurring in the code, it's line 892 in "zm_local_camera.cpp"
|
| Tue Mar 09, 2010 11:52 pm |
|
 |
|
dclarke
Joined: Wed Feb 10, 2010 4:17 am Posts: 7
|
Are you sure you ran the changed version of the program? The fix is in a library used in a lot of programs; did all the referencing programs (including zmu) get recompiled and updated?
That "Invalid argument" message comes from perror() on errno=EINVAL, but the fix explicitly catches errno=EINVAL and treats it as a normal condition.
Stick in some fprintf(stderr...)'s and see if what you think you did is actually what you really did.
|
| Wed Mar 24, 2010 8:04 pm |
|
 |
|
mick.crane
Joined: Thu Apr 15, 2010 7:23 pm Posts: 1
|
hi,
I also get this error.
I altered zm_local_camera.cpp as above and added "#include <cstdio>"
to zm_utils.cpp
it compiled ok but I still get the error about cropping.
it's only a creative webcam vista plus.
I'm not a coder but I'd rather change a line than get a better webcam just now.
|
| Thu Apr 15, 2010 7:32 pm |
|
 |
|
Abdulrhman
Joined: Fri May 07, 2010 3:30 pm Posts: 1
|
hey bro
i got 2 usb camera and all of them give that error !
anyway i try to catch up with ur edit .. but i got lost !
so .. could u please provide a copy of zm_local_camera.cpp after modification
regards
|
| Fri May 07, 2010 4:31 pm |
|
 |
|
carlosecg
Joined: Thu May 27, 2010 4:51 am Posts: 1 Location: Brazil
|
Hi! Just wanted to say that the ZM install on a Debian Squeeze is easy and painless. Except for this same problem described on the post when trying to use my USB webcam with ZM. On Ubuntu 10.04 I had the same problem. The camera works with Cheese.
Although I'm a programmer, I'm not experienced in linux programming or debian packaging. I tried to rebuild the package from the source on the Debian repository, but it didn't worked. I didn't googled for the errors that appeared because I've been doing this for a few hours, I'll try again later.
My question: is there any forecast on a release that includes this fix? Better yet, a Debian package? If not, how can I help?
|
| Thu May 27, 2010 5:05 am |
|
 |
|
willberg
Joined: Thu Jun 03, 2010 10:51 am Posts: 2
|
Hi there, for anyone also having trouble with getting certain USB/built-in webcams to work because of this cropping issue, but they do work in Cheese/xawtv, you can instead route the camera through a ffmpeg stream. Like so (edited version of http://ubuntuforums.org/showthread.php?t=665607):
Install zoneminder from deb/rpm/whatever is easy. There is a guide on the wiki that works fine.
Install ffmpeg
Back up old ffmpeg streamer config file Make a new config file Input the following Save and exit. (ctrl-x, yes) Start the ffmpeg streaming video server: Start the video stream from the webcam. NOTE, I am assuming we're using /dev/video0 - replace that with your video capture device. NOTE: You must specify video4linux2 there, I've not yet made it work with v4l1. This is different to the instructions at the source. If you get some buffer underflows, don't worry too much. Do worry a little bit, though. Too many can cause it not to work. If you are getting underflows and it doesn't seem to be working, then lower the frame rate (the -r option) or lower the resolution. If you aren't getting underruns, then feel free to mess with those options to improve quality. Now, open the ZoneMinder console in the web browser, and make a new monitor. Make sure it is an ffmpeg stream, then set the location as follows:
The resolution should be the same as that which you set in the ffmpeg stream command before.
It now works.
This worked for me from a clean ZM install on Ubuntu 10.04 Netbook Remix (!!!), using a built-in webcam on a recently-released eeepc (1005ha) - so it will work for just any damn thing at all which works in Cheese.
This isn't an optimal solution, it would be much better to do the compile from source and fix the two bugs (the non-inclusion of a cstdio somewhere, and the above-mentioned fix). For me, however, I kept getting core dumps (!!!!!!) after trying to compile my own, so this is the next-best thing.
If anyone would find it helpful, I can write a complete empty-box-to-working-video tutorial.
Edit: If the stream doesn't seem to be working, i.e. the monitor source is in red text and no image shows, then see if you can get the stream showing in VLC. Install VLC and then point it at that same stream URL which we put in the config file (not the file name we specify in the command): http://localhost:8090/test.flv. If even that doesn't work, then stop the stream and mess with the frame rate/resolution before starting it again.
|
| Thu Jun 03, 2010 11:06 am |
|
 |
|
RCL
Joined: Sat Jun 26, 2010 4:14 pm Posts: 1
|
Thank you for this solution.
I did not manage to get zoneminder to work with ffmpeg streams though, although they are working with VLC (I have two web cameras, so I had to modify your setup). Zoneminder shows monitor names and its sources in orange, but there's no video in monitor windows.
Still, I'm using "raw" ffserver (which config you don't have to replace, just use -f switch) to monitor my pets while I'm at work - and I'm satisfied with this solution even without zoneminder itself  (making it work with UVC cameras out of the box would be great, though!)
|
| Sat Jun 26, 2010 4:42 pm |
|
 |
|
Xhorder
Joined: Thu Jul 15, 2010 12:07 am Posts: 1
|
 Re: [FIX] ZM 1.24.2 "Error, failed to query crop"
 |  |  |  | dclarke wrote: A USB camera that doesn't support cropping will produce an error message "Error, failed to query crop: /dev/video0: Invalid argument" from zmu -q -v. Failures are exhibited in zmu, and other places that rely on LocalCamera::GetCurrentSettings. The fault is in LocalCamera::GetCurrentSettings. The error arises from the fact that ioctl VIDIOC_G_CROP returns -1 and errno = EINVAL to indicate that cropping is not supported. (See http://v4l2spec.bytesex.org/spec/r9994.htm). LocalCamera::GetCurrentSettings treats any negative rc from ioctl VIDIOC_G_CROP as grounds for abnormal termination. The fix is straightforward and short. All changes are in zm_local_camera.cpp as follows:  |  |  |  | Code: 911,912c911 < int crop_rc = vidioctl( vid_fd, VIDIOC_G_CROP, &crop ); < if ((crop_rc <0> if ( vidioctl( vid_fd, VIDIOC_G_CROP, &crop ) < 0 ) 921,928c920,921 < if ( verbose ) { <if>= 0) { < sprintf( output+strlen(output), " Current: %d x %d\n", crop.c.width, crop.c.height ); < } < else { < sprintf( output+strlen(output), " Current: Cropping is not supported\n"); < } <if> sprintf( output+strlen(output), " Current: %d x %d\n", crop.c.width, crop.c.height );
|  |  |  |  |
|  |  |  |  |
I don't understand this 'code'? What do I do with it? do the <and> mean something?
help
|
| Thu Jul 15, 2010 12:12 am |
|
|
Who is online |
Users browsing this forum: No registered users and 0 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|