USB camera, horizontal image crashes


5 posts
by ksieluk » Tue Sep 11, 2012 9:31 pm
Hello everyone.

I am trying to force my USB camera (Creative Live Vista Cam) to work properly with my Raspberry Pi.
In order to check it out I wrote small script in Python, using OpenCV library:

Code: Select all
import cv2.cv as cv
capture = cv.CreateCameraCapture(-1)
cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FRAME_WIDTH, 320)
cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FRAME_HEIGHT, 240)
img = cv.QueryFrame(capture)
cv.SaveImage("output.jpg",img)


And everything seemed to be ok...

Next thing I decided to do was taking few shoots one after another. So I modified script a bit:


Code: Select all
import cv2.cv as cv
i=0
while i <10:
   capture = cv.CreateCameraCapture(-1)
   cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FRAME_WIDTH,320)
   cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FRAME_HEIGHT,240)
   img = cv.QueryFrame(capture)
   nazwa = 'output{0}.jpg'.format(i)
   cv.SaveImage(nazwa,img)
   i = i+1


As a result, I get 10 photos, where first was alright, but others were *crashed*.There were some horizontal shifts (the bottom part was on the top).

I was trying to change the size of the captured image, but it didn't solved the problem.

My next step was mplayer test.

I used in the shell command:

Code: Select all
mplayer -cache 128 -fps 15 -tv driver=v4l2:width=320:height=240:device=/dev/video0 tv://


In a new window I saw few frames (some of them were crashed too) and after few seconds camera stopped responding.

I am using Arch Linux.

I am looking forward hearing from You guys;) It's really annoying, becouse I can't move forward with my project.
Posts: 15
Joined: Tue Sep 11, 2012 8:03 pm
by elatllat » Sun Sep 16, 2012 2:11 pm
There are some known known bugs with the usb driver, try:
rpi-update
smsc95xx.turbo_mode=N in /boot/cmdline.txt
dwc_otg.microframe_schedule=1 in /boot/cmdline.txt
vm.min_free_kbytes=16384 in /etc/sysctl.conf
reboot

If the problem persists post
Code: Select all
dmesg
4k or USB3 : hardkernel.com

FAQ : raspberrypi.stackexchange.com

https://google.com/search?q=site%3Awww.raspberrypi.org+search+first

https://www.raspberrypi.org/forums/search.php?search_id=unanswered
Posts: 1337
Joined: Sat Dec 17, 2011 5:05 pm
by Wisar » Mon Apr 08, 2013 8:07 pm
elatllat

Thanks for the USB tweeks...the seem to have given me the stability that I have lacked with libgphoto2 driving my DSLR. My app did not used to run more than a couple of captures before going belly up. Great input.

Wisar
Posts: 58
Joined: Tue Sep 25, 2012 6:33 am
Location: Temple near Marlow, England
by davef21370 » Fri Apr 12, 2013 1:30 pm
elatllat wrote:try:
rpi-update
smsc95xx.turbo_mode=N in /boot/cmdline.txt
dwc_otg.microframe_schedule=1 in /boot/cmdline.txt
vm.min_free_kbytes=16384 in /etc/sysctl.conf


I've been having problems with gphoto2 so thought I'd give this a go, I've changed vm.min_free_kbytes but don't have the other 2 in cmdline.txt, do I just add them? If so, what does the xx represent in smsc95xx?

Cheers.
Dave.
Please feel free to tap into my abundant lack of knowledge.
When you're dead you don't know you're dead. It's the same as being stupid.
Apple say. Monkey do.
User avatar
Posts: 824
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded
by M33P » Fri Apr 12, 2013 6:44 pm
davef21370 wrote:
I've been having problems with gphoto2 so thought I'd give this a go, I've changed vm.min_free_kbytes but don't have the other 2 in cmdline.txt, do I just add them? If so, what does the xx represent in smsc95xx?

Cheers.
Dave.

smsc95xx is the name of the driver. It caters for several types of SMSC chips. Insert this parameter for turbo mode with a space before and after, anywhere in the single line already in /boot/cmdline.txt.

dwc_otg.microframe_schedule is now default to 1, you don't need to add it.
Posts: 199
Joined: Sun Sep 02, 2012 1:14 pm