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 730510 - facedetect: improve performance
facedetect: improve performance
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.x
Other Linux
: Normal enhancement
: 1.5.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-05-21 11:52 UTC by Nicola
Modified: 2014-09-05 07:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proof of concept patch (1.36 KB, patch)
2014-05-21 11:52 UTC, Nicola
none Details | Review
updated patch (4.44 KB, patch)
2014-06-01 08:37 UTC, Nicola
reviewed Details | Review
updated patch (4.48 KB, patch)
2014-07-23 22:41 UTC, Nicola
reviewed Details | Review
updated patch (4.62 KB, patch)
2014-09-05 06:56 UTC, Nicola
committed Details | Review

Description Nicola 2014-05-21 11:52:54 UTC
Created attachment 276930 [details] [review]
proof of concept patch

this is a proof of concept patch, basically I noted that if I have a completly black image facedetect use more cpu than for a normal image, 

this patch calculate the standard deviation and perform facedetection only if that deviation is > 20 (hardcoded for now),

what do you think about? If I add a property to control the deviation value will this be accepted? Probably this apply to other opencv elements too
Comment 1 Nicola 2014-06-01 08:37:13 UTC
Created attachment 277662 [details] [review]
updated patch

added a property to control minimun standard deviation
Comment 2 Stefan Sauer (gstreamer, gtkdoc dev) 2014-07-23 20:11:04 UTC
Review of attachment 277662 [details] [review]:

Sounds like a good idea and it is not a lot of code. Maybe change the comment a bit. It would not only save CPU on black images, but on image with very little change in general.

::: ext/opencv/gstfacedetect.c
@@ +542,3 @@
+  } else {
+    GST_LOG_OBJECT (filter,
+        "Calculated stddev %f lesser than min_stddev %" G_GINT32_FORMAT

%lf as img_stddev is a double?
Comment 3 Nicola 2014-07-23 22:41:39 UTC
Created attachment 281537 [details] [review]
updated patch
Comment 4 Nicola 2014-07-23 22:42:24 UTC
similar improvements could be added to other elements too, for example motioncells
Comment 5 Nicolas Dufresne (ndufresne) 2014-07-24 13:15:55 UTC
Review of attachment 281537 [details] [review]:

I think it would be nicer with a better property name. Dev is way too commonly used for device.
Comment 6 Tim-Philipp Müller 2014-07-24 13:33:08 UTC
> +    GST_LOG_OBJECT (filter,
> +        "Calculated stddev %f lesser than min_stddev %" G_GINT32_FORMAT
> 
> %lf as img_stddev is a double?

This is not required, since floats are automatically promoted to doubles in vararg functions.

Just like "%" G_GINT32_FORMAT is not really needed, you can just use "%d" since the gint32 would be promoted to a normal int in any case here.
Comment 7 Nicola 2014-07-24 13:40:16 UTC
ok so %f and %d for format,

for the name what do you suggest instead of min-stddev?

- min-deviation
- min-image-change
- min-average-deviation

other ideas?
Comment 8 Nicola 2014-09-03 22:35:44 UTC
ping
Comment 9 Sebastian Dröge (slomo) 2014-09-04 08:20:46 UTC
min-stddev seems ok to me... Thiago?
Comment 10 Sebastian Dröge (slomo) 2014-09-04 08:22:11 UTC
Comment on attachment 281537 [details] [review]
updated patch

As Tim said you can use %f instead of %lf here but it doesn't really matter. But instead of G_GINT32_FORMAT please just use %d.
Comment 11 Nicola 2014-09-05 06:56:49 UTC
Created attachment 285452 [details] [review]
updated patch

patch rebased and updated as per comments.

For my info when G_*_FORMAT are supposed to be used? I have a lot of code that use them instead of %d ecc.. I thought that for portability reasons was better to use glib format instead of %d ecc..
Comment 12 Sebastian Dröge (slomo) 2014-09-05 07:38:47 UTC
commit 3a0a4a8d700b7c719c72e9a7b6bfc6eef72304d7
Author: Nicola Murino <nicola.murino@gmail.com>
Date:   Fri Sep 5 08:51:30 2014 +0200

    facedetect: Add new property min-stddev
    
    face detection will be performed only if image standard deviation is
    greater that min-stddev. Default min-stddev is 0 for backward
    compatibility. This property will avoid to perform face detection on
    images with little changes improving cpu usage and reducing false
    positives
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730510