13 Commits
dev ... BiFace

Author SHA1 Message Date
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
15 changed files with 210 additions and 67 deletions

View File

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

View File

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

View File

@@ -37,7 +37,7 @@ class CaptureLogsController extends Controller {
$t = date_format(date_create_from_format('H:i d/m/Y', $to), 'U');
}
$this->view->title = "Capture Log";
$this->view->title = "Lịch sử hệ thống";
$searchModel = new CaptureLogsSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
if (!$all)

View File

@@ -338,8 +338,8 @@ class ConfigController extends Controller {
array_map('unlink', glob("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/*.*"));
try {
file_get_contents("http://localhost:2305/update-feature");
} catch (Exception $exc) {
echo $exc->getTraceAsString();
} catch (\Exception $exc) {
}
}
return Url::to(['/config']);

View File

@@ -39,7 +39,7 @@ class ControlLogsController extends Controller {
$t = date_format(date_create_from_format('H:i d/m/Y', $to), 'U');
}
$this->view->title = "Control Log";
$this->view->title = "Danh sách nhận diện";
$searchModel = new CaptureLogsSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$dataProvider->query->andWhere(["<>", "capture_logs.staff_id", 0]);

View File

@@ -34,7 +34,7 @@ class ListManagementController extends Controller {
public function actionIndex($from = "", $to = "", $name = "", $type = "all", $gender = "all", $id = "") {
$f = date_format(date_create_from_format('H:i d/m/Y', "00:00 " . date("d/m/Y")), 'U');
$t = date_format(date_create_from_format('H:i d/m/Y', "23:59 " . date("d/m/Y")), 'U');
$this->view->title = "List management";
$this->view->title = "Quản lý mẫu";
$searchModel = new ListManagementSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
if ($from !== "" && $to !== "") {
@@ -578,7 +578,8 @@ class ListManagementController extends Controller {
])), true);
foreach ($results as $key => $value) {
$images = [];
foreach ($value['images'] as $k => $v) {
$imagesReverse = array_reverse($value['images']);
foreach ($imagesReverse as $k => $v) {
if ($k < Yii::$app->params['maxPicture']) {
$key = common::generateRandomString();
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";

View File

@@ -63,11 +63,62 @@ class CaptureLogsGrid {
public static function confidence() {
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() {
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);",
@@ -95,7 +146,7 @@ class CaptureLogsGrid {
if ($staff) {
$images = json_decode($staff->image, true);
if (count($images) > 0)
return Html::img("/data/uploads/face/" . $images[0]['url'], [
return Html::img("/data/uploads/face/" . $images[count($images) - 1]['url'], [
"class" => "img-thumbnail",
"style" => "width: 150px;height:150px;"
]);

View File

@@ -118,14 +118,24 @@ class ListManagement extends \yii\db\ActiveRecord {
public function getAllFeatures() {
$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) {
$f[] = $v['features'];
$feature1[] = $v['features'];
if (isset($v['features512']))
if (count($v['features512']))
$f[] = $v['features512'];
$feature2[] = $v['features512'];
}
return $f;
return [
"feature1" => $feature1,
"feature2" => $feature2
];
}
public static function statisticFeatures() {

View File

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

View File

@@ -1,16 +1,17 @@
<?php
use yii\widgets\Breadcrumbs;
use dmstr\widgets\Alert;
?>
<div class="content-wrapper">
<!-- <section class="content-header">
<?=
Breadcrumbs::widget(
<?=
Breadcrumbs::widget(
[
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]
) ?>
)
?>
</section>-->
<section class="content" style="padding: 0 0 15px 0;">
@@ -21,8 +22,12 @@ use dmstr\widgets\Alert;
</div>
<footer class="main-footer">
<div class="pull-right hidden-xs" style="margin-top: 10px;">
<!--<b>Hotline</b> <a href="tel:0912461556">091.246.1556</a>-->
<div class="pull-right hidden-xs">
<b>Version: </b>
<?php
$version = \app\models\SyncUrl::findOne(['key_config' => 'version']);
echo $version ? $version->data : Yii::$app->params["version"];
?>
</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/">BEETINNOVATORS</a>.</strong> All rights reserved.

View File

@@ -48,17 +48,17 @@ use yii\widgets\ActiveForm;
</li>
<li class="<?php if (Yii::$app->controller->id == "list-management") echo "active"; ?>">
<a href="<?php echo yii\helpers\Url::to(['/list-management']); ?>">
<i class="fa fa-list"></i> List Management
<i class="fa fa-list"></i> Quản lý mẫu
</a>
</li>
<li class="<?php if (Yii::$app->controller->id == "capture-logs") echo "active"; ?>">
<a href="<?php echo yii\helpers\Url::to(['/capture-logs']); ?>">
<i class="fa fa-camera"></i> Capture log
<i class="fa fa-camera"></i> Lịch sử hệ thống
</a>
</li>
<li class="<?php if (Yii::$app->controller->id == "control-logs") echo "active"; ?>">
<a href="<?php echo yii\helpers\Url::to(['/control-logs']); ?>">
<i class="fa fa-database"></i> Control log
<i class="fa fa-database"></i> Danh sách nhận diện
</a>
</li>
</ul>

View File

@@ -55,6 +55,7 @@
'attribute' => 'confidence',
'contentOptions' => ['class' => 'text-center'],
'headerOptions' => ['class' => 'text-center'],
'format' => "raw",
'value' => \app\helpers\CaptureLogsGrid::confidence()
],
[
@@ -89,17 +90,22 @@
<div style="width: 500px;position: absolute;right:0;top: 250px;" id='form' class="hidden">
<div class="panel panel-info">
<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>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-4 text-center">
<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 class="col-md-8">
<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">
<select style="width: 100%;height: 26px;" name="Type">
<option value="wl">White list</option>
@@ -117,34 +123,34 @@
</div>
</div>
<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">
<input type="text" name="Name">
</div>
</div>
<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">
<select style="width: 100%;height: 26px;" name="Gender">
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Male">Nam</option>
<option value="Female">Nữ</option>
</select>
</div>
</div>
<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">
<input type="text" name="Birthday" id="birthday">
</div>
</div>
<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">
<input type="text" name="Telephone">
</div>
</div>
<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">
<input type="text" name="Address">
</div>
@@ -153,8 +159,8 @@
</div>
<div class="text-center">
<input type="hidden" value="" name="CaptureLogsID">
<button onclick="_save(this);" data-href='{Url::to(["/list-management/create"])}'>Save</button>
<button onclick="_close();">Cancel</button>
<button onclick="_save(this);" data-href='{Url::to(["/list-management/create"])}'>Lưu</button>
<button onclick="_close();">Hủy</button>
</div>
</div>
</div>

View File

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

View File

@@ -30,9 +30,9 @@
</thead>
<tbody id="sync-lists">
{foreach from=$datas item=arr}
<tr id="filters-{$arr.code}" onclick="choooseToSync(this);" style="cursor: pointer;" class="filters {if !in_array($arr.idStaff,$allID)}not-in-list{/if}" data-stt="false" data-id="{$arr.idStaff}">
<tr id="filters-{$arr.code}" onclick="choooseToSync(this);" style="cursor: pointer;" class="filters {if !in_array($arr.idStaff,$allID)}not-in-list{/if}" data-stt="false" data-id="{trim($arr.idStaff)}">
<td>
<div id="full-data-{$arr.idStaff}" class="hidden">{json_encode($arr)}</div>
<div id="full-data-{trim($arr.idStaff)}" class="hidden">{json_encode($arr)}</div>
{$arr.idStaff}
{if in_array($arr.idStaff,$allID)}
<i class="fa fa-check-circle text-green"></i>

View File

@@ -23,6 +23,9 @@ function _form(e) {
$("#form").removeClass("hidden");
$("input[name='CaptureLogsID']").val($(e).attr("data-id"));
$("#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() {