trouble displaying image data from pyvision in standard openCV

51 views
Skip to first unread message

alegra

unread,
Nov 2, 2010, 8:52:36 AM11/2/10
to pyvision
hello,

I am using pyvision to do face detection (it seems faster than
standard openCV), but I would like to use the openCV gui rather than
wx. However, when trying to convert the captured image, I get
distorted images.

What I do is the following:

im = self.webcam.query()
frame = cvCreateImage(im.size, IPL_DEPTH_8U, 3)
cvShowImage('Camera', frame)

This results in a very flickering image with the wrong colours.

I have also tried using "cvim = im.asOpenCV()", but this does not seem
to lead to an IplImage format that can be used with cvShowImage.

Any help or suggestions would be appreciated.

Regards.

David Bolme

unread,
Nov 3, 2010, 3:26:26 PM11/3/10
to pyvi...@googlegroups.com
I am not sure if the issue is with the webcam or high gui.  Webcam import is done through opencv so if there may be a format or driver problem with the webcam.  If that is the issue please send me a bug report including info on your operating system, camera model, and drivers so that I can keep track of these issues. I am afraid there is not much I can do to help you debug that problem.  You may check the OpenCV website or other forums to see if your configuration is supported or if other people are having similar problems.

As for the display, Steve O'Hara has made some recent modifications to Image.show to display images using opencv highgui.  You can get these modifications from subversion.  It works very well and can display animations as they are computed. You might take a look at his code in this file.  It works fine on Mac and Linux.  It looks like cv.NamedWindow("myName") and cv.WaitKey(1) are important.  


    def show(self, window="PyVisionImage", pos=None, delay=1):
        '''
        Displays the annotated version of the image using OpenCV highgui
        @param window: the name of the highgui window to use, this should
            already have been created using cv.NamedWindow or set newWindow=True
        @param pos: If newWindow, then pos is the (x,y) coordinate for the new window 
        @param delay: A delay in milliseconds to wait for keyboard input (passed to cv.WaitKey).  
            0 delays indefinatly, 1 is good for live updates and animations.  The window
            will disappear after the program exits.  
        '''
        cv.NamedWindow(window)
        
        if pos != None:
            cv.MoveWindow(window, pos[0], pos[1])
            
        x = pyvision.Image(self.asAnnotated())        
        cv.ShowImage(window, x.asOpenCV() )
        cv.WaitKey(delay=delay)
        del x

alegra

unread,
Nov 5, 2010, 11:01:52 AM11/5/10
to pyvision

Thanks for your response. I have found a workaround by treating the
image as a PIL first and then converting it to an IPL image that
Opencv can use in cvShowImage. Which is essentially the same as what
happens in the pyvision code, I believe.

Regards.



On Nov 3, 7:26 pm, David Bolme <dbo...@gmail.com> wrote:
> I am not sure if the issue is with the webcam or high gui.  Webcam import is done through opencv so if there may be a format or driver problem with the webcam.  If that is the issue please send me a bug report including info on your operating system, camera model, and drivers so that I can keep track of these issues. I am afraid there is not much I can do to help you debug that problem.  You may check the OpenCV website or other forums to see if your configuration is supported or if other people are having similar problems.
>
> As for the display, Steve O'Hara has made some recent modifications to Image.show to display images using opencv highgui.  You can get these modifications from subversion.  It works very well and can display animations as they are computed. You might take a look at his code in this file.  It works fine on Mac and Linux.  It looks like cv.NamedWindow("myName") and cv.WaitKey(1) are important.  
>
> https://pyvision.svn.sourceforge.net/svnroot/pyvision/trunk/src/pyvis...
Reply all
Reply to author
Forward
0 new messages