How to draw a rectangle onto an ximagesink?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to draw a rectangle onto an ximagesink?

Nieto, Noe M

Hi everybody,

 

I am writing an application where the user should be able to draw (with the mouse) a rectangle on a playing video window (for now it is an ximagesink).

 

I try the following but I see nothing drawing on the screen…

### CONFIGURE PIPELINE TO CATCH SYNC MESSAGES

bus = self.Pipeline.get_bus()

bus.add_signal_watch()

bus.enable_sync_message_emission()

bus.connect('message', self.on_message)

bus.connect('sync-message::element', self.on_sync_message)

 

 

#############

## Tell ximagesink to draw into the draw area that I give it, not in it’s own …

    def on_sync_message(self, bus, message):

      if message.structure is None:

            return

      message_name = message.structure.get_name()

      if message_name == "prepare-xwindow-id":

            imagesink = message.src

            imagesink.set_property("force-aspect-ratio", True)

            imagesink.set_xwindow_id(self.DrawingArea.window.xid)

 

#############

## Now, on the expose event of the drawing area, paint the rectangle according to user input (mouse)

#############

    def on_DrawingAreaCamera_expose_event(self,widget,event):

        #if self.area_selection_now is True:

        context = widget.window.cairo_create()

        #widget.window.draw(context)

        context.rectangle(self.area_selection)

        context.set_source_rgb(1,0,0)

        context.stroke()

 

 

What is the right way to interact with ximagesink, so I can also draw things on it’s drawable??

 

Regards

 


-------------------------------------------------------------------------
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
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to draw a rectangle onto an ximagesink?

Stefan Sauer
hi,

Nieto, Noe M schrieb:
> Hi everybody,
>
>  
>
> I am writing an application where the user should be able to draw (with
> the mouse) a rectangle on a playing video window (for now it is an
> ximagesink).

Thats not so easy. Curretly xvimagesink does autofill-colorkey. That is it fills
the drawable with the colorkey so that you see the video. Please file an
enhancement request, so that xvimagesink supports a property to turn off
autofill and another to tell you about the colorkey. Then you can fill the
drawable yourself with the colorkey and paint your rectangle in a different
color over it. The video will be seen where the colorkey is visible.

Stefan

>
>  
>
> I try the following but I see nothing drawing on the screen…
>
> ### CONFIGURE PIPELINE TO CATCH SYNC MESSAGES
>
> bus = self.Pipeline.get_bus()
>
> bus.add_signal_watch()
>
> bus.enable_sync_message_emission()
>
> bus.connect('message', self.on_message)
>
> bus.connect('sync-message::element', self.on_sync_message)
>
>  
>
>  
>
> #############
>
> ## Tell ximagesink to draw into the draw area that I give it, not in
> it’s own …
>
>     def on_sync_message(self, bus, message):
>
>       if message.structure is None:
>
>             return
>
>       message_name = message.structure.get_name()
>
>       if message_name == "prepare-xwindow-id":
>
>             imagesink = message.src
>
>             imagesink.set_property("force-aspect-ratio", True)
>
>             imagesink.set_xwindow_id(self.DrawingArea.window.xid)
>
>  
>
> #############
>
> ## Now, on the expose event of the drawing area, paint the rectangle
> according to user input (mouse)
>
> #############
>
>     def on_DrawingAreaCamera_expose_event(self,widget,event):
>
>         #if self.area_selection_now is True:
>
>         context = widget.window.cairo_create()
>
>         #widget.window.draw(context)
>
>         context.rectangle(self.area_selection)
>
>         context.set_source_rgb(1,0,0)
>
>         context.stroke()
>
>  
>
>  
>
> What is the right way to interact with ximagesink, so I can also draw
> things on it’s drawable??
>
>  
>
> Regards
>
>  
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> 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
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


-------------------------------------------------------------------------
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
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel