looking for help about python-sane

Discussion in 'Python' started by derek, Feb 28, 2006.

  1. derek

    derek Guest

    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
     
    derek, Feb 28, 2006
    #1
    1. Advertising

  2. derek

    JW Guest

    Every time, or just this run?
     
    JW, Mar 1, 2006
    #2
    1. Advertising

  3. derek

    none Guest

    JW wrote:
    > Every time, or just this run?
    >

    every time
     
    none, Mar 1, 2006
    #3
  4. derek

    JW Guest

    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
     
    JW, Mar 2, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jack Jansen
    Replies:
    0
    Views:
    305
    Jack Jansen
    Sep 16, 2004
  2. GMane Python

    python sane imaging

    GMane Python, Dec 28, 2004, in forum: Python
    Replies:
    0
    Views:
    376
    GMane Python
    Dec 28, 2004
  3. Fredrik Lundh

    Re: python sane imaging

    Fredrik Lundh, Dec 28, 2004, in forum: Python
    Replies:
    0
    Views:
    455
    Fredrik Lundh
    Dec 28, 2004
  4. Rene Pijlman
    Replies:
    1
    Views:
    458
    Claudio Grondi
    Feb 24, 2006
  5. dwelch
    Replies:
    1
    Views:
    512
    Lonnie Princehouse
    Mar 29, 2006
Loading...

Share This Page