From 84ab37cedc884255e1fbfaa1a7e4379774771a45 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 17 Jan 2019 15:56:11 +0800 Subject: [PATCH] fix missing face bug --- docker/production_1.env | 3 ++- src/detector/index.js | 10 +++++----- src/detector/waitqueue.js | 22 +++++++++++++++++----- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/docker/production_1.env b/docker/production_1.env index 216842bf..eb581fae 100644 --- a/docker/production_1.env +++ b/docker/production_1.env @@ -1,7 +1,8 @@ # works in detector plugin, all Integer type -DEEP_ANALYSIS_MODE=0 +DEEP_ANALYSIS_MODE=1 +ONE_KNOWN_PERSON_BYPASS_QUEUE_MODE=0 SAMPLING_TO_SAVE_ENERGY_MODE=0 RESTRICT_RECOGNITON_MODE=0 MINIMAL_FACE_RESOLUTION=100 diff --git a/src/detector/index.js b/src/detector/index.js index d8c8533d..e14fd420 100644 --- a/src/detector/index.js +++ b/src/detector/index.js @@ -265,7 +265,7 @@ function save_image_for_delayed_process(cameraId, file_path, force_saving){ var current_face_count = getCurrentFaceCount(cameraId) var current_tracker_id = getCurrentTrackerId(cameraId) if(current_face_count > 0){ - ON_DEBUG && console.log('TODO: save and send to no priority task, faces: '+current_person_count + ' camera: '+cameraId) + ON_DEBUG && console.log('TODO: save and send to no priority task, faces: '+current_face_count + ' camera: '+cameraId) var ts = new Date().getTime() waitqueue.waitQueueInsert({'cameraId': cameraId, 'filepath': file_path, 'ts': ts, 'trackerid':current_tracker_id}) @@ -319,7 +319,7 @@ function getFaceRecognitionTaskList(cameraId,cropped_images,tracking_info,curren } var time_diff = (new Date() - current_tracker_id)/1000 - console.log('Tracking lasting for %ds, I like this logic game ',time_diff,cropped_images,tracking_info) + ON_DEBUG && console.log('Tracking lasting for %ds, I like this logic game ',time_diff,cropped_images,tracking_info) var face_list = [] cropped_images.sort(function(a,b){ var area_a = a.height * a.width; @@ -329,17 +329,17 @@ function getFaceRecognitionTaskList(cameraId,cropped_images,tracking_info,curren cropped_images.forEach(function(item){ if(RESTRICT_RECOGNITON_MODE && item.style !== 'front'){ deepeye.delete_image(item.path) - console.log('Do not use side face') + ON_DEBUG && console.log('Do not use side face') return } if(item.width < MINIMAL_FACE_RESOLUTION || item.height < MINIMAL_FACE_RESOLUTION){ - console.log('Do not use smaller face than %d',MINIMAL_FACE_RESOLUTION) + ON_DEBUG && console.log('Do not use smaller face than %d',MINIMAL_FACE_RESOLUTION) deepeye.delete_image(item.path) return } if(BIGGEST_FACE_ONLY_MODE){ if(face_list.length >=1){ - console.log('BIGGEST_FACE_ONLY_MODE, skipped one face') + ON_DEBUG && console.log('BIGGEST_FACE_ONLY_MODE, skipped one face') deepeye.delete_image(item.path) return } diff --git a/src/detector/waitqueue.js b/src/detector/waitqueue.js index 8308532e..2af8f9b5 100644 --- a/src/detector/waitqueue.js +++ b/src/detector/waitqueue.js @@ -14,12 +14,18 @@ function GetEnvironmentVarInt(varname, defaultvalue) } var MINIMAL_FACE_RESOLUTION = GetEnvironmentVarInt('MINIMAL_FACE_RESOLUTION', 200) +var DEEP_ANALYSIS_MODE = GetEnvironmentVarInt('DEEP_ANALYSIS_MODE',1) function need_do_face_recognition(tracking_info){ - // 初始阶段,还没有任何检测结果,送入Delayed队列 + // No need to do face recognition at the early stage if(!tracking_info){ return true; } + // Do face recognition if deep analysis mode enabled + if(DEEP_ANALYSIS_MODE){ + ON_DEBUG && console.log('---------deep analysis mode enabled--------') + return true; + } /* Tracking Info Format { _id: 1542403488136, // TimeStamp for the first frame of this event @@ -31,22 +37,27 @@ function need_do_face_recognition(tracking_info){ } */ var recognized_in_results = Object.keys(tracking_info.results).length - // 如果已经识别出的人数多于当前Tracking的最大人数,不必在Delayed Queue里面计算,浪费时间 + // No need to do face recognition if recognized faces are greater than maximal tracking number. if(recognized_in_results >= tracking_info.number){ console.log('recognized_in_results >= %d, skip delayed process',tracking_info.number) return false; } - // 镜头前是陌生人,正脸出现次数大于 N,不再入Delayed队列 + // No need to do face recognition if number of stranger's front face greater than N if(tracking_info.front_faces >= tracking_info.number){ console.log('Unknowd faces >= %d skip delayed process',tracking_info.number) return false; } - // 其他情况,计算 + // else do face recognition return true; } function getLargeFrontFacesList(cropped_images){ - var face_list = [] + if(DEEP_ANALYSIS_MODE){ + console.log('---cropped images length-----',cropped_images.length) + return cropped_images + } + + var face_list=[] cropped_images.forEach(function(item){ if(item.style !== 'front'){ deepeye.delete_image(item.path) @@ -101,6 +112,7 @@ function processWaitQueue() { ON_DEBUG && console.log(">>>>> " + JSON.stringify(cropped_images)) var front_large_faces = getLargeFrontFacesList(cropped_images) if (front_large_faces.length>0) { + console.log('do embedding after waitqueue---------') deepeye.embedding(front_large_faces, trackerId,function(err,results){ console.log('Got result on delayed task: '+results) timeline.update(trackerId,'delayed',cropped_num,results,function(){