GNOME Bugzilla – Bug 730510
facedetect: improve performance
Last modified: 2014-09-05 07:38:52 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
Created attachment 277662 [details] [review] updated patch added a property to control minimun standard deviation
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?
Created attachment 281537 [details] [review] updated patch
similar improvements could be added to other elements too, for example motioncells
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.
> + 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.
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?
ping
min-stddev seems ok to me... Thiago?
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.
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..
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