14 Commits

Author SHA1 Message Date
b3bca79f55 fix bug confidence 2021-06-17 17:42:56 +07:00
9ceb3567c9 Update 'controllers/ApiController.php'
fix bug regenfeature
2021-05-19 10:31:09 +00:00
2c722a1ee9 Merge branch 'dev_DTD' of http://gitea.beetai.com/dongpd/BiFace_Server_Lite into dev_DTD 2021-04-26 14:23:04 +07:00
70d60ff51e fix bug token - version 2021-04-26 14:22:57 +07:00
c02733be18 Update 'config/params.php' 2021-04-26 03:48:02 +00:00
924d23dad0 fix bug confidence 2021-04-26 10:24:53 +07:00
b006af4e1f update confidence + version 2021-04-23 16:58:19 +07:00
1b1162f3c2 get config to gen 512 feature 2021-04-20 10:33:22 +07:00
bf93f6c9d0 update version 2021-03-15 09:45:50 +07:00
aaa6de6f9c fix bug reset thiet bi 2021-03-03 14:08:46 +07:00
e45e08f372 upda ngon ngu tieng Viet cho nhung cho tieng Anh 2021-02-18 17:44:18 +07:00
c353c25abf fix bug idStaff co dau cach 2021-02-04 17:59:25 +07:00
92541936d1 hien thi anh mau moi nhat 2021-01-27 10:26:05 +07:00
6d87d47d68 update new feature 2021-01-22 16:16:18 +07:00
11 changed files with 200 additions and 57 deletions

View File

@@ -3,5 +3,6 @@
return [ return [
'adminEmail' => 'admin@example.com', 'adminEmail' => 'admin@example.com',
"maxLogs" => 100000, "maxLogs" => 100000,
"maxPicture" => 2 "maxPicture" => 5,
"version" => "1.0.7"
]; ];

View File

@@ -78,7 +78,7 @@ class ApiController extends Controller {
"Staff" => $post["id"], "Staff" => $post["id"],
"Time" => $time, "Time" => $time,
"Image" => $fileName, "Image" => $fileName,
"Confidence" => strval($post["confidence"]) "Confidence" => json_encode($post["confidence"])
]); ]);
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']); $server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
$ip = "https://dev-dc.beetai.com"; $ip = "https://dev-dc.beetai.com";
@@ -124,17 +124,30 @@ class ApiController extends Controller {
$allFeatures = []; $allFeatures = [];
foreach ($listManagement as $key => $value) { foreach ($listManagement as $key => $value) {
$features = json_decode($value->image, true); $features = json_decode($value->image, true);
$f = []; // $f = [];
// foreach ($features as $k => $v) {
// $f[] = $v['features'];
// if (isset($v['features512']))
// if (count($v['features512']))
// $f[] = $v['features512'];
// }
// $allFeatures[] = [
// "id" => $value->id,
// "name" => $this->convert_vi_to_en($value->name),
// "features" => $f
// ];
$feature1 = $feature2 = [];
foreach ($features as $k => $v) { foreach ($features as $k => $v) {
$f[] = $v['features']; $feature1[] = $v['features'];
if (isset($v['features512'])) if (isset($v['features512']))
if (count($v['features512'])) if (count($v['features512']))
$f[] = $v['features512']; $feature2[] = $v['features512'];
} }
$allFeatures[] = [ $allFeatures[] = [
"id" => $value->id, "id" => $value->id,
"name" => $this->convert_vi_to_en($value->name), "name" => $this->convert_vi_to_en($value->name),
"features" => $f "feature1" => $feature1,
"feature2" => $feature2
]; ];
} }
Yii::$app->response->format = "json"; Yii::$app->response->format = "json";
@@ -235,6 +248,8 @@ class ApiController extends Controller {
public function actionAutoGenFeature() { public function actionAutoGenFeature() {
Yii::$app->response->format = "json"; Yii::$app->response->format = "json";
if (!$this->check512())
return ["status" => false];
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']); $updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
if (!$updating) { if (!$updating) {
$model = new \app\models\SyncUrl(); $model = new \app\models\SyncUrl();
@@ -244,13 +259,21 @@ class ApiController extends Controller {
]); ]);
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']); $updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
} }
$currentCache = json_decode(file_get_contents("http://localhost:2305/current-cache"), true);
if ($updating->data === "true") { if ($updating->data === "true") {
$txt = "\n" . date("H:i:s d/m/Y") . " " . "updating"; if ($currentCache['n_128'] == $currentCache['n_512']) {
file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND); $updating->data = "false";
return ["status" => false]; $updating->save();
$txt = "\n" . date("H:i:s d/m/Y") . " " . "success";
file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND);
return ["status" => false];
} else {
$txt = "\n" . date("H:i:s d/m/Y") . " " . "updating";
file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND);
return ["status" => false];
}
} }
$currentCache = json_decode(file_get_contents("http://localhost:2305/current-cache"), true);
if ($currentCache['n_128'] == $currentCache['n_512']) { if ($currentCache['n_128'] == $currentCache['n_512']) {
$txt = "\n" . date("H:i:s d/m/Y") . " " . "success"; $txt = "\n" . date("H:i:s d/m/Y") . " " . "success";
file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND); file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND);
@@ -392,31 +415,66 @@ class ApiController extends Controller {
'data' => $post['token'] 'data' => $post['token']
]); ]);
} }
$version = \app\models\SyncUrl::findOne(['key_config' => 'version']);
if ($version) {
$version->data = $post['version'];
$version->save();
} else {
$model = new \app\models\SyncUrl();
$model->create([
'key_config' => "version",
'data' => $post['version']
]);
}
Yii::$app->response->format = "json"; Yii::$app->response->format = "json";
return ["status" => true]; return ["status" => true];
} }
} }
public function actionTest() { public function check512() {
$check = \app\models\SyncUrl::findOne(['key_config' => 'updating']); $tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
$check->data = "false"; 'http' => [
$check->save(); 'header' => "Content-Type: application/json",
return var_dump($check); 'method' => "POST"
// file_get_contents("http://localhost:2305/update-feature"); ]
// return; ])), true);
set_time_limit(0); if (!$tempConfig['status'])
$lists = ListManagement::find()->all(); return false;
foreach ($lists as $key => $value) {
$extract = false; $engineConfig = json_decode($tempConfig['data'], true);
$images = json_decode($value->image, true); if (count($engineConfig['data']['engines']) == 0)
$newImgs = []; return false;
foreach ($images as $k => $v) {
$v['features512'] = []; $checkConfig = json_decode(file_get_contents("http://localhost:4004/ReadConfig", false, stream_context_create([
$newImgs[] = $v; 'http' => [
} 'header' => "Content-Type: application/json",
$value->image = json_encode($newImgs); 'method' => "POST",
$value->save(); 'content' => json_encode([
'path' => $engineConfig['data']['engines'][0]['path']
])
]
])), true);
if (!$checkConfig['status'])
return false;
$config_json = "";
if ($checkConfig['status']) {
$config_json = json_decode($checkConfig['data'], true);
$check512 = $config_json['feature']['type2']['enable'];
if ($check512 !== "0")
return true;
} }
return false;
}
public function actionTest() {
// $updating = \app\models\SyncUrl::findOne(['key_config' => 'token']);
$updating = \app\models\SyncUrl::find()->all();
foreach ($updating as $key => $value) {
echo $value->key_config . " " . $value->data . "<br>";
}
exit();
} }
public function actionReGenFeature() { public function actionReGenFeature() {
@@ -428,7 +486,15 @@ class ApiController extends Controller {
'data' => "false" 'data' => "false"
]); ]);
} else { } else {
$updating->data = "false"; if ($this->check512()) {
$currentCache = json_decode(file_get_contents("http://localhost:2305/current-cache"), true);
if ($currentCache['n_128'] == $currentCache['n_512']) {
$updating->data = "true";
} else {
$updating->data = "false";
}
} else
$updating->data = "false";
$updating->save(); $updating->save();
} }
Yii::$app->response->format = "json"; Yii::$app->response->format = "json";

View File

@@ -339,7 +339,7 @@ class ConfigController extends Controller {
try { try {
file_get_contents("http://localhost:2305/update-feature"); file_get_contents("http://localhost:2305/update-feature");
} catch (\Exception $exc) { } catch (\Exception $exc) {
// echo $exc->getTraceAsString();
} }
} }
return Url::to(['/config']); return Url::to(['/config']);

View File

@@ -578,7 +578,8 @@ class ListManagementController extends Controller {
])), true); ])), true);
foreach ($results as $key => $value) { foreach ($results as $key => $value) {
$images = []; $images = [];
foreach ($value['images'] as $k => $v) { $imagesReverse = array_reverse($value['images']);
foreach ($imagesReverse as $k => $v) {
if ($k < Yii::$app->params['maxPicture']) { if ($k < Yii::$app->params['maxPicture']) {
$key = common::generateRandomString(); $key = common::generateRandomString();
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads"; $RootFolder = Yii::getAlias('@webroot') . "/data/uploads";

View File

@@ -63,11 +63,62 @@ class CaptureLogsGrid {
public static function confidence() { public static function confidence() {
return function($model) { return function($model) {
return number_format($model->confidence, 2); $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 = "<div class='feature-img'>" . Html::img("/data/uploads/face/" . $images[0]['url'], [
// "class" => "img-thumbnail",
// "style" => "width: 100px;height:100px;"
// ]) . "<br>" . $person1->name . " [" . $confidence['percent1'] . "]" . "</div>";
// }
// 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 = "<div class='feature-img'>" . Html::img("/data/uploads/face/" . $images[0]['url'], [
// "class" => "img-thumbnail",
// "style" => "width: 100px;height:100px;"
// ]) . "<br>" . $person2->name . " [" . $confidence['percent2'] . "]" . "</div>";
// }
// }
return $confidence['percent1']; //$person1_html . $person2_html;
};
}
public static function confidenceControlLogs() {
return function($model) {
$confidence = json_decode($model->confidence, true);
return $confidence['percent1'] . ($confidence['percent2'] > 0 ? " [" . $confidence['percent2'] . "]" : "");
}; };
} }
public static function rows() { public static function rows() {
return function($model, $index, $widget, $grid) {
$confidence = json_decode($model->confidence, true);
$person = isset($confidence['id1']) ? \app\models\ListManagement::findOne($confidence['id1']) : false;
$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" => isset($confidence['percent1']) ? $confidence['percent1'] : "",
"img" => isset($images[0]) ? "/data/uploads/face/" . $images[0]['url'] : ""
])
]
];
};
}
public static function rowsControlLogs() {
return function($model, $index, $widget, $grid) { return function($model, $index, $widget, $grid) {
return [ return [
"ondblclick" => "_form(this);", "ondblclick" => "_form(this);",

View File

@@ -118,14 +118,24 @@ class ListManagement extends \yii\db\ActiveRecord {
public function getAllFeatures() { public function getAllFeatures() {
$features = json_decode($this->image, true); $features = json_decode($this->image, true);
$f = []; // $f = [];
// foreach ($features as $k => $v) {
// $f[] = $v['features'];
// if (isset($v['features512']))
// if (count($v['features512']))
// $f[] = $v['features512'];
// }
$feature1 = $feature2 = [];
foreach ($features as $k => $v) { foreach ($features as $k => $v) {
$f[] = $v['features']; $feature1[] = $v['features'];
if (isset($v['features512'])) if (isset($v['features512']))
if (count($v['features512'])) if (count($v['features512']))
$f[] = $v['features512']; $feature2[] = $v['features512'];
} }
return $f; return [
"feature1" => $feature1,
"feature2" => $feature2
];
} }
public static function statisticFeatures() { public static function statisticFeatures() {

View File

@@ -4,5 +4,5 @@ copy.src.target=
remote.connection=BiFace-99bab6 remote.connection=BiFace-99bab6
remote.directory=/BiFace_Server_Lite remote.directory=/BiFace_Server_Lite
remote.upload=ON_SAVE remote.upload=ON_SAVE
run.as=LOCAL run.as=REMOTE
url=http://localhost/ url=http://localhost/

View File

@@ -1,16 +1,17 @@
<?php <?php
use yii\widgets\Breadcrumbs; use yii\widgets\Breadcrumbs;
use dmstr\widgets\Alert; use dmstr\widgets\Alert;
?> ?>
<div class="content-wrapper"> <div class="content-wrapper">
<!-- <section class="content-header"> <!-- <section class="content-header">
<?= <?=
Breadcrumbs::widget( Breadcrumbs::widget(
[ [
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
] ]
) ?> )
?>
</section>--> </section>-->
<section class="content" style="padding: 0 0 15px 0;"> <section class="content" style="padding: 0 0 15px 0;">
@@ -21,8 +22,12 @@ use dmstr\widgets\Alert;
</div> </div>
<footer class="main-footer"> <footer class="main-footer">
<div class="pull-right hidden-xs" style="margin-top: 10px;"> <div class="pull-right hidden-xs">
<!--<b>Hotline</b> <a href="tel:0912461556">091.246.1556</a>--> <b>Version: </b>
<?php
$version = \app\models\SyncUrl::findOne(['key_config' => 'version']);
echo $version ? $version->data : Yii::$app->params["version"];
?>
</div> </div>
<!--<strong>Copyright &copy; 2020 <a href="https://beetinnovators.com/"><img src="/images/BI_Logo.png" width="80px"></a> & <a href="https://tctech.vn/"><img src="/images/TCTech.jpg" width="80px"></a>.</strong> All rights reserved.--> <!--<strong>Copyright &copy; 2020 <a href="https://beetinnovators.com/"><img src="/images/BI_Logo.png" width="80px"></a> & <a href="https://tctech.vn/"><img src="/images/TCTech.jpg" width="80px"></a>.</strong> All rights reserved.-->
<strong>Copyright &copy; 2020 <a href="https://beetinnovators.com/">BEETINNOVATORS</a>.</strong> All rights reserved. <strong>Copyright &copy; 2020 <a href="https://beetinnovators.com/">BEETINNOVATORS</a>.</strong> All rights reserved.

View File

@@ -55,6 +55,7 @@
'attribute' => 'confidence', 'attribute' => 'confidence',
'contentOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'],
'headerOptions' => ['class' => 'text-center'], 'headerOptions' => ['class' => 'text-center'],
'format' => "raw",
'value' => \app\helpers\CaptureLogsGrid::confidence() 'value' => \app\helpers\CaptureLogsGrid::confidence()
], ],
[ [
@@ -89,17 +90,22 @@
<div style="width: 500px;position: absolute;right:0;top: 250px;" id='form' class="hidden"> <div style="width: 500px;position: absolute;right:0;top: 250px;" id='form' class="hidden">
<div class="panel panel-info"> <div class="panel panel-info">
<div class="panel-heading text-bold"> <div class="panel-heading text-bold">
List management Quản lý mẫu
<i class="fa fa-remove pull-right" style="cursor: pointer;" onclick="_close();"></i> <i class="fa fa-remove pull-right" style="cursor: pointer;" onclick="_close();"></i>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div class="row"> <div class="row">
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<img src="" class="img-thumbnail" id="FaceImage" style="width: 150px;height: 150px;"> <img src="" class="img-thumbnail" id="FaceImage" style="width: 150px;height: 150px;">
<div class='feature-img'>
<img src="" class="img-thumbnail" id="closest-img" style="width: 100px;height:100px;">
<br>
<i id="closest-name"></i>
</div>
</div> </div>
<div class="col-md-8"> <div class="col-md-8">
<div class="row"> <div class="row">
<div class="col-md-4 text-right">Type</div> <div class="col-md-4 text-right">Danh sách</div>
<div class="col-md-8"> <div class="col-md-8">
<select style="width: 100%;height: 26px;" name="Type"> <select style="width: 100%;height: 26px;" name="Type">
<option value="wl">White list</option> <option value="wl">White list</option>
@@ -117,34 +123,34 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-4 text-right">Name</div> <div class="col-md-4 text-right">Tên</div>
<div class="col-md-8"> <div class="col-md-8">
<input type="text" name="Name"> <input type="text" name="Name">
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-4 text-right">Gender</div> <div class="col-md-4 text-right">Giới tính</div>
<div class="col-md-8"> <div class="col-md-8">
<select style="width: 100%;height: 26px;" name="Gender"> <select style="width: 100%;height: 26px;" name="Gender">
<option value="Male">Male</option> <option value="Male">Nam</option>
<option value="Female">Female</option> <option value="Female">Nữ</option>
</select> </select>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-4 text-right">Birthday</div> <div class="col-md-4 text-right">Ngày sinh</div>
<div class="col-md-8"> <div class="col-md-8">
<input type="text" name="Birthday" id="birthday"> <input type="text" name="Birthday" id="birthday">
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-4 text-right">Telephone</div> <div class="col-md-4 text-right">Điện thoại</div>
<div class="col-md-8"> <div class="col-md-8">
<input type="text" name="Telephone"> <input type="text" name="Telephone">
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-4 text-right">Department</div> <div class="col-md-4 text-right">Đơn vị</div>
<div class="col-md-8"> <div class="col-md-8">
<input type="text" name="Address"> <input type="text" name="Address">
</div> </div>
@@ -153,8 +159,8 @@
</div> </div>
<div class="text-center"> <div class="text-center">
<input type="hidden" value="" name="CaptureLogsID"> <input type="hidden" value="" name="CaptureLogsID">
<button onclick="_save(this);" data-href='{Url::to(["/list-management/create"])}'>Save</button> <button onclick="_save(this);" data-href='{Url::to(["/list-management/create"])}'>Lưu</button>
<button onclick="_close();">Cancel</button> <button onclick="_close();">Hủy</button>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -31,7 +31,7 @@
'class' => 'table table-striped table-bordered', 'class' => 'table table-striped table-bordered',
'style' => 'background:#fff;min-width:700px;' 'style' => 'background:#fff;min-width:700px;'
], ],
'rowOptions' => \app\helpers\CaptureLogsGrid::rows(), 'rowOptions' => \app\helpers\CaptureLogsGrid::rowsControlLogs(),
'columns' => [ 'columns' => [
[ [
'attribute' => 'id', 'attribute' => 'id',
@@ -62,7 +62,7 @@
'attribute' => 'confidence', 'attribute' => 'confidence',
'contentOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'],
'headerOptions' => ['class' => 'text-center'], 'headerOptions' => ['class' => 'text-center'],
'value' => \app\helpers\CaptureLogsGrid::confidence() 'value' => \app\helpers\CaptureLogsGrid::confidenceControlLogs()
], ],
'listManagement.name', 'listManagement.name',
'listManagement.gender', 'listManagement.gender',

View File

@@ -23,6 +23,9 @@ function _form(e) {
$("#form").removeClass("hidden"); $("#form").removeClass("hidden");
$("input[name='CaptureLogsID']").val($(e).attr("data-id")); $("input[name='CaptureLogsID']").val($(e).attr("data-id"));
$("#FaceImage").attr("src", $(e).attr("data-img")); $("#FaceImage").attr("src", $(e).attr("data-img"));
var confidence = JSON.parse($(e).attr("data-confidence"));
$("#closest-img").attr("src", confidence.img);
$("#closest-name").html(confidence.name + " [" + confidence.score + "]");
} }
function _close() { function _close() {