Opening an OpenCV window in a gstreamer element

iron_guitarist1987 jtrinidadperez at gmail.com
Thu May 3 07:06:46 PDT 2012


I'm trying to do a very basic Gstreamer element that opens an OpenCV window
with an image.

In my element, I have a chain function that only calls the window-opening
function called select_points(), which is in select_points.cpp.

the chain_function:

    static GstFlowReturn
    gst_georeg_chain (GstPad * pad, GstBuffer * buf)
    {
       GstGeoreg *filter;

       georeg_val gvals;

       filter = GST_GEOREG (GST_OBJECT_PARENT (pad));

       get_data(&gvals);

       select_points(&gvals);

       return gst_pad_push (filter->srcpad, buf);
    }

Now in my select_points.cpp, I have the following code

    #include <stdio.h>
    #include "datasetup.h"
    #include <opencv/cv.h>
    #include <opencv/highgui.h>

    using namespace cv;

    extern "C" void select_points(georeg_val *gvals) //plugin is in C
    {
       IplImage* img=0; 
       img=cvLoadImage(gvals->imageName,1);
       if(!img) 
      {
         printf("Could not load image file: \n$%s$\n",gvals->imageName);
      }
      else
      {        
         printf("Image was loaded\n");
         cvNamedWindow("Select", CV_WINDOW_AUTOSIZE); 

        cvMoveWindow("Select", 200, 200); // offset from the UL corner of
the screen

        cvShowImage("Select",img);

        cvDestroyWindow("Select");
        cvReleaseImage(&img); 

      }

    }
The problem is that when I run the pipeline with my element, it hangs when
calling cvNamedWindow. Any suggestions? Everything else works fine if I
comment out select_points().

--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Opening-an-OpenCV-window-in-a-gstreamer-element-tp4606096.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list