Face Compare report Changes : 1

This commit is contained in:
VE10-Sanjeev 2022-09-10 22:18:23 +05:30
parent 44cc68da0a
commit 9d8e793e56
3 changed files with 96 additions and 39 deletions

View File

@ -842,8 +842,6 @@ class PD_Controller extends REST_Controller
EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_details['pd_id']);
$exist_pd_details = $this->PD_Model->getPDMasterDetails($pd_details['pd_id']);
// print_r($pd_details);
// print_r($exist_pd_details);
if (!file_exists($this->external_path . '/pd_reports/' . $pd_details['pd_id'])) {
mkdir($this->external_path . '/pd_reports/' . $pd_details['pd_id'], 0777);
}
@ -891,9 +889,9 @@ class PD_Controller extends REST_Controller
if (isset($pd_details['pd_status']) && (($pd_details['pd_status'] == COMPLETED) || ($pd_details['pd_status'] == ADD_ON_PENDING))) {
if ($pd_details['pd_status'] == COMPLETED) {
// $pd_details['complete_override_data'] = json_encode($pd_details['complete_override_data']);
$pd_details['complete_override_data'] = isset($pd_details['complete_override_data']) ? json_encode($pd_details['complete_override_data']) : null;
$pd_details['completed_on'] = date('Y-m-d H:i:s');
log_message('ERROR', "In PD Controller @ line no : 992 (When Completed status means calling to Make FaceBoundingBox fns below");
log_message('ERROR', "In PD Controller (When Completed status means calling to Make FaceBoundingBox fns below");
$this->toMakeFaceBoundingBox($exist_pd_details);
if(isset($pd_details['is_this_smc_pd']) && $pd_details['is_this_smc_pd'] == 1 && $pd_details['pd_status'] == COMPLETED){
$this->load->helper('smc_creditpd');
@ -5798,6 +5796,24 @@ class PD_Controller extends REST_Controller
}
}
$db_result = $this->PD_Model->selectCustomRecords(array('faceapi_result'), array('pd_id' => $pdid), PDTRIGGER);
$string = $db_result[0]['faceapi_result'];
// echo gettype($string);
$my_array = json_decode($string, true);
// echo gettype($my_array);
if (!empty($my_array) && !empty($my_array["FaceMatches"])) {
$data['faceapi_result'] = $my_array;
$arr = $my_array["FaceMatches"];
log_message('ERROR', "In PD Controller to Make FaceBoundingBox FaceMatches array cnt : " . count($arr));
for ($i = 0; $i < count($arr); $i++) {
$data['bounding_box'][$i] = $arr[$i]['Face']['BoundingBox'];
$data['bounding_box'][$i]['Similarity'] = $arr[$i]['Similarity'];
}
}else{
$data['faceapi_result'] = array();
$data['bounding_box'] = array();
}
// print_r($data['add_on_pd_images']);
// die();
@ -5844,8 +5860,8 @@ class PD_Controller extends REST_Controller
$t = $this->load->view('report_templates/JSONTOREPORT_DI_AI_ADDON', $data, true);
}
//$t = $this->load->view('temp_html.html',null,true);
echo $data['pd_master_details'][0]['customer_segment_abbr'];
echo $data['pd_master_details'][0]['fk_pd_type'];
// echo $data['pd_master_details'][0]['customer_segment_abbr'];
// echo $data['pd_master_details'][0]['fk_pd_type'];
echo $t;
die();
@ -10474,17 +10490,17 @@ class PD_Controller extends REST_Controller
// public function toMakeFaceBoundingBox_get(){
public function toMakeFaceBoundingBox($master_details)
{
// $pdid = $this->get('pd');//pdid 3184 comment this
$pdid = $master_details[0]['pd_id'];
log_message('ERROR', "In PD Controller @ line no : 11951 (to Make FaceBoundingBox called ) PDID : " . $pdid);
public function toMakeFaceBoundingBox_get(){
// public function toMakeFaceBoundingBox($master_details)
// {
$pdid = $this->get('pd');//pdid 3184 comment this
// $pdid = $master_details[0]['pd_id'];
log_message('ERROR', "In PD Controller (to Make FaceBoundingBox called ) PDID : " . $pdid);
$bounding_box = array();
if (!empty($pdid)) {
// $master_details = $this->PD_Model->getPDMasterDetails($pdid);//comment this
if ($master_details[0]['facemark_image_generated'] == 0) {
log_message('ERROR', "In PD Controller @ line no : 11956 Facemark Image Generated : " . $master_details[0]['facemark_image_generated']);
$master_details = $this->PD_Model->getPDMasterDetails($pdid);//comment this
if ($master_details[0]['facemark_image_generated']) {
log_message('ERROR', "In PD Controller Facemark Image Generated : " . $master_details[0]['facemark_image_generated']);
$db_result = $this->PD_Model->selectCustomRecords(array('faceapi_result'), array('pd_id' => $pdid), PDTRIGGER);
$string = $db_result[0]['faceapi_result'];
// echo gettype($string);
@ -10492,7 +10508,7 @@ class PD_Controller extends REST_Controller
// echo gettype($my_array);
if (!empty($my_array) && !empty($my_array["FaceMatches"])) {
$arr = $my_array["FaceMatches"];
log_message('ERROR', "In PD Controller @ line no : 11964 to Make FaceBoundingBox FaceMatches array cnt : " . count($arr));
log_message('ERROR', "In PD Controller to Make FaceBoundingBox FaceMatches array cnt : " . count($arr));
for ($i = 0; $i < count($arr); $i++) {
$bounding_box[$i] = $arr[$i]['Face']['BoundingBox'];
$bounding_box[$i]['Similarity'] = $arr[$i]['Similarity'];
@ -10504,7 +10520,7 @@ class PD_Controller extends REST_Controller
$bucketname = LENDER_BUCKET_NAME_PREFIX . $master_details[0]['fk_lender_id'];
$key = 'pd' . $pdid . '/' . $img_result[0]['pd_document_name'];
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, '+30 minutes');
log_message('ERROR', "In PD Controller @ line no : 11973 to Make FaceBoundingBox FaceMatches singed_uri : " . $singed_uri);
log_message('ERROR', "In PD Controller to Make FaceBoundingBox FaceMatches singed_uri : " . $singed_uri);
// $temp_image_name = "sample.png";
$temp_image_name = "face_api_image.jpeg";
@ -10518,35 +10534,34 @@ class PD_Controller extends REST_Controller
$bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile);
$s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data);
log_message('ERROR', "In PD Controller @ line no : 11990 to Make FaceBoundingBox FaceMatches s3result : " . $s3result['@metadata']['statusCode']);
log_message('ERROR', "In PD Controller to Make FaceBoundingBox FaceMatches s3result : " . $s3result['@metadata']['statusCode']);
// print_r($s3result);die();
if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) {
log_message('ERROR', "In PD Controller @ line no : 11996 to Make FaceBoundingBox updating pdtrigger table facemark_image_generated as 1");
log_message('ERROR', "In PD Controller to Make FaceBoundingBox updating pdtrigger table facemark_image_generated as 1");
//Update
$this->db->WHERE('pd_id', $pdid)->UPDATE(PDTRIGGER, array('facemark_image_generated' => 1));
log_message('ERROR', "In PD Controller @ line no : 11998 to Make FaceBoundingBox save document table face_api_result_image after unlink");
log_message('ERROR', "In PD Controller to Make FaceBoundingBox save document table face_api_result_image after unlink");
$record_data = array('fk_pd_id' => $pdid, 'pd_document_title' => 'face_api_result_image', 'pd_document_name' => $temp_image_name);
$this->PD_Model->saveRecords($record_data, PDDOCUMENTS);
unlink($destination_path);
}
// $data['dataStatus'] = true;
// $data['status'] = REST_Controller::HTTP_OK;
// $data['msg'] = 'Success ';
// $data['details'] = $bounding_box;
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['msg'] = 'Success ';
$data['details'] = $bounding_box;
} else {
log_message('ERROR', "In PD Controller @ line no : 12009 to Make FaceBoundingBox Faceapi Image Already Generated");
// $data['dataStatus'] = false;
// $data['status'] = REST_Controller::HTTP_NO_CONTENT;
// $data['msg'] = 'Faceapi Image Already Generated';
log_message('ERROR', "In PD Controller to Make FaceBoundingBox Faceapi Image Already Generated");
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'Faceapi Image Already Generated';
}
} else {
log_message('ERROR', "In PD Controller @ line no : 12016 to Make FaceBoundingBox PDID is Not Available");
// $data['dataStatus'] = false;
// $data['status'] = REST_Controller::HTTP_NO_CONTENT;
// $data['msg'] = 'PDID is Not Available';
log_message('ERROR', "In PD Controller to Make FaceBoundingBox PDID is Not Available");
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'PDID is Not Available';
}
// $this->response($data,REST_Controller::HTTP_OK);
$this->response($data,REST_Controller::HTTP_OK);
}
}

View File

@ -35,6 +35,7 @@ class faceapi
$y1 = $Top_coordinate;
self::DrawLine($x1,$y1,$Face_width,$Face_height,$Similarity,$img,$destination_path);
self::imgCrop($x1,$y1,$Face_width,$Face_height,$Similarity,$img,$destination_path,$i);
}
@ -119,6 +120,24 @@ class faceapi
return imagepolygon($image, $points, 4, $color);
}
public static function imgCrop($x1,$y1,$Face_width,$Face_height,$Similarity,$img,$destination_path,$i){
$temp_image_name = "face_crop_".$i.".jpeg";
log_message('ERROR','In faceapi helper - imgCrop @ line no : 126 x1 : '.$x1.' y1 : '.$y1.' Face_width : '.$Face_width.' Face_height : '.$Face_height.' Similarity : '.$Similarity.' img : '.$img.' destination_path : '.$destination_path);
$destination_path_2 = preg_replace('#/\w+(\.\w+)$#', '/'.$temp_image_name, $destination_path);
log_message('ERROR','In faceapi helper - imgCrop @ line no : 126 destination_path b4 : '.$destination_path.' destination_path after : '.$destination_path_2);
$to_crop_array = array('x' =>$x1 , 'y' => $y1, 'width' => $Face_width, 'height'=> $Face_height);
$dest = imagecrop($img, $to_crop_array);
$get_image_format = explode(".",$destination_path);
$image_format = $get_image_format[1];
if($image_format == 'png'){
imagepng($dest, $destination_path_2);
}else if($image_format == 'jpeg'){
imagejpeg($dest, $destination_path_2);
}else if($image_format == 'jpg'){
imagejpg($dest, $destination_path_2);
}
}
}
?>

View File

@ -9,6 +9,10 @@ $loan_word = $pd_master_details[0]['lender_short_name'] != 'CFPL' ? 'Loan' : 'Fa
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Merriweather" rel="stylesheet">
<style type="text/css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
@ -5109,14 +5113,33 @@ if($total_no_of_business > 0) {
echo "</table>";
}
// ########################### End Of Score Card Section #########################################
// ########################### Percentage Bar Section #########################################
// print_r($faceapi_result);
// echo "**********************";
// print_r($bounding_box);
echo '<div class="container">
<h2>Face Comparison</h2>';
$equal_mark ='<span style="font-family: DejaVu Sans; sans-serif;font-size:12px">≠</span>';
$notequal_mark ='<span style="font-family: DejaVu Sans; sans-serif;font-size:12px">=</span>';
echo '<img src="admin:///opt/lampp/htdocs/ssa_external_data/testing/pd_reports/3287/IDproofV1.jpg" width="300" height="200" alt=""/>';
echo $equal_mark;
echo '<img src="admin:///opt/lampp/htdocs/ssa_external_data/testing/pd_reports/3287/face_crop_0.jpeg" width="300" height="200" alt=""/>';
echo '<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:70%">
70%
</div>
</div>';
echo '<img src="admin:///opt/lampp/htdocs/ssa_external_data/testing/pd_reports/3287/IDproofV1.jpg" width="300" height="200" alt=""/>';
echo $notequal_mark;
echo '<img src="admin:///opt/lampp/htdocs/ssa_external_data/testing/pd_reports/3287/face_crop_1.jpeg" width="300" height="200" alt=""/>';
echo'</div>';
?>
// ########################### End of Percentage Bar Section #########################################
?>
</body>
</html>