Debian Codegraph @

src/filter/facebl0r/facebl0r.cpp

raw symbols SCIP
1 /*
2 * This source code is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Public License as published by
4 * the Free Software Foundation; either version 3 of the License, or
5 * (at your option) any later version.
6 *
7 * This source code is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Please refer
10 * to the GNU Public License for more details.
11 *
12 * You should have received a copy of the GNU Public License along
13 * with this source code; if not, write to: Free Software Foundation,
14 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16
17
18 #include <stdlib.h>
19 #include <stdio.h>
20 #include <string.h>
21 #include <opencv2/opencv.hpp>
22 #include "frei0r.hpp"cxx . . $ `<file>/include/frei0r.hpp`/
23 #include "frei0r/math.h"cxx . . $ `<file>/include/frei0r/math.h`/
24
25 class TrackedObjcxx . . $ TrackedObj# {
26 public:
27 void update_histcxx . . $ TrackedObj#update_hist(49f6e7a06ebc5aa8).();
28 void update_hue_imagecxx . . $ TrackedObj#update_hue_image(37d4cb3831369c97). (const cvcxx . . $ cv/::Matcxx . . $ cv/Mat#& image);
29 cvcxx . . $ cv/::RotatedRectcxx . . $ cv/RotatedRect# camshift_track_facecxx . . $ TrackedObj#camshift_track_face(fe011d747cf16d5e).();
30
31 cvcxx . . $ cv/::Matcxx . . $ cv/Mat# hsvcxx . . $ TrackedObj#hsv.; //input image converted to HSV
32 cvcxx . . $ cv/::Matcxx . . $ cv/Mat# huecxx . . $ TrackedObj#hue.; //hue channel of HSV image
33 cvcxx . . $ cv/::Matcxx . . $ cv/Mat# maskcxx . . $ TrackedObj#mask.; //image for masking pixels
34 cvcxx . . $ cv/::Matcxx . . $ cv/Mat# probcxx . . $ TrackedObj#prob.; //face probability estimates for each pixel
35
36 cvcxx . . $ cv/::Matcxx . . $ cv/Mat# histcxx . . $ TrackedObj#hist.; //histogram of hue in original face image
37 static const int hist_binscxx . . $ TrackedObj#hist_bins.; //number of histogram bins
38 static const float hist_rangecxx . . $ TrackedObj#hist_range.[2]; //histogram range
39
40 cvcxx . . $ cv/::Rectcxx . . $ cv/Rect# prev_rectcxx . . $ TrackedObj#prev_rect.; //location of face in previous frame
41 cvcxx . . $ cv/::RotatedRectcxx . . $ cv/RotatedRect# curr_boxcxx . . $ TrackedObj#curr_box.; //current face location estimate
42 };
43
44 const float TrackedObjcxx . . $ TrackedObj#::hist_rangecxx . . $ TrackedObj#hist_range.[2] = { 0, 180 };
45 const int TrackedObjcxx . . $ TrackedObj#::hist_binscxx . . $ TrackedObj#hist_bins. = 30;
46
47 class FaceBl0rcxx . . $ FaceBl0r#: public frei0rcxx . . $ frei0r/::filtercxx . . $ frei0r/filter# {
48
49 public:
50 FaceBl0rcxx . . $ FaceBl0r#FaceBl0r(3e454b8ccf442868).(int wdt, int hgt);
51 ~cxx . . $ FaceBl0r#`~FaceBl0r`(49f6e7a06ebc5aa8).FaceBl0rcxx . . $ FaceBl0r#() = default;
52
53 void updatecxx . . $ FaceBl0r#update(da7b4a17ceb4e697).(double time,
54 uint32_tcxx . . $ uint32_t#* out,
55 const uint32_tcxx . . $ uint32_t#* in);
56
57 private:
58
59 //trackface
60 stdcxx . . $ std/::vectorcxx . . $ std/vector#<cvcxx . . $ cv/::Rectcxx . . $ cv/Rect#> detect_facecxx . . $ FaceBl0r#detect_face(af1a205b8c6bf75e).();
61
62 TrackedObjcxx . . $ TrackedObj# tracked_objcxx . . $ FaceBl0r#tracked_obj.;
63
64 //used by capture_video_frame, so we don't have to keep creating.
65 cvcxx . . $ cv/::Matcxx . . $ cv/Mat# imagecxx . . $ FaceBl0r#image.;
66
67 cvcxx . . $ cv/::CascadeClassifiercxx . . $ cv/CascadeClassifier# cascadecxx . . $ FaceBl0r#cascade.;
68
69 // plugin parameters
70 stdcxx . . $ std/::stringcxx . . $ std/string# classifiercxx . . $ FaceBl0r#classifier.;
71 bool ellipsecxx . . $ FaceBl0r#ellipse.;
72 double recheckcxx . . $ FaceBl0r#recheck.;
73 double threadscxx . . $ FaceBl0r#threads.;
74 double search_scalecxx . . $ FaceBl0r#search_scale.;
75 double neighborscxx . . $ FaceBl0r#neighbors.;
76 double smallestcxx . . $ FaceBl0r#smallest.;
77 double largestcxx . . $ FaceBl0r#largest.;
78
79 stdcxx . . $ std/::stringcxx . . $ std/string# old_classifiercxx . . $ FaceBl0r#old_classifier.;
80
81 unsigned int face_foundcxx . . $ FaceBl0r#face_found.;
82 unsigned int face_notfoundcxx . . $ FaceBl0r#face_notfound.;
83 };
84
85
86 frei0rcxx . . $ frei0r/::constructcxx . . $ frei0r/construct#<FaceBl0rcxx . . $ FaceBl0r#> plugincxx . . $ plugin.("FaceBl0r"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
87 "automatic face blur"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
88 "ZioKernel, Biilly, Jilt, Jaromil, ddennedy"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
89 1,1, F0R_COLOR_MODEL_BGRA8888cxx . . $ `include/frei0r.h:299:9`!);
90
91 FaceBl0rcxx . . $ FaceBl0r#::FaceBl0rcxx . . $ FaceBl0r#FaceBl0r(3e454b8ccf442868).(int wdt, int hgt) {
92
93 face_foundcxx . . $ FaceBl0r#face_found. = 0;
94
95 classifiercxx . . $ FaceBl0r#classifier. =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml";
96 register_paramcxx . . $ frei0r/fx#register_param(f828b6c35e9835e7).(classifiercxx . . $ FaceBl0r#classifier.,
97 "Classifier"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
98 "Full path to the XML pattern model for recognition; look in /usr/share/opencv/haarcascades"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
99 ellipsecxx . . $ FaceBl0r#ellipse. = false;
100 register_paramcxx . . $ frei0r/fx#register_param(f12007cc47cdd2c7).(ellipsecxx . . $ FaceBl0r#ellipse., "Ellipse"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., "Draw a red ellipse around the object"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
101 recheckcxx . . $ FaceBl0r#recheck. = 0.025;
102 face_notfoundcxx . . $ FaceBl0r#face_notfound. = cvRoundcxx . . $ cvRound(620b9ac44d2573a6).(recheckcxx . . $ FaceBl0r#recheck. * 1000);
103 register_paramcxx . . $ frei0r/fx#register_param(acfd1d4411be0164).(recheckcxx . . $ FaceBl0r#recheck., "Recheck"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., "How often to detect an object in number of frames, divided by 1000"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
104 threadscxx . . $ FaceBl0r#threads. = 0.01; //number of CPUs
105 register_paramcxx . . $ frei0r/fx#register_param(acfd1d4411be0164).(threadscxx . . $ FaceBl0r#threads., "Threads"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., "How many threads to use divided by 100; 0 uses CPU count"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
106 search_scalecxx . . $ FaceBl0r#search_scale. = 0.12; // increase size of search window by 20% on each pass
107 register_paramcxx . . $ frei0r/fx#register_param(acfd1d4411be0164).(search_scalecxx . . $ FaceBl0r#search_scale., "Search scale"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., "The search window scale factor, divided by 10"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
108 neighborscxx . . $ FaceBl0r#neighbors. = 0.02; // require 2 neighbors
109 register_paramcxx . . $ frei0r/fx#register_param(acfd1d4411be0164).(neighborscxx . . $ FaceBl0r#neighbors., "Neighbors"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., "Minimum number of rectangles that makes up an object, divided by 100"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
110 smallestcxx . . $ FaceBl0r#smallest. = 0.0; // smallest window size is trained default
111 register_paramcxx . . $ frei0r/fx#register_param(acfd1d4411be0164).(smallestcxx . . $ FaceBl0r#smallest., "Smallest"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., "Minimum window size in pixels, divided by 1000"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
112 largestcxx . . $ FaceBl0r#largest. = 0.0500; // largest object size shown is 500 px
113 register_paramcxx . . $ frei0r/fx#register_param(acfd1d4411be0164).(largestcxx . . $ FaceBl0r#largest., "Largest"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., "Maximum object size in pixels, divided by 10000"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
114 }
115
116 void FaceBl0rcxx . . $ FaceBl0r#::updatecxx . . $ FaceBl0r#update(da7b4a17ceb4e697).(double time,
117 uint32_tcxx . . $ uint32_t#* out,
118 const uint32_tcxx . . $ uint32_t#* in)
119 {
120 if (cascadecxx . . $ FaceBl0r#cascade..emptycxx . . $ cv/CascadeClassifier#empty(50ce9a9e25b4a850).()) {
121 cvcxx . . $ cv/::setNumThreadscxx . . $ cv/setNumThreads(d4f767463ce0a6b3).(cvRoundcxx . . $ cvRound(620b9ac44d2573a6).(threadscxx . . $ FaceBl0r#threads. * 100));
122 if (classifiercxx . . $ FaceBl0r#classifier..lengthcxx . . $ std/__cxx11/basic_string#length(48278e53df7b52a5).() == 0 || classifiercxx . . $ FaceBl0r#classifier. ==cxx . . $ std/`operator==`(2965e344aacb545b). old_classifiercxx . . $ FaceBl0r#old_classifier.) {
123 // same as before, avoid repeating error messages
124 memcpy(out, in, sizecxx . . $ frei0r/fx#size. * 4); // of course assuming we are RGBA only
125 return;
126 }
127 old_classifiercxx . . $ FaceBl0r#old_classifier. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). classifiercxx . . $ FaceBl0r#classifier.;
128 }
129
130 if (!cascadecxx . . $ FaceBl0r#cascade..loadcxx . . $ cv/CascadeClassifier#load(7c222eea44a24d43).(classifiercxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)..c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).())) {
131 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "ERROR in filter facebl0r, classifier cascade not found:\n");
132 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, " %s\n", classifiercxx . . $ FaceBl0r#classifier..c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).());
133 memcpy(out, in, sizecxx . . $ frei0r/fx#size. * 4);
134 return;
135 }
136
137 // sanitize parameters
138 recheckcxx . . $ FaceBl0r#recheck. = CLAMPcxx . . $ `include/frei0r/math.h:48:9`!(recheck, 0.001, 1.0);
139 search_scalecxx . . $ FaceBl0r#search_scale. = CLAMPcxx . . $ `include/frei0r/math.h:48:9`!(search_scale, 0.11, 1.0);
140 neighborscxx . . $ FaceBl0r#neighbors. = CLAMPcxx . . $ `include/frei0r/math.h:48:9`!(neighbors, 0.01, 1.0);
141
142 // copy input image to OpenCV
143 imagecxx . . $ FaceBl0r#image. =cxx . . $ cv/Mat#`operator=`(4400436486737d83). cvcxx . . $ cv/Mat#Mat(14af0c169761eea9).::Matcxx . . $ cv/Mat#(heightcxx . . $ frei0r/fx#height., widthcxx . . $ frei0r/fx#width., CV_8UC4cxx . . $ `<external>/5620397100220980448/interface.h:91:9`!, (void*)in);
144 tracked_objcxx . . $ FaceBl0r#tracked_obj..update_hue_imagecxx . . $ TrackedObj#update_hue_image(37d4cb3831369c97).(imagecxx . . $ FaceBl0r#image.);
145
146 /*
147 no face*
148 - look for (detect_face)
149 yes face
150 - track face
151 - no more face
152 no face*
153 */
154 if(face_notfoundcxx . . $ FaceBl0r#face_notfound.>0) {
155 stdcxx . . $ std/::vectorcxx . . $ std/vector#<cvcxx . . $ cv/::Rectcxx . . $ cv/Rect#> facescxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
156 if(face_notfoundcxx . . $ FaceBl0r#face_notfound. % cvRoundcxx . . $ cvRound(620b9ac44d2573a6).(recheckcxx . . $ FaceBl0r#recheck. * 1000) == 0)
157 faces =cxx . . $ std/vector#`operator=`(27b3db0518c64371). detect_facecxx . . $ FaceBl0r#detect_face(af1a205b8c6bf75e).();
158
159 // if no face detected
160 if (faces.emptycxx . . $ std/vector#empty(50ce9a9e25b4a850).()) {
161 face_notfoundcxx . . $ FaceBl0r#face_notfound.++;
162 } else {
163 tracked_objcxx . . $ FaceBl0r#tracked_obj..prev_rectcxx . . $ TrackedObj#prev_rect. =cxx . . $ cv/Rect_#`operator=`(6268ad01b00bdd9a). faces[cxx . . $ std/vector#`operator[]`(428bb168810b9e52).0];
164 tracked_objcxx . . $ FaceBl0r#tracked_obj..update_histcxx . . $ TrackedObj#update_hist(49f6e7a06ebc5aa8).();
165 face_notfoundcxx . . $ FaceBl0r#face_notfound. = 0;
166 face_foundcxx . . $ FaceBl0r#face_found.++;
167 }
168 }
169
170 if (face_foundcxx . . $ FaceBl0r#face_found. > 0) {
171 //track the face in the new frame
172 cvcxx . . $ cv/::RotatedRectcxx . . $ cv/RotatedRect# face_box = tracked_objcxx . . $ FaceBl0r#tracked_obj..camshift_track_facecxx . . $ TrackedObj#camshift_track_face(fe011d747cf16d5e).();
173
174 int min = cvRoundcxx . . $ cvRound(620b9ac44d2573a6).(smallestcxx . . $ FaceBl0r#smallest. * 1000);
175 min = min? min : 10;
176 int max = cvRoundcxx . . $ cvRound(620b9ac44d2573a6).(largestcxx . . $ FaceBl0r#largest. * 10000);
177 if( ( face_box.sizecxx . . $ cv/RotatedRect#size..widthcxx . . $ cv/Size_#width. < min )
178 || (face_box.sizecxx . . $ cv/RotatedRect#size..heightcxx . . $ cv/Size_#height. < min )
179 || (face_box.sizecxx . . $ cv/RotatedRect#size..widthcxx . . $ cv/Size_#width. > max )
180 || (face_box.sizecxx . . $ cv/RotatedRect#size..heightcxx . . $ cv/Size_#height. > max )
181 ) {
182 face_foundcxx . . $ FaceBl0r#face_found. = 0;
183 face_notfoundcxx . . $ FaceBl0r#face_notfound.++;
184 }
185 else {
186 cvcxx . . $ cv/::Rectcxx . . $ cv/Rect# blur_region = tracked_objcxx . . $ cv/Rect_#Rect_(83d0633b56fccc8d)..prev_rectcxx . . $ TrackedObj#prev_rect. &cxx . . $ cv/`operator&`(865370648dce7856). cvcxx . . $ cv/Rect_#Rect_(bd932547fceb70f3).::Rectcxx . . $ cv/Rect#({cxx . . $ cv/Point_#Point_(249673c20e2b8d5).0, 0}, imagecxx . . $ FaceBl0r#image..sizecxx . . $ cv/Mat#size.(cxx . . $ cv/MatSize#`operator()`(cd4eb43328384590).));
187 cvcxx . . $ cv/::Matcxx . . $ cv/Mat# blurcxx . . $ cv/Mat#Mat(bf56aeb09249bed1).(imagecxx . . $ FaceBl0r#image., blur_region);
188 cvcxx . . $ cv/::blurcxx . . $ cv/blur(363ff432c8e91b8e).(blurcxx . . $ cv/_InputArray#_InputArray(37d4cb3831369c97)., blurcxx . . $ cv/_OutputArray#_OutputArray(88ae6b8fd72f0dfb)., {cxx . . $ cv/Size_#Size_(249673c20e2b8d5).23, 23}, cvcxx . . $ cv/Point_#Point_(25b43654c881fdb8).::Pointcxx . . $ cv/Point#(-1, -1));
189
190 //outline face ellipse
191 if (ellipsecxx . . $ FaceBl0r#ellipse.)
192 cvcxx . . $ cv/::ellipsecxx . . $ cv/ellipse(763755c49fe42d7d).(imagecxx . . $ cv/_InputOutputArray#_InputOutputArray(88ae6b8fd72f0dfb)., face_box, CV_RGBcxx . . $ `<external>/2309583762017856418/imgproc.hpp:4495:9`!(255,0,0), 2, cvcxx . . $ cv/::LINE_AAcxx . . $ cv/LINE_AA.);
193
194 face_foundcxx . . $ FaceBl0r#face_found.++;
195 if(face_foundcxx . . $ FaceBl0r#face_found. % cvRoundcxx . . $ cvRound(620b9ac44d2573a6).(recheckcxx . . $ FaceBl0r#recheck. * 1000) == 0)
196 face_notfoundcxx . . $ FaceBl0r#face_notfound. = cvRoundcxx . . $ cvRound(620b9ac44d2573a6).(recheckcxx . . $ FaceBl0r#recheck. * 1000); // try recheck
197 }
198 }
199
200 memcpy(out, imagecxx . . $ FaceBl0r#image..datacxx . . $ cv/Mat#data., sizecxx . . $ frei0r/fx#size. * 4);
201 }
202
203 /* Given an image and a classider, detect and return region. */
204 stdcxx . . $ std/::vectorcxx . . $ std/vector#<cvcxx . . $ cv/::Rectcxx . . $ cv/Rect#> FaceBl0rcxx . . $ FaceBl0r#::detect_facecxx . . $ FaceBl0r#detect_face(af1a205b8c6bf75e).()
205 {
206 if (cascadecxx . . $ FaceBl0r#cascade..emptycxx . . $ cv/CascadeClassifier#empty(50ce9a9e25b4a850).()) {
207 return stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<cvcxx . . $ cv/::Rectcxx . . $ cv/Rect#>();
208 }
209
210 //use an equalized gray image for better recognition
211 cvcxx . . $ cv/::Matcxx . . $ cv/Mat# graycxx . . $ cv/Mat#Mat(49f6e7a06ebc5aa8).;
212 cvcxx . . $ cv/::cvtColorcxx . . $ cv/cvtColor(baf8054afaf7b716).(imagecxx . . $ cv/_InputArray#_InputArray(37d4cb3831369c97)., graycxx . . $ cv/_OutputArray#_OutputArray(88ae6b8fd72f0dfb)., cvcxx . . $ cv/::COLOR_BGR2GRAYcxx . . $ cv/COLOR_BGR2GRAY.);
213 cvcxx . . $ cv/::equalizeHistcxx . . $ cv/equalizeHist(98d8004069bfaa87).(graycxx . . $ cv/_InputArray#_InputArray(37d4cb3831369c97)., graycxx . . $ cv/_OutputArray#_OutputArray(88ae6b8fd72f0dfb).);
214
215 //get a sequence of faces in image
216 int min = cvRoundcxx . . $ cvRound(620b9ac44d2573a6).(smallestcxx . . $ FaceBl0r#smallest. * 1000);
217 stdcxx . . $ std/::vectorcxx . . $ std/vector#<cvcxx . . $ cv/::Rectcxx . . $ cv/Rect#> facescxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
218 cascadecxx . . $ FaceBl0r#cascade..detectMultiScalecxx . . $ cv/CascadeClassifier#detectMultiScale(1d254b8eed870013).(graycxx . . $ cv/_InputArray#_InputArray(37d4cb3831369c97)., faces,
219 search_scalecxx . . $ FaceBl0r#search_scale. * 10.0,
220 cvRoundcxx . . $ cvRound(620b9ac44d2573a6).(neighborscxx . . $ FaceBl0r#neighbors. * 100),
221 cvcxx . . $ cv/::CASCADE_FIND_BIGGEST_OBJECTcxx . . $ cv/CASCADE_FIND_BIGGEST_OBJECT.|//since we track only the first, get the biggest
222 cvcxx . . $ cv/::CASCADE_DO_CANNY_PRUNINGcxx . . $ cv/CASCADE_DO_CANNY_PRUNING., //skip regions unlikely to contain a face
223 cvcxx . . $ cv/Size_#Size_(9f6e8d2061d44f50).::Sizecxx . . $ cv/Size#(min, min));
224
225 return facescxx . . $ std/vector#vector(b1ea180184b47f03).;
226 }
227
228 void TrackedObjcxx . . $ TrackedObj#::update_histcxx . . $ TrackedObj#update_hist(49f6e7a06ebc5aa8).()
229 {
230 //create a histogram representation for the face
231 cvcxx . . $ cv/::Matcxx . . $ cv/Mat# hue_roicxx . . $ cv/Mat#Mat(bf56aeb09249bed1).(huecxx . . $ TrackedObj#hue., prev_rectcxx . . $ TrackedObj#prev_rect.);
232 cvcxx . . $ cv/::Matcxx . . $ cv/Mat# mask_roicxx . . $ cv/Mat#Mat(bf56aeb09249bed1).(maskcxx . . $ TrackedObj#mask., prev_rectcxx . . $ TrackedObj#prev_rect.);
233
234 const float* range = hist_rangecxx . . $ TrackedObj#hist_range.;
235 cvcxx . . $ cv/::calcHistcxx . . $ cv/calcHist(78b7fb7430586173).(&hue_roi, 1, nullptr, mask_roicxx . . $ cv/_InputArray#_InputArray(37d4cb3831369c97)., histcxx . . $ cv/_OutputArray#_OutputArray(88ae6b8fd72f0dfb)., 1, &hist_binscxx . . $ TrackedObj#hist_bins., &range);
236 normalizecxx . . $ cv/normalize(35a9cc612d71ccef).(histcxx . . $ cv/_InputArray#_InputArray(37d4cb3831369c97)., histcxx . . $ cv/_InputOutputArray#_InputOutputArray(88ae6b8fd72f0dfb)., 0, 255, cvcxx . . $ cv/::NORM_MINMAXcxx . . $ cv/NORM_MINMAX.);
237 }
238
239 /* Given an image and tracked object, return box position. */
240 cvcxx . . $ cv/::RotatedRectcxx . . $ cv/RotatedRect# TrackedObjcxx . . $ TrackedObj#::camshift_track_facecxx . . $ TrackedObj#camshift_track_face(fe011d747cf16d5e).()
241 {
242 //create a probability image based on the face histogram
243 const float* range = hist_rangecxx . . $ TrackedObj#hist_range.;
244 cvcxx . . $ cv/::calcBackProjectcxx . . $ cv/calcBackProject(2de080d7840af9f8).(&huecxx . . $ TrackedObj#hue., 1, nullptr, histcxx . . $ cv/_InputArray#_InputArray(37d4cb3831369c97)., probcxx . . $ cv/_OutputArray#_OutputArray(88ae6b8fd72f0dfb)., &range);
245 probcxx . . $ TrackedObj#prob. &=cxx . . $ cv/`operator&=`(3c01df4f0ed2fe22). maskcxx . . $ TrackedObj#mask.;
246
247 //use CamShift to find the center of the new face probability
248 cvcxx . . $ cv/::RotatedRectcxx . . $ cv/RotatedRect# curr_box = CamShiftcxx . . $ cv/CamShift(9405e47b928bd32d).(probcxx . . $ cv/_InputArray#_InputArray(37d4cb3831369c97)., prev_rectcxx . . $ TrackedObj#prev_rect.,
249 cvcxx . . $ cv/TermCriteria#TermCriteria(d56ae6de0a26ea65).::TermCriteriacxx . . $ cv/TermCriteria#(cvcxx . . $ cv/::TermCriteriacxx . . $ cv/TermCriteria#::EPScxx . . $ cv/TermCriteria#EPS. | cvcxx . . $ cv/::TermCriteriacxx . . $ cv/TermCriteria#::MAX_ITERcxx . . $ cv/TermCriteria#MAX_ITER., 10, 1 ));
250
251 //update face location
252 prev_rectcxx . . $ TrackedObj#prev_rect. =cxx . . $ cv/Rect_#`operator=`(98dbd96029d5685f). curr_box.boundingRectcxx . . $ cv/RotatedRect#boundingRect(1022150768b51b40).();
253
254 return curr_box;
255 }
256
257 void TrackedObjcxx . . $ TrackedObj#::update_hue_imagecxx . . $ TrackedObj#update_hue_image(37d4cb3831369c97). (const cvcxx . . $ cv/::Matcxx . . $ cv/Mat#& image) {
258 //limits for calculating hue
259 int vmin = 65, vmax = 256, smin = 55;
260
261 //convert to HSV color model
262 cvcxx . . $ cv/::cvtColorcxx . . $ cv/cvtColor(baf8054afaf7b716).(imagecxx . . $ cv/_InputArray#_InputArray(37d4cb3831369c97)., hsvcxx . . $ cv/_OutputArray#_OutputArray(88ae6b8fd72f0dfb)., cvcxx . . $ cv/::COLOR_BGR2HSVcxx . . $ cv/COLOR_BGR2HSV.);
263
264 //mask out-of-range values
265 cvcxx . . $ cv/::inRangecxx . . $ cv/inRange(cd637b5382c91ae0).(hsvcxx . . $ cv/_InputArray#_InputArray(37d4cb3831369c97)., //source
266 cvcxx . . $ cv/_InputArray#_InputArray(cb736c85b94eeb6b).::Scalarcxx . . $ cv/Scalar#(0, smin, MINcxx . . $ `<external>/12337262044557133826/cvdef.h:513:11`!(vmin, vmax)), //lower bound
267 cvcxx . . $ cv/_InputArray#_InputArray(cb736c85b94eeb6b).::Scalarcxx . . $ cv/Scalar#(180, 256, MAXcxx . . $ `<external>/12337262044557133826/cvdef.h:517:11`!(vmin, vmax)), //upper bound
268 maskcxx . . $ cv/_OutputArray#_OutputArray(88ae6b8fd72f0dfb).); //destination
269
270 //extract the hue channel, split: src, dest channels
271 cvcxx . . $ cv/::extractChannelcxx . . $ cv/extractChannel(80b3582d1b0738cc).(hsvcxx . . $ cv/_InputArray#_InputArray(37d4cb3831369c97)., huecxx . . $ cv/_OutputArray#_OutputArray(88ae6b8fd72f0dfb)., 0);
272 }