On Jul 12, 7:38 pm, David <da...@pythontoo.com> wrote:
> Sparky wrote:
> > On Jul 12, 4:30 pm, David <da...@pythontoo.com> wrote:
> >> Sparky wrote:
> >>> On Jul 12, 3:50 pm, Sparky <samnspa...@gmail.com> wrote:
> >>>> Hello! I need to stream from a webcam in Linux and I need to be able
> >>>> to analyze the video feed frame by frame with PIL. Currently my web-
> >>>> cam (Quickcam Chat) only seems to work with GStreamer so a solution
> >>>> using pygst would be preferred.
> >>>> Thanks for your help,
> >>>> Sam
> >>> Sorry, to clarify I am just having a hard time capturing frames in a
> >>> way that I can access with PIL.
> >> Most web cams produce jpeg images so read the note at the bottom 
> >> here;http://effbot.org/imagingbook/format-jpeg.htm
> >> What exactly are you trying to do? What have you tried so far and what
> >> happened may help.
>
> >> --
> >> Powered by Gentoo GNU/Linuxhttp://linuxcrazy.com
>
> > Dear David,
>
> > Thank you for your quick response. I have tried a few things. First of
> > all, I have tried gst-launch-0.10 v4l2src ! ffmpegcolorspace !
> > pngenc ! filesink location=foo.png. Foo.png comes out sharp enough but
> > it takes around 2 seconds to complete. I have also tried CVTypes but
> > it does not run without LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so and,
> > when it does run, it only displays colored "snow". Here is that code:
>
> > 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(-1)
> > print "cam:" + str(camera)
> > def get_image():
> >    print "here"
> >    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()
> >    im = get_image()
> >    print im.mode
> >    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))
>
> > Finally, I have gotten pygst to stream video with the example at
> >http://pygstdocs.berlios.de/pygst-tutorial/webcam-viewer.htmlbut of
> > course I do not know how to get a hold of that data. Just so you know,
> > I am trying a primitive type of object tracking. I would use some of
> > the libraries already available but the two more popular
> > implementations on Linux (tbeta/ccv and reacTIVision) dont seem to
> > work with my web cam. I have more info on those non-python attempts at
> >http://ubuntuforums.org/showthread.php?p=7596908. Unfortunately no one
> > seemed to respond to that post.
>
> > Thanks again,
> > Sam
>
> See if this gets you started, I got it working here with a video4linux2 
> cam.http://code.google.com/p/python-video4linux2/
> here is what I have, I think it is the 
> same;http://dwabbott.com/python-video4linux2-read-only/
> let me know how you make out.
> -david
>
> --
> Powered by Gentoo GNU/Linuxhttp://linuxcrazy.com

I gave it a shot and here is what I got:

s...@sam-laptop:~/python-video4linux2-read-only$ ./pyv4l2.py
Available devices:  ['/dev/video0']
        /dev/video0
Capabilities:
        Capture
        ReadWrite
        Streaming
Input 0:
                Name:   zc3xx
                Type:   camera
                Standards: []
Pixel formats:
        JPEG    JPEG
Resolutions:
Segmentation fault

-------------------------------------

s...@sam-laptop:~/python-video4linux2-read-only$ ./streampics.py /dev/
video0 0 BGR3 640 480 testpics
Trying to create directory pics
Recording /dev/video0:0 with format JPEG at (640, 480)
Traceback (most recent call last):
  File "./streampics.py", line 94, in <module>
    Run()
  File "./streampics.py", line 78, in Run
    d.SetupStreaming(5, StreamCallback)
  File "/home/sam/python-video4linux2-read-only/pyv4l2.py", line 682,
in SetupStreaming
    self.StreamOn()
  File "/home/sam/python-video4linux2-read-only/pyv4l2.py", line 636,
in StreamOn
    lib.Error()
Exception: Could not start streaming:   22: Invalid argument
*** glibc detected *** python: free(): invalid next size (fast):
0x0a2aeff0 ***

Any suggestions?

Thanks,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to