From 924d23dad0e65a7a41166a54a6bc66a3bf1bd6db Mon Sep 17 00:00:00 2001 From: dongpd Date: Mon, 26 Apr 2021 10:24:53 +0700 Subject: [PATCH] fix bug confidence --- helpers/CaptureLogsGrid.php | 64 +++++++++++++++++++++++++----------- views/capture-logs/index.tpl | 27 ++++++++------- views/control-logs/index.tpl | 2 +- web/index.php | 4 +-- web/js/capture-logs.js | 3 ++ 5 files changed, 66 insertions(+), 34 deletions(-) diff --git a/helpers/CaptureLogsGrid.php b/helpers/CaptureLogsGrid.php index 3bd6115d..80d82e44 100644 --- a/helpers/CaptureLogsGrid.php +++ b/helpers/CaptureLogsGrid.php @@ -64,26 +64,26 @@ class CaptureLogsGrid { public static function confidence() { return function($model) { $confidence = json_decode($model->confidence, true); - $person1_html = $person2_html = ""; - $person1 = \app\models\ListManagement::findOne($confidence['id1']); - if ($person1) { - $images = json_decode($person1->image, true); - $person1_html = "
" . Html::img("/data/uploads/face/" . $images[0]['url'], [ - "class" => "img-thumbnail", - "style" => "width: 100px;height:100px;" - ]) . "
" . $person1->name . " [" . $confidence['percent1'] . "]" . "
"; - } - if ($confidence['id2'] !== "0" && $confidence['id2'] != $confidence['id1']) { - $person2 = \app\models\ListManagement::findOne($confidence['id2']); - if ($person2) { - $images = json_decode($person2->image, true); - $person2_html = "
" . Html::img("/data/uploads/face/" . $images[0]['url'], [ - "class" => "img-thumbnail", - "style" => "width: 100px;height:100px;" - ]) . "
" . $person2->name . " [" . $confidence['percent2'] . "]" . "
"; - } - } - return $person1_html . $person2_html; +// $person1_html = $person2_html = ""; +// $person1 = \app\models\ListManagement::findOne($confidence['id1']); +// if ($person1) { +// $images = json_decode($person1->image, true); +// $person1_html = "
" . Html::img("/data/uploads/face/" . $images[0]['url'], [ +// "class" => "img-thumbnail", +// "style" => "width: 100px;height:100px;" +// ]) . "
" . $person1->name . " [" . $confidence['percent1'] . "]" . "
"; +// } +// if ($confidence['id2'] !== "0" && $confidence['id2'] != $confidence['id1']) { +// $person2 = \app\models\ListManagement::findOne($confidence['id2']); +// if ($person2) { +// $images = json_decode($person2->image, true); +// $person2_html = "
" . Html::img("/data/uploads/face/" . $images[0]['url'], [ +// "class" => "img-thumbnail", +// "style" => "width: 100px;height:100px;" +// ]) . "
" . $person2->name . " [" . $confidence['percent2'] . "]" . "
"; +// } +// } + return $confidence['percent1']; //$person1_html . $person2_html; }; } @@ -95,6 +95,30 @@ class CaptureLogsGrid { } public static function rows() { + return function($model, $index, $widget, $grid) { + $confidence = json_decode($model->confidence, true); + $person = \app\models\ListManagement::findOne($confidence['id1']); + $images = false; + if ($person) { + $images = json_decode($person->image, true); + } + return [ + "ondblclick" => "_form(this);", + "style" => "cursor: pointer;", + "data" => [ + "id" => $model->id, + "img" => "/data/uploads/face/" . $model->image, + "confidence" => json_encode([ + "name" => $person ? $person->name : "", + "score" => $confidence['percent1'], + "img" => isset($images[0]) ? "/data/uploads/face/" . $images[0]['url'] : "" + ]) + ] + ]; + }; + } + + public static function rowsControlLogs() { return function($model, $index, $widget, $grid) { return [ "ondblclick" => "_form(this);", diff --git a/views/capture-logs/index.tpl b/views/capture-logs/index.tpl index a5ff4ab5..18e03004 100644 --- a/views/capture-logs/index.tpl +++ b/views/capture-logs/index.tpl @@ -90,17 +90,22 @@