Problems with Python highui lib

View: New views
3 Messages — Rating Filter:   Alert me  

Problems with Python highui lib

by hds :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi There,

sorry if i am too blind to find the info myself, but:
i'm playing around here with the highgui lib. basically i just want to
make a capture from a cam every few seconds.

now i have some basic code:

from opencv.cv import *
from opencv.highgui import *
camport = 1
imgcounter = 0
while True:
    imgcounter +=1
    cam = cvCreateCameraCapture( camport )
    cvSetCaptureProperty(cam,CV_CAP_PROP_FRAME_WIDTH,640)
    cvSetCaptureProperty(cam,CV_CAP_PROP_FRAME_HEIGHT,480)
    cvNamedWindow( "result", 1 );
    frame = cvQueryFrame ( cam )
    if ( cam and frame):
        cvSaveImage (
"/home/aland/LittleDemo/images/testimageimage"+str(imgcounter)+".jpg",
frame)
    frame = None
    cam = None
    print "wrote image "+str(imgcounter)

but it spits out a VIDIOC_QBUF error 16, Device or resource busy

after the first capture.
I want to embed this in a piece of larger code, where i originally
didn't do the cam=None, frame=None business at the end, but always got
the same pic from the cam, or some place in memory.

I'd be thankful for any help, maybe some useful links or something.

Cheers,

Julian



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Opencvlibrary-devel mailing list
Opencvlibrary-devel@...
https://lists.sourceforge.net/lists/listinfo/opencvlibrary-devel

Re: Problems with Python highui lib

by hds :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi there,

Julian Finn schrieb:
> Hi There,
>
> sorry if i am too blind to find the info myself, but:
> i'm playing around here with the highgui lib. basically i just want to
> make a capture from a cam every few seconds.
>  

i found out some little errors but the main problem seems to be, that I
get a segmentation fault as i use cvQueryFrame with alternating cameras.
a short snap of what it looks like atm (embedded in a class, so please
excuse all the complication): http://pastebin.com/m3dfe1afa
thanks so much for help,

Julian


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Opencvlibrary-devel mailing list
Opencvlibrary-devel@...
https://lists.sourceforge.net/lists/listinfo/opencvlibrary-devel

Re: Problems with Python highui lib

by Nils Hasler-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Julian,

2008/6/9 Julian Finn <julian@...>:
> while True:
>    imgcounter +=1
>    cam = cvCreateCameraCapture( camport )
>    cvSetCaptureProperty(cam,CV_CAP_PROP_FRAME_WIDTH,640)
>    cvSetCaptureProperty(cam,CV_CAP_PROP_FRAME_HEIGHT,480)
>    cvNamedWindow( "result", 1 );
>    frame = cvQueryFrame ( cam )

> but it spits out a VIDIOC_QBUF error 16, Device or resource busy
>
> after the first capture.

that's probably because you reopen the camera for every capture but
don't close it in between...

try moving
   cam = cvCreateCameraCapture( camport )
before the loop.

cheers,
nils

--
Max-Planck-Institut Informatik
Campus E1 4, D-66123 Saarbrücken
Phone: +49 681 9325-420
www.mpi-inf.mpg.de/~hasler

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Opencvlibrary-devel mailing list
Opencvlibrary-devel@...
https://lists.sourceforge.net/lists/listinfo/opencvlibrary-devel