change menu

This commit is contained in:
2022-10-14 09:41:42 +07:00
parent 982db2b6c8
commit d6d7dc3719
6 changed files with 63 additions and 63 deletions

View File

@@ -109,7 +109,8 @@ class ApiController extends Controller {
'method' => "POST",
'content' => json_encode([
'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName)),
'data' => common::rsaEncode($text)
'data' => common::rsaEncode($text),
'confidence' => isset($post["confidence"]["percent1"]) ? $post["confidence"]["percent1"] : 0
])
]
])), true);
@@ -149,7 +150,7 @@ class ApiController extends Controller {
}
$allFeatures[] = [
"id" => $value->id,
"object_id" => $value->staff_id,
"object_id" => $value->staff_id,
"name" => $this->convert_vi_to_en($value->name),
"feature1" => $feature1,
"feature2" => $feature2
@@ -353,6 +354,7 @@ class ApiController extends Controller {
foreach ($ls as $key => $value) {
if (file_exists("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)) {
$staffInfo = ListManagement::findOne($value->staff_id);
$confidence = json_decode($value->confidence, true);
$res = json_decode(file_get_contents($ip . "/api/oem/face_recognition?token=" . $tk, false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
@@ -364,7 +366,8 @@ class ApiController extends Controller {
'idCard' => $staffInfo ? strval($staffInfo->code) : "0",
'idObject' => $staffInfo ? $staffInfo->staff_id : "",
"person_id" => "123",
"timezone" => "+7"
"timezone" => "+7",
'confidence' => isset($confidence['percent1']) ? floatval($confidence['percent1']) : 0
])
]
])), true);

View File

@@ -117,4 +117,39 @@ class CaptureLogsController extends Controller {
throw new NotFoundHttpException(Yii::t("app", "KHONG_TIM_THAY_THONG_TIN"));
}
public function actionFaceComparison() {
if (Yii::$app->request->post()) {
$post = Yii::$app->request->post();
Yii::$app->response->format = "json";
$results = json_decode(file_get_contents("http://192.168.1.43:2305/compare", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode([
"type" => "base64",
"img0" => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web" . $post['face1'])),
"img1" => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web" . $post['face2']))
])
]
])), true);
return [
"type1" => number_format($results['type1']['percent'] * 100, 2),
"type2" => number_format($results['type2']['percent'] * 100, 2)
];
} else {
$this->view->title = Yii::t("app", "SO_SANH_MAT");
return $this->render('face-comparison', [
]);
}
}
public function actionUploadFace() {
if (Yii::$app->request->post()) {
$post = Yii::$app->request->post();
$model = new \app\models\UploadForm();
$url = $model->UploadGlobal("image" . $post['imageIndex'], ["PNG", "JPG", "JPEG", "GIF"], "comparison");
return $url;
}
}
}

View File

@@ -927,39 +927,4 @@ class ListManagementController extends Controller {
}
}
public function actionFaceComparison() {
if (Yii::$app->request->post()) {
$post = Yii::$app->request->post();
Yii::$app->response->format = "json";
$results = json_decode(file_get_contents("http://192.168.1.43:2305/compare", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode([
"type" => "base64",
"img0" => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web" . $post['face1'])),
"img1" => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web" . $post['face2']))
])
]
])), true);
return [
"type1" => number_format($results['type1']['percent'] * 100, 2),
"type2" => number_format($results['type2']['percent'] * 100, 2)
];
} else {
$this->view->title = Yii::t("app", "SO_SANH_MAT");
return $this->render('face-comparison', [
]);
}
}
public function actionUploadFace() {
if (Yii::$app->request->post()) {
$post = Yii::$app->request->post();
$model = new \app\models\UploadForm();
$url = $model->UploadGlobal("image" . $post['imageIndex'], ["PNG", "JPG", "JPEG", "GIF"], "comparison");
return $url;
}
}
}