After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 788567 - opencv: Add support for blurring portion of image
opencv: Add support for blurring portion of image
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal enhancement
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-10-05 17:30 UTC by Michał Górny
Modified: 2017-10-16 09:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-opencv-Support-smoothing-only-part-of-the-image.patch (6.76 KB, patch)
2017-10-09 16:15 UTC, Michał Górny
none Details | Review
0001-opencv-Support-smoothing-only-part-of-the-image.patch (v2) (6.51 KB, patch)
2017-10-11 19:47 UTC, Michał Górny
none Details | Review
0001-opencv-Add-kernel-prefix-to-width-height.patch (5.77 KB, patch)
2017-10-11 20:16 UTC, Michał Górny
committed Details | Review
0002-opencv-Support-smoothing-only-part-of-the-image.patch (6.61 KB, patch)
2017-10-11 20:16 UTC, Michał Górny
committed Details | Review

Description Michał Górny 2017-10-05 17:30:28 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.
Comment 1 Michał Górny 2017-10-09 16:15:22 UTC
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
Comment 2 Thibault Saunier 2017-10-11 15:22:35 UTC
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
Comment 3 Michał Górny 2017-10-11 19:47:52 UTC
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')
Comment 4 Michał Górny 2017-10-11 20:16:11 UTC
Created attachment 361366 [details] [review]
0001-opencv-Add-kernel-prefix-to-width-height.patch
Comment 5 Michał Górny 2017-10-11 20:16:58 UTC
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.
Comment 6 Thibault Saunier 2017-10-16 09:13:28 UTC
Thanks!
Comment 7 Thibault Saunier 2017-10-16 09:14:29 UTC
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