Re: webcam (usb) access under Ubuntu

2008-05-23 Thread ticapix
On 16 avr, 09:41, Berco Beute <[EMAIL PROTECTED]> wrote:
> On Apr 15, 11:45 pm, Berco Beute <[EMAIL PROTECTED]> wrote:
>
> > I've tried reinstalling gstreamer (for windows):
>
> >http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre..
>
> > but that didn't help. I get some complaints about 'libgstinterfaces'
> > as well...
>
> To be more precise, when doing an 'import gst' Python shell pops up an
> error dialog saying:
>
> "This application has failed to start because
> libgstinterfaces-0.10.dll was not found."
>
> 2B

You need to install gst-plugins-good too

--
pierre
--
http://mail.python.org/mailman/listinfo/python-list


Re: webcam (usb) access under Ubuntu

2008-04-17 Thread Berco Beute
On Apr 16, 2:26 pm, yoz <[EMAIL PROTECTED]> wrote:
> Berco Beute wrote:
> > I've been trying to access my webcam using Python, but I failed
> > miserably. The camera works fine under Ubuntu (using camora and
> > skype), but I am unable to get WebCamSpy or libfg to access my webcam.
>
> > First I tried webcamspy (http://webcamspy.sourceforge.net/). That
> > requires pySerial and pyParallel, and optionally pyI2C. Runing
> > WebCamSpy results in:
>
> > Exception exceptions.AttributeError: "Parallel instance has no
> > attribute '_fd'" in  > > ignored
>
> > This seems to come from importing I2C. The application window opens,
> > but there's an error message:
>
> > NO VIDEO SOURCE FOUND
>
> > Next I tried libfg (http://antonym.org/libfg). I built it, made the
> > Python bindings and installed it. Unfortunately the following:
>
>  import fg
>  grabber = fg.Grabber()
>
> > results in:
>
> > fg_open(): open video device failed: No such file or directory
>
> > Since the camera works fine in Ubuntu itself my guess is that the
> > problem is with the python libraries (or even likelier, my usage of
> > them). Is there anybody here that was successful in accessing their
> > webcam on linux using Python? Else I have to reside to Windows and
> > VideoCapture (which relies on the win32 api and thus is Windows-only),
> > something I'd rather not do.
>
> > Thanks for any help,
> > 2B
>
> > ===
> > I am uUsing:
> > WebCam: Logitech QuickCam Pro 400
> > Ubuntu
> > Python 2.5
>
> Some time ago I was playing with writing a webcam server under Linux
> using V4L - I found this bit of code which may help (it works for me).
> Obviously it needs X running to work and the associated libs installed.
> Note this is not my code but it was a good starting point for me to work
> from. I can't find a link to the original article but credit to the author.
>
> import pygame
> import Image
> from pygame.locals import *
> import sys
>
> import opencv
> #this is important for capturing/displaying images
> from opencv import highgui
>
> camera = highgui.cvCreateCameraCapture(0)
> def get_image():
>  im = highgui.cvQueryFrame(camera)
>  #convert Ipl image to PIL image
>  return opencv.adaptors.Ipl2PIL(im)
>
> fps = 30.0
> pygame.init()
> window = pygame.display.set_mode((320,240))
> pygame.display.set_caption("WebCam Demo")
> screen = pygame.display.get_surface()
>
> while True:
>  events = pygame.event.get()
>  for event in events:
>  if event.type == QUIT or event.type == KEYDOWN:
>  sys.exit(0)
>  im = get_image()
>  pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode)
>  screen.blit(pg_img, (0,0))
>  pygame.display.flip()
>  pygame.time.delay(int(1000 * 1.0/fps))
>
> Best of Luck
> Bgeddy

Thank you! That seems to work under both Linux and windows. The opencv
library is the clue here. I've used the ctypes wrapper for opencv
provided by the first link below, but there are more options.

For future reference here are some relevant links:

http://wwwx.cs.unc.edu/~gb/wp/blog/2007/02/04/python-opencv-wrapper-using-ctypes/
http://opencvlibrary.sourceforge.net/
http://opencvlibrary.sourceforge.net/NoamLewis
http://opencvlibrary.sourceforge.net/PythonInterface

Windows specific:
http://www.instructables.com/id/Using-openCV-1.0-with-python-2.5-in-Windows-XP/
http://dip.sun.ac.za/3Dvision/talks/OpenCV_in_Python_on_Windows.pps
http://opencvlibrary.sourceforge.net/NoamLewis

Thanks for all the help.

2B
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webcam (usb) access under Ubuntu

2008-04-16 Thread yoz
Berco Beute wrote:
> I've been trying to access my webcam using Python, but I failed
> miserably. The camera works fine under Ubuntu (using camora and
> skype), but I am unable to get WebCamSpy or libfg to access my webcam.
> 
> First I tried webcamspy (http://webcamspy.sourceforge.net/). That
> requires pySerial and pyParallel, and optionally pyI2C. Runing
> WebCamSpy results in:
> 
> Exception exceptions.AttributeError: "Parallel instance has no
> attribute '_fd'" in  > ignored
> 
> This seems to come from importing I2C. The application window opens,
> but there's an error message:
> 
> NO VIDEO SOURCE FOUND
> 
> Next I tried libfg (http://antonym.org/libfg). I built it, made the
> Python bindings and installed it. Unfortunately the following:
> 
 import fg
 grabber = fg.Grabber()
> 
> results in:
> 
> fg_open(): open video device failed: No such file or directory
> 
> Since the camera works fine in Ubuntu itself my guess is that the
> problem is with the python libraries (or even likelier, my usage of
> them). Is there anybody here that was successful in accessing their
> webcam on linux using Python? Else I have to reside to Windows and
> VideoCapture (which relies on the win32 api and thus is Windows-only),
> something I'd rather not do.
> 
> Thanks for any help,
> 2B
> 
> ===
> I am uUsing:
> WebCam: Logitech QuickCam Pro 400
> Ubuntu
> Python 2.5


Some time ago I was playing with writing a webcam server under Linux 
using V4L - I found this bit of code which may help (it works for me). 
Obviously it needs X running to work and the associated libs installed.
Note this is not my code but it was a good starting point for me to work 
from. I can't find a link to the original article but credit to the author.

import pygame
import Image
from pygame.locals import *
import sys

import opencv
#this is important for capturing/displaying images
from opencv import highgui

camera = highgui.cvCreateCameraCapture(0)
def get_image():
 im = highgui.cvQueryFrame(camera)
 #convert Ipl image to PIL image
 return opencv.adaptors.Ipl2PIL(im)

fps = 30.0
pygame.init()
window = pygame.display.set_mode((320,240))
pygame.display.set_caption("WebCam Demo")
screen = pygame.display.get_surface()

while True:
 events = pygame.event.get()
 for event in events:
 if event.type == QUIT or event.type == KEYDOWN:
 sys.exit(0)
 im = get_image()
 pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode)
 screen.blit(pg_img, (0,0))
 pygame.display.flip()
 pygame.time.delay(int(1000 * 1.0/fps))


Best of Luck
Bgeddy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webcam (usb) access under Ubuntu

2008-04-16 Thread Diez B. Roggisch
Berco Beute wrote:

> On Apr 16, 12:19 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
>> Maybe if you are now using windows, there are better options - but I'm a
>> *nix-boy :)
>>
>> Diez
> 
> So am I :), but the application I'm writing has to run on *that other
> operating system from the 90's*.
> I'm trying hard not to implement the application in C#/.Net, but I'm
> running out of open source alternatives. VideoCapture *almost* worked
> and now I'm stranded at the gstreamer road as well...

How's that saying? "If your in Rom, do as the Romans do". Don't fight
Windows. And take IronPython to mitigate the pain of using it :)

Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webcam (usb) access under Ubuntu

2008-04-16 Thread Berco Beute
On Apr 16, 12:19 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Maybe if you are now using windows, there are better options - but I'm a
> *nix-boy :)
>
> Diez

So am I :), but the application I'm writing has to run on *that other
operating system from the 90's*.
I'm trying hard not to implement the application in C#/.Net, but I'm
running out of open source alternatives. VideoCapture *almost* worked
and now I'm stranded at the gstreamer road as well...

2B
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webcam (usb) access under Ubuntu

2008-04-16 Thread Diez B. Roggisch
Berco Beute wrote:

> On Apr 15, 11:45 pm, Berco Beute <[EMAIL PROTECTED]> wrote:
>> I've tried reinstalling gstreamer (for windows):
>>
>>
http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre...http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre...
>>
>> but that didn't help. I get some complaints about 'libgstinterfaces'
>> as well...
> 
> To be more precise, when doing an 'import gst' Python shell pops up an
> error dialog saying:
> 
> "This application has failed to start because
> libgstinterfaces-0.10.dll was not found."

I'm sorry, but I really can't comment on gst-installion issues - that all
worked for me because of ubuntu.

Maybe if you are now using windows, there are better options - but I'm a
*nix-boy :)

Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webcam (usb) access under Ubuntu

2008-04-16 Thread Berco Beute
On Apr 15, 11:45 pm, Berco Beute <[EMAIL PROTECTED]> wrote:
> I've tried reinstalling gstreamer (for windows):
>
> http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre...http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre...
>
> but that didn't help. I get some complaints about 'libgstinterfaces'
> as well...

To be more precise, when doing an 'import gst' Python shell pops up an
error dialog saying:

"This application has failed to start because
libgstinterfaces-0.10.dll was not found."

2B

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webcam (usb) access under Ubuntu

2008-04-15 Thread Berco Beute
On Apr 15, 11:18 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Berco Beute schrieb:
>
> > Thanks, that would be great.
>
> Here you go.
>
> http://roggisch.de/vidio.tgz
>
> Diez

Wonderful! Thank you very much!
I'm running out of time, but after installing the necessary goodies
using the nice package from here:
http://aruiz.typepad.com/siliconisland/2006/12/allinone_win32_.html

In the meantime I've switched to windows. I'm running into the problem
that 'import gst' throws:

===
>>> import gst
Traceback (most recent call last):
  File "", line 1, in 
  File "H:\Python25\lib\site-packages\gst-0.10\gst\__init__.py", line
87, in 
from _gst import *
ImportError: DLL load failed: The specified module could not be found.

===

I've tried reinstalling gstreamer (for windows):

http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstreamer-0.10.17.setup.zip
http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstreamer-0.10.17.win32.zip

but that didn't help. I get some complaints about 'libgstinterfaces'
as well... I'm too unfamiliar with these libraries to have a clue
what's wrong here...

I'll look into it some more tomorrow.

2B
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webcam (usb) access under Ubuntu

2008-04-15 Thread Diez B. Roggisch
Berco Beute schrieb:
> Thanks, that would be great.

Here you go.

http://roggisch.de/vidio.tgz

Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webcam (usb) access under Ubuntu

2008-04-15 Thread Laurent Pointal
Le Tue, 15 Apr 2008 05:21:54 -0700, Berco Beute a écrit :

> I've been trying to access my webcam using Python, but I failed
> miserably. The camera works fine under Ubuntu (using camora and skype),
> but I am unable to get WebCamSpy or libfg to access my webcam.
> 
> First I tried webcamspy (http://webcamspy.sourceforge.net/). That
> requires pySerial and pyParallel, and optionally pyI2C. Runing WebCamSpy
> results in:
> 
> Exception exceptions.AttributeError: "Parallel instance has no attribute
> '_fd'" in  > ignored
> 
> This seems to come from importing I2C. The application window opens, but
> there's an error message:
> 
> NO VIDEO SOURCE FOUND
> 
> Next I tried libfg (http://antonym.org/libfg). I built it, made the
> Python bindings and installed it. Unfortunately the following:
> 
import fg
grabber = fg.Grabber()
> 
> results in:
> 
> fg_open(): open video device failed: No such file or directory
> 
> Since the camera works fine in Ubuntu itself my guess is that the
> problem is with the python libraries (or even likelier, my usage of
> them). Is there anybody here that was successful in accessing their
> webcam on linux using Python? Else I have to reside to Windows and
> VideoCapture (which relies on the win32 api and thus is Windows-only),
> something I'd rather not do.
> 
> Thanks for any help,

I dont know if this resolve your problem, but to get snapshots from a 
camera under linux, using V4L2 API, I wrote a small wrapper around this 
API.
Its called pyvideograb, and its here:
http://laurent.pointal.org/python/projets/pyvideograb/index.pih

Note: there is no automatic thing in this library, just a wrapper to 
V4L2, so you must know what options and image format your camera support 
and use these (you may have to convert image by yourself - see PIL and 
Numpy for quick data processing functions). To find the supported options 
you can use xawtv and give it ad-hoc cli option to make it verbose.

A+

Laurent.

-- 
Laurent POINTAL - [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: webcam (usb) access under Ubuntu

2008-04-15 Thread Diez B. Roggisch
Berco Beute wrote:

> Thanks, that would be great.
> 
> While I'm at it I wondering how to display a video preview. Here's
> someone using VideoCapture (the win32 lib) and PyGame, but I'd rather
> use a GUI framework and preview/capture videos directly.

gstreamer has a preview window.

Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webcam (usb) access under Ubuntu

2008-04-15 Thread Berco Beute
Thanks, that would be great.

While I'm at it I wondering how to display a video preview. Here's
someone using VideoCapture (the win32 lib) and PyGame, but I'd rather
use a GUI framework and preview/capture videos directly.

2B


> It has been *ages* since I did this - so take it with a grain of salt.
> However, back then I was able to access a video camera using gqcam. Looking
> into the source of that revealed that all it did were some simple
> ioctl-calls and reading from a /dev/video*-device.
>
> That did the trick for me...
>
> Additionally, you might consider using gstreamer + the python bindings for
> that. I was also successful using them - if I remember this conversation
> tonight or so, I'll send you the sources.
>
> Diez
>
> Diez

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webcam (usb) access under Ubuntu

2008-04-15 Thread Diez B. Roggisch
Berco Beute wrote:

> I've been trying to access my webcam using Python, but I failed
> miserably. The camera works fine under Ubuntu (using camora and
> skype), but I am unable to get WebCamSpy or libfg to access my webcam.
> 
> First I tried webcamspy (http://webcamspy.sourceforge.net/). That
> requires pySerial and pyParallel, and optionally pyI2C. Runing
> WebCamSpy results in:
> 
> Exception exceptions.AttributeError: "Parallel instance has no
> attribute '_fd'" in  > ignored
> 
> This seems to come from importing I2C. The application window opens,
> but there's an error message:
> 
> NO VIDEO SOURCE FOUND
> 
> Next I tried libfg (http://antonym.org/libfg). I built it, made the
> Python bindings and installed it. Unfortunately the following:
> 
import fg
grabber = fg.Grabber()
> 
> results in:
> 
> fg_open(): open video device failed: No such file or directory
> 
> Since the camera works fine in Ubuntu itself my guess is that the
> problem is with the python libraries (or even likelier, my usage of
> them). Is there anybody here that was successful in accessing their
> webcam on linux using Python? Else I have to reside to Windows and
> VideoCapture (which relies on the win32 api and thus is Windows-only),
> something I'd rather not do.

It has been *ages* since I did this - so take it with a grain of salt.
However, back then I was able to access a video camera using gqcam. Looking
into the source of that revealed that all it did were some simple
ioctl-calls and reading from a /dev/video*-device.

That did the trick for me...

Additionally, you might consider using gstreamer + the python bindings for
that. I was also successful using them - if I remember this conversation
tonight or so, I'll send you the sources.

Diez

Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


webcam (usb) access under Ubuntu

2008-04-15 Thread Berco Beute
I've been trying to access my webcam using Python, but I failed
miserably. The camera works fine under Ubuntu (using camora and
skype), but I am unable to get WebCamSpy or libfg to access my webcam.

First I tried webcamspy (http://webcamspy.sourceforge.net/). That
requires pySerial and pyParallel, and optionally pyI2C. Runing
WebCamSpy results in:

Exception exceptions.AttributeError: "Parallel instance has no
attribute '_fd'" in > ignored

This seems to come from importing I2C. The application window opens,
but there's an error message:

NO VIDEO SOURCE FOUND

Next I tried libfg (http://antonym.org/libfg). I built it, made the
Python bindings and installed it. Unfortunately the following:

>>>import fg
>>>grabber = fg.Grabber()

results in:

fg_open(): open video device failed: No such file or directory

Since the camera works fine in Ubuntu itself my guess is that the
problem is with the python libraries (or even likelier, my usage of
them). Is there anybody here that was successful in accessing their
webcam on linux using Python? Else I have to reside to Windows and
VideoCapture (which relies on the win32 api and thus is Windows-only),
something I'd rather not do.

Thanks for any help,
2B

===
I am uUsing:
WebCam: Logitech QuickCam Pro 400
Ubuntu
Python 2.5
-- 
http://mail.python.org/mailman/listinfo/python-list