Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > looking for help about python-sane

Reply
Thread Tools

looking for help about python-sane

 
 
derek
Guest
Posts: n/a
 
      02-28-2006
I m looking for help about python-sane, The follow sample code try to
grab the image from the webcam through a /dev/video0 on linux, it works
fine for the first 185 times, but it freeze the computer when i ~ 185,
I dont know why?

The computer become very busy when i > 160, very strange?

I m using Ubuntu 5.10 Linux

Thanks


-----------------------code start------------------

#! /usr/bin/python

import sane, time, Image

def grabImage(_webcam):
_webcam.mode='color'
_webcam.start()
img=_webcam.snap()
return img



for i in range(200):
print 'i=', i
sane.init()
webcam = sane.open('v4l:/dev/video0')
grabImage(webcam)
webcam.close()
sane.exit()
time.sleep(1)
----------------------code end-------------------

---------------------output--------------------
i=0
i=1
i=2
.....


i= 182
i= 183
i= 184
i= 185
Traceback (most recent call last):
File "testSane.py", line 17, in ?
grabImage(webcam)
File "testSane.py", line 7, in grabImage
_webcam.start()
File "/usr/lib/python2.4/site-packages/sane.py", line 201, in start
return self.dev.start()
_sane.error: Error during device I/O
 
Reply With Quote
 
 
 
 
JW
Guest
Posts: n/a
 
      03-01-2006
Every time, or just this run?

 
Reply With Quote
 
 
 
 
none
Guest
Posts: n/a
 
      03-01-2006
JW wrote:
> Every time, or just this run?
>

every time
 
Reply With Quote
 
JW
Guest
Posts: n/a
 
      03-02-2006
Sorry, I can't help much with the issue. You are getting a low-level
hardware fault, and
not much information is being propagated up throught the system. It's
not a Python problem, but something with SANE, and the Python wrapper
is just propagating the SANE error to you. I have a few suggestions:

- Use a try block, and see if you can recover:

try:
grabImage(webcam)
except _sane.Error, se:
print se
# but continue

See if all you get is errors, or if it's just a once-in-a-while thing.
Maybe you should sleep longer when you get an error, to give the system
a chance to do something else.

- Try to figure out if SANE is printing any logging message. Check the
kernel log (dmesg), the normal system log, read SANE man pages, etc.
- Read the sane-v4l man page. The one I found on the Internet says it
is Alpha software, which means it is highly experimental, but maybe it
has improved.
- Try a similar task using the native sane tools (sane-find-scanner,
scanimage, etc.). This may generate more useful error messages.
- Post a question to the SANE mailing lists:
http://www.sane-project.org/mailing-lists.html

Once you have a happy SANE setup, then it should be trivial modify the
Python code to do the same thing. Hope this is some help,
JW

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [SI] Reminder, Looking Up/Looking Down is due March 17th. Tony Cooper Digital Photography 9 03-17-2013 05:03 AM
Re: [SI] Reminder, Looking Up/Looking Down is due March 17th. Robert Coe Digital Photography 2 03-15-2013 01:42 AM
Re: [SI] Reminder, Looking Up/Looking Down is due March 17th. Rob Digital Photography 2 03-15-2013 01:36 AM
Re: [SI] Reminder, Looking Up/Looking Down is due March 17th. Robert Coe Digital Photography 0 03-14-2013 01:35 AM
Looking for a Ruby Programmer Looking for a Fun Project. ;) Mark Ruby 9 03-10-2006 08:11 PM



Advertisments