Skip to content

Commit

Permalink
fix missing face bug
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jan 17, 2019
1 parent a219dbc commit 84ab37c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
3 changes: 2 additions & 1 deletion 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
Expand Down
10 changes: 5 additions & 5 deletions src/detector/index.js
Expand Up @@ -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})
Expand Down Expand Up @@ -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;
Expand All @@ -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
}
Expand Down
22 changes: 17 additions & 5 deletions src/detector/waitqueue.js
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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(){
Expand Down

0 comments on commit 84ab37c

Please sign in to comment.