update lay vecto 512 ngam
This commit is contained in:
parent
3b247f9f25
commit
aa811a40dd
|
@ -91,7 +91,11 @@ class ApiController extends Controller {
|
|||
$id_camera = intval($device_id->data);
|
||||
$logsInfo = CaptureLogs::findOne($logs);
|
||||
$staffInfo = ListManagement::findOne($post['id']);
|
||||
$res = json_decode(file_get_contents($ip . "/api/oem/face_recognition", false, stream_context_create([
|
||||
$tk = "";
|
||||
$token = \app\models\SyncUrl::findOne(['key_config' => 'token']);
|
||||
if ($token)
|
||||
$tk = $token->data;
|
||||
$res = json_decode(file_get_contents($ip . "/api/oem/face_recognition?token=" . $tk, false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
|
@ -231,14 +235,28 @@ class ApiController extends Controller {
|
|||
|
||||
public function actionAutoGenFeature() {
|
||||
Yii::$app->response->format = "json";
|
||||
$processTime = [];
|
||||
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
|
||||
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];
|
||||
}
|
||||
|
||||
$start = $this->getCurrentTime();
|
||||
$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);
|
||||
return ["status" => false];
|
||||
}
|
||||
|
||||
$updating->data = "true";
|
||||
$updating->save();
|
||||
|
||||
$processTime = [];
|
||||
set_time_limit(0);
|
||||
$lists = ListManagement::find()->all();
|
||||
$finish = $this->getCurrentTime();
|
||||
$processTime["getAllLM"] = round(($finish - $start), 4);
|
||||
$extract = false;
|
||||
foreach ($lists as $key => $value) {
|
||||
$extract = false;
|
||||
$images = json_decode($value->image, true);
|
||||
$newImgs = [];
|
||||
$temp = [];
|
||||
|
@ -260,23 +278,20 @@ class ApiController extends Controller {
|
|||
}
|
||||
if ($extract) {
|
||||
$processTime['extract'] = $temp;
|
||||
$value->image = json_encode($newImgs);
|
||||
$start = $this->getCurrentTime();
|
||||
$value->image = json_encode($newImgs);
|
||||
$value->save();
|
||||
$finish = $this->getCurrentTime();
|
||||
$processTime["updateDB"] = round(($finish - $start), 4);
|
||||
$txt = "\n" . json_encode($processTime);
|
||||
file_put_contents(date('Ymd') . ".txt", $txt, FILE_APPEND);
|
||||
common::updateFeature([
|
||||
"cmd" => "update",
|
||||
"id" => $value->id,
|
||||
"name" => common::convert_vi_to_en($value->name),
|
||||
"features" => $value->allFeatures
|
||||
]);
|
||||
return ["status" => true, "time" => $processTime];
|
||||
}
|
||||
}
|
||||
return ["status" => false];
|
||||
|
||||
file_get_contents("http://localhost:2305/update-feature");
|
||||
$updating->data = "false";
|
||||
$updating->save();
|
||||
return ["status" => true];
|
||||
}
|
||||
|
||||
public function actionSync() {
|
||||
|
@ -291,9 +306,14 @@ class ApiController extends Controller {
|
|||
if ($device_id)
|
||||
$id_camera = intval($device_id->data);
|
||||
$ls = CaptureLogs::find()->andWhere(['sync_status' => null])->all();
|
||||
|
||||
$tk = "";
|
||||
$token = \app\models\SyncUrl::findOne(['key_config' => 'token']);
|
||||
if ($token)
|
||||
$tk = $token->data;
|
||||
foreach ($ls as $key => $value) {
|
||||
$staffInfo = ListManagement::findOne($value->staff_id);
|
||||
$res = json_decode(file_get_contents($ip . "/api/oem/face_recognition", false, stream_context_create([
|
||||
$res = json_decode(file_get_contents($ip . "/api/oem/face_recognition?token=" . $tk, false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
|
@ -333,19 +353,62 @@ class ApiController extends Controller {
|
|||
}
|
||||
|
||||
public function actionGetTotalFeature() {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
Yii::$app->response->format = "json";
|
||||
$start = $this->getCurrentTime();
|
||||
$statistics = ListManagement::statisticFeatures();
|
||||
$finish = $this->getCurrentTime();
|
||||
$processTime = round(($finish - $start), 4);
|
||||
return [
|
||||
"statistics" => $statistics,
|
||||
"processTime" => $processTime
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionCurrentCache() {
|
||||
return file_get_contents("http://localhost:2305/current-cache");
|
||||
}
|
||||
|
||||
public function actionSaveToken() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$post = Yii::$app->request->bodyParams;
|
||||
$token = \app\models\SyncUrl::findOne(['key_config' => 'token']);
|
||||
if ($token) {
|
||||
$token->data = $post['token'];
|
||||
$token->save();
|
||||
} else {
|
||||
$model = new \app\models\SyncUrl();
|
||||
$model->create([
|
||||
'key_config' => "token",
|
||||
'data' => $post['token']
|
||||
]);
|
||||
}
|
||||
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();
|
||||
$total128 = $total512 = 0;
|
||||
foreach ($lists as $key => $value) {
|
||||
$extract = false;
|
||||
$images = json_decode($value->image, true);
|
||||
$newImgs = [];
|
||||
foreach ($images as $k => $v) {
|
||||
if (isset($v['features']) && count($v['features']) > 0)
|
||||
$total128++;
|
||||
if (isset($v['features512']) && count($v['features512']) > 0)
|
||||
$total512++;
|
||||
$v['features512'] = [];
|
||||
$newImgs[] = $v;
|
||||
}
|
||||
$value->image = json_encode($newImgs);
|
||||
$value->save();
|
||||
}
|
||||
return ["total" => count($lists), "128" => $total128, "512" => $total512];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ class ListManagementController extends Controller {
|
|||
// if (!is_object($last))
|
||||
// $last = (object) ['id' => 0];
|
||||
// $idAuto = $data['data']['box_id'] . "_" . ($last->id + 1);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
|
@ -71,7 +72,7 @@ class ListManagementController extends Controller {
|
|||
'typeArray' => ListManagement::$typeArray,
|
||||
'genderArray' => ListManagement::$genderArray,
|
||||
// 'idAuto' => $idAuto,
|
||||
"staffArray" => ListManagement::staffArray()
|
||||
"staffArray" => ListManagement::staffArray(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -547,6 +548,7 @@ class ListManagementController extends Controller {
|
|||
}
|
||||
$totalFinish = $this->getCurrentTime();
|
||||
$processTime["total"] = round(($totalFinish - $totalStart), 4);
|
||||
$processTime["id"] = strval($data['idStaff']);
|
||||
return $processTime; //["status" => true];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,4 +128,28 @@ class ListManagement extends \yii\db\ActiveRecord {
|
|||
return $f;
|
||||
}
|
||||
|
||||
public static function statisticFeatures() {
|
||||
$lists = self::find()->all();
|
||||
$total128 = $total512 = $totalImg = $img = 0;
|
||||
foreach ($lists as $key => $value) {
|
||||
$images = json_decode($value->image, true);
|
||||
if (count($images) > 0)
|
||||
$totalImg++;
|
||||
$img += count($images);
|
||||
foreach ($images as $k => $v) {
|
||||
if (isset($v['features']) && count($v['features']) > 0)
|
||||
$total128++;
|
||||
if (isset($v['features512']) && count($v['features512']) > 0)
|
||||
$total512++;
|
||||
}
|
||||
}
|
||||
return [
|
||||
"total" => count($lists),
|
||||
"totalImg" => $totalImg,
|
||||
"img" => $img,
|
||||
"128" => $total128,
|
||||
"512" => $total512
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
<input type="hidden" value="{Url::to(["/list-management/sync-feature-to-server"])}" name="sync_feature_to_server_url">
|
||||
<input type="hidden" value="{Url::to(["/list-management/sync-feature-from-device"])}" name="sync_feature_from_device_url">
|
||||
<input type="hidden" value="{Url::to(["/list-management/update-feature"])}" name="update_feature_url">
|
||||
<input type="hidden" value="{Url::to(["/api/get-total-feature"])}" name="get_total_feature_url">
|
||||
<div class="row">
|
||||
<div class="col-md-10" style="max-height: 850px;overflow-y: auto;">
|
||||
{GridView::widget([
|
||||
|
@ -189,6 +190,27 @@
|
|||
</div>
|
||||
<span class="help-block hidden"></span>
|
||||
</div>
|
||||
<hr style="border-top: 1px solid #000;">
|
||||
<table class="table table-bordered" style="background: #fff;">
|
||||
<tr>
|
||||
<td>Số người có ảnh / tổng</td>
|
||||
<td class="text-right" id="totalPeople">
|
||||
{*<b class="text-red">{$statistics.totalImg}</b>/<b>{$statistics.total}</b>*}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Đặc trưng 1</td>
|
||||
<td class="text-right" id="total128">
|
||||
{* <b class="text-red">{$statistics.128}</b>/<b>{$statistics.img}</b>*}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Đặc trưng 2</td>
|
||||
<td class="text-right" id="total512">
|
||||
{* <b class="text-red">{$statistics.512}</b>/<b>{$statistics.img}</b>*}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 300px;position: absolute;" id="menu" class="hidden">
|
||||
|
|
|
@ -16,8 +16,8 @@ $(function () {
|
|||
});
|
||||
btnImage();
|
||||
$("#Code").select2();
|
||||
getTotalFeature();
|
||||
});
|
||||
|
||||
function _search(e) {
|
||||
var location = $(e).attr("data-href"); // + "?from=" + $("input[name='From']").val() + "&to=" + $("input[name='To']").val();
|
||||
location = location + "?id=" + $("input[name='IDSearch']").val();
|
||||
|
@ -555,10 +555,11 @@ function syncFeatureToServer(id, fullData) {
|
|||
id: id
|
||||
},
|
||||
success: function (data) {
|
||||
if (data.status != 10000) {
|
||||
error++;
|
||||
console.log(error);
|
||||
}
|
||||
console.log(data);
|
||||
// if (data.status != 10000) {
|
||||
// error++;
|
||||
// console.log(error);
|
||||
// }
|
||||
progressToServer++;
|
||||
$("#progress-current").html(parseInt($("#progress-current").html()) + 1);
|
||||
var percent = parseInt(progressToServer / totalsToServer * 100);
|
||||
|
@ -601,3 +602,18 @@ function removeFilters() {
|
|||
$("#filter-from-server").val('').trigger('change');
|
||||
checkAllSync(false);
|
||||
}
|
||||
|
||||
function getTotalFeature() {
|
||||
$.ajax({
|
||||
url: $("input[name='get_total_feature_url']").val(),
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
$("#totalPeople").html(`<b class="text-red">` + data.statistics.totalImg + `</b>/<b>` + data.statistics.total + `</b>`);
|
||||
$("#total128").html(`<b class="text-red">` + data.statistics["128"] + `</b>/<b>` + data.statistics.img + `</b>`);
|
||||
$("#total512").html(`<b class="text-red">` + data.statistics["512"] + `</b>/<b>` + data.statistics.img + `</b>`);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user