@@ -244,14 +244,13 @@ Java_dlib_android_FaceRecognizer_recognizeFaces(JNIEnv *env,
244
244
pixelscolor = (char *) pixelscolor + infocolor.stride ;
245
245
}
246
246
247
- // dlib::save_bmp(img, "/sdcard/Download/tt.bmp");
247
+ // dlib::save_bmp(img, "/sdcard/Download/res1.bmp");
248
+
248
249
std::vector<dlib::rectangle> dets = detector1 (img);
249
250
if (dets.size () == 0 ){
250
251
return strarr;
251
252
}
252
253
253
- // LOGI("dets: %d", dets.size());
254
-
255
254
std::vector<matrix<rgb_pixel>> faces;
256
255
for (auto face : dets)
257
256
{
@@ -261,8 +260,6 @@ Java_dlib_android_FaceRecognizer_recognizeFaces(JNIEnv *env,
261
260
faces.push_back (move (face_chip));
262
261
}
263
262
264
- // LOGI("faces: %d", faces.size());
265
-
266
263
std::vector<matrix<float , 0 , 1 >> face_descriptors = net1 (faces);
267
264
268
265
for (size_t i = 0 ; i < face_descriptors.size (); ++i)
@@ -325,46 +322,46 @@ Java_dlib_android_FaceRecognizer_recognizeFace(JNIEnv *env, jobject instance, jo
325
322
}
326
323
327
324
// todo: smth wrong with colors
328
- dlib::save_bmp (img, " /sdcard/Download/res.bmp" );
329
-
330
- // std::vector<dlib::rectangle> dets = detector(img);
331
- // LOGI("detected size %d", dets.size());
332
- //
333
- // float min_dist = 0.0;
334
- // if(dets.size() > 0 ){
335
- // auto face = dets.front();
336
- // std::vector<matrix<rgb_pixel>> faces;
337
- // int x = face.left();
338
- // int y = face.top();
339
- // int width = face.width();
340
- // int height = face.height();
341
- //
342
- // auto shape = sp(img, face);
343
- // matrix<rgb_pixel> face_chip;
344
- // extract_image_chip(img, get_face_chip_details(shape, 150, 0.25), face_chip);
345
- // faces.push_back(move(face_chip));
346
- //
347
- // std::vector<matrix<float, 0, 1>> face_descriptors = net(faces);
348
- //
349
- // if (face_descriptors.size() > 0)
350
- // {
351
- // matrix<float, 0, 1> face_desc = face_descriptors[0];
352
- // for (auto& i : known_faces) {
353
- // float dist = length(face_desc - i.second );
354
- // if (dist < min_dist){
355
- // min_dist = dist;
356
- // }
357
- // if( dist < FACE_RECOGNIZE_THRESH) //todo: extract thresh
358
- // {
359
- // LOGI("recognized");
360
- // return env->NewStringUTF(i.first.c_str());
361
- // }
362
- // }
363
- // }
364
- // LOGI("not recognized, max dist %0.2f", min_dist);
365
- // }
366
- //
367
- LOGI (" unlocking pixels" );
325
+ // dlib::save_bmp(img, "/sdcard/Download/res.bmp");
326
+
327
+ std::vector<dlib::rectangle> dets = detector (img);
328
+ LOGI (" detected size %d" , dets.size ());
329
+
330
+ float min_dist = 0.0 ;
331
+ if (dets.size () > 0 ){
332
+ auto face = dets.front ();
333
+ std::vector<matrix<rgb_pixel>> faces;
334
+ int x = face.left ();
335
+ int y = face.top ();
336
+ int width = face.width ();
337
+ int height = face.height ();
338
+
339
+ auto shape = sp (img, face);
340
+ matrix<rgb_pixel> face_chip;
341
+ extract_image_chip (img, get_face_chip_details (shape, 150 , 0.25 ), face_chip);
342
+ faces.push_back (move (face_chip));
343
+
344
+ std::vector<matrix<float , 0 , 1 >> face_descriptors = net (faces);
345
+
346
+ if (face_descriptors.size () > 0 )
347
+ {
348
+ matrix<float , 0 , 1 > face_desc = face_descriptors[0 ];
349
+ for (auto & i : known_faces) {
350
+ float dist = length (face_desc - i.second );
351
+ if (dist < min_dist){
352
+ min_dist = dist;
353
+ }
354
+ if ( dist < FACE_RECOGNIZE_THRESH)
355
+ {
356
+ // LOGI("recognized");
357
+ return env->NewStringUTF (i.first .c_str ());
358
+ }
359
+ }
360
+ }
361
+ LOGI (" not recognized, max dist %0.2f" , min_dist);
362
+ }
363
+
364
+ // LOGI("unlocking pixels");
368
365
AndroidBitmap_unlockPixels (env, bmp);
369
366
370
367
std::string returnValue = " Unknown" ;
0 commit comments