GNOME Bugzilla – Bug 788567
opencv: Add support for blurring portion of image
Last modified: 2017-10-16 09:14:29 UTC
We have to filter a large number of videos and blur a specific (rectangular) area of the clip. We'd like to use pitivi+gstreamer for that task. However, it doesn't seem to have an efficient and convenient way of doing that at the moment. After talking to pitivi developers, we've established that probably the best way of achieving this would be through extending the recently added opencv plugin. I'm going to attempt to write support for specifying a region of the image to the gstcvsmooth plugin.
Created attachment 361195 [details] [review] 0001-opencv-Support-smoothing-only-part-of-the-image.patch Here's my initial patch. To my surprise, it works ;-). It adds four new properties: position-x, position-y, size-x, size-y (names stolen from frei0r alphaspot plugin). They are all double in range 0..1 to easily account for different image sizes, with 1.0 corresponding to the image width/height. For example, to blur a square in the middle of the image, you'd set: position-x = 0.25 position-y = 0.25 size-x = 0.5 size-y = 0.5
Review of attachment 361195 [details] [review]: It looks generally good, but I think we should rather have absolute values instead of relative to the frame size, for precision and because it is what we usually do, have a look at GstCompositorPad, although in gdkpixbufoverlay we have a switch to let users use relative values for the positioning, not the size though. I think we could merge with relative values for x/y if you rename so that we can extend the API later and have it similar to other ones (ie gdkpixbufoverlay). ::: ext/opencv/gstcvsmooth.h @@ -76,0 +76,6 @@ + + /* coordinates to apply the effect to, 0..1 relative to image size */ + gdouble positionx; ... 3 more ... Those should be called width/height to follow usual GStreamer namings
Created attachment 361364 [details] [review] 0001-opencv-Support-smoothing-only-part-of-the-image.patch (v2) Here's a partially updated patch. I've made it work using absolute values with G_MAXINT limit as suggested. I haven't updated the names yet since 'width' and 'height' are taken for kernel size. Do you have a suggestion on how to proceed here? (i.e. use other names for my vars, e.g. 'area-width', or rename the kernel to 'kernel-width')
Created attachment 361366 [details] [review] 0001-opencv-Add-kernel-prefix-to-width-height.patch
Created attachment 361367 [details] [review] 0002-opencv-Support-smoothing-only-part-of-the-image.patch And here's an updated version with the renames, and the other patch to rename kernel size as suggested.
Thanks!
commit a8889bdcbc70f459a893fc8d7140e627489abd2a Author: Michał Górny <mgorny@gentoo.org> Date: Mon Oct 9 18:08:47 2017 +0200 opencv: Support smoothing only part of the image https://bugzilla.gnome.org/show_bug.cgi?id=788567 commit 798d899a25e26c4a73f1c33d480b5a3f70b1507c Author: Michał Górny <mgorny@gentoo.org> Date: Wed Oct 11 22:03:24 2017 +0200 opencv: Add 'kernel' prefix to width/height Rename width to kernel-width, and height to kernel-height to avoid ambiguity in the name. https://bugzilla.gnome.org/show_bug.cgi?id=788567