update lay vecto 512 ngam
This commit is contained in:
@@ -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() {
|
||||
Yii::$app->response->format = "json";
|
||||
$lists = ListManagement::find()->all();
|
||||
$total128 = $total512 = 0;
|
||||
foreach ($lists as $key => $value) {
|
||||
$images = json_decode($value->image, true);
|
||||
foreach ($images as $k => $v) {
|
||||
if (isset($v['features']) && count($v['features']) > 0)
|
||||
$total128++;
|
||||
if (isset($v['features512']) && count($v['features512']) > 0)
|
||||
$total512++;
|
||||
}
|
||||
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();
|
||||
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();
|
||||
}
|
||||
return ["total" => count($lists), "128" => $total128, "512" => $total512];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user