Face Compare report Changes 4 : ps

This commit is contained in:
VE10-Sanjeev 2022-09-18 21:20:32 +05:30
parent def80961cc
commit 1316fb4496
2 changed files with 45 additions and 37 deletions

View File

@ -10498,11 +10498,11 @@ class PD_Controller extends REST_Controller
// public function toMakeFaceBoundingBox_get(){
public function toMakeFaceBoundingBox($pdid,$len_id){
// $pdid = $this->get('pd');//comment this bcoz test purpose
// $master_details = $this->PD_Model->getPDMasterDetails($pdid);//comment this bcoz test purpose
// $len_id = $master_details[0]['fk_lender_id'];//comment this bcoz test purpose
public function toMakeFaceBoundingBox($pdid,$len_id){
// $pdid = $this->get('pd'); //comment this bcoz test purpose
// $master_details = $this->PD_Model->getPDMasterDetails($pdid); //comment this bcoz test purpose
// $len_id = $master_details[0]['fk_lender_id']; //comment this bcoz test purpose
log_message('ERROR', "In PD Controller (to Make FaceBoundingBox called ) PDID : " . $pdid);
$where = array('isactive' => 1, 'fk_form_id' => 18, 'fk_pd_id' => $pdid);
$details = $this->PD_Model->selectCustomRecords(array('json'), $where, PDFORMDETAILSJSON);
@ -10524,23 +10524,26 @@ class PD_Controller extends REST_Controller
$where_condition_array['pd_co_applicant_id in ('.implode(",",$applicant_id_arr).')'] = null;
}
$applicants_details = $this->PD_Model->selectCustomRecords(array('pd_co_applicant_id', 'applicant_name', 'faceapi_result', 'facemark_image_generated', 'facecrop'), $where_condition_array, PDAPPLICANTSDETAILS);
if (!empty($applicants_details) && !empty($pdid)) {
// print_r($applicants_details);die();
// echo "working fine";
if (!empty($applicant_id_arr) && !empty($applicants_details) && !empty($pdid)) {
log_message('ERROR', "In PD Controller (to Make FaceBoundingBox called ) Total Applicant : " . count($applicants_details));
for ($j = 0; $j < count($applicants_details); $j++) {
log_message('ERROR', "In PD Controller (to Make FaceBoundingBox called ) Total Person Met Applicant : " . count($applicant_id_arr));
for ($j = 0; $j < count($applicants_details); $j++) {
$bounding_box = array();
$img_response = array();
$apcntid = $applicants_details[$j]['pd_co_applicant_id'];
//$master_details = $this->PD_Model->getPDMasterDetails($pdid);//comment this
if ($applicants_details[$j]['facemark_image_generated']) {
log_message('ERROR', "In PD Controller Facemark Image Generated : " . $applicants_details[$j]['facemark_image_generated']);
if (!$applicants_details[$j]['facemark_image_generated']) {
log_message('ERROR', $applicants_details[$j]['applicant_name'] . " Facemark Image Generated : " . $applicants_details[$j]['facemark_image_generated']);
$string = $applicants_details[$j]['faceapi_result'];
// echo gettype($string);
$my_array = json_decode($string, true);
// echo gettype($my_array);
if (!empty($my_array) && !empty($my_array["FaceMatches"])) {
$arr = $my_array["FaceMatches"];
log_message('ERROR', "In PD Controller to Make FaceBoundingBox FaceMatches array cnt : " . count($arr));
log_message('ERROR', $applicants_details[$j]['applicant_name'] . " FaceMatched array cnt : " . count($arr));
for ($i = 0; $i < count($arr); $i++) {
$bounding_box['compare_image'][$i] = $arr[$i]['Face']['BoundingBox'];
$bounding_box['compare_image'][$i]['Similarity'] = $arr[$i]['Similarity'];
@ -10550,31 +10553,36 @@ class PD_Controller extends REST_Controller
$bounding_box['source_image'] = $my_array["SourceImageFace"]['BoundingBox'];
}
$where_condition_array = array('fk_pd_id' => $pdid, 'isactive' => 1);
$where_condition_array = array('fk_pd_id' => $pdid, 'isactive' => 1,'co_applicant_id'=>$apcntid);
$where_condition_array['image_key in ("selfie_with_person_met","person_met_id")'] = null;
$select_col = array('pd_document_id', 'pd_document_name', 'pd_document_title', 'image_key');
$img_result = $this->PD_Model->selectCustomRecords($select_col, $where_condition_array, PDDOCUMENTS);
// print_r($this->db->last_query());
// echo count($img_result);
// print_r($img_result);
if (count($img_result) > 0) {
for ($i = 0; $i < count($img_result); $i++) {
for ($k = 0; $k < count($img_result); $k++) {
$bucketname = LENDER_BUCKET_NAME_PREFIX . $len_id;
$file_name = $img_result[$i]['pd_document_name'];
$file_name = $img_result[$k]['pd_document_name'];
$key = 'pd' . $pdid . '/' . $file_name;
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, '+30 minutes');
$destination_path = $this->external_path . "/pd_reports/" . $pdid . "/";
if (!file_exists($destination_path . $file_name)) {
(!is_dir($destination_path)) ? mkdir($destination_path, 0777) : '';
file_put_contents($destination_path . $file_name, file_get_contents($singed_uri));
}
$info = getimagesize($destination_path . $file_name);
$extension = image_type_to_extension($info[2]);
// echo '-- extension'.$extension.$file_name;
log_message('ERROR', "In PD Controller to Make FaceBoundingBox FaceMatches inx " . $i . " singed_uri : " . $singed_uri);
log_message('ERROR', "In PD Controller to Make FaceBoundingBox FaceMatches inx " . $k . " singed_uri : " . $singed_uri);
$response = faceapi::toMakeFaceBoundingBox($bounding_box, $destination_path, $file_name, $img_result[$i]['image_key']);
// echo $j.$k;
$response = faceapi::toMakeFaceBoundingBox($bounding_box, $destination_path, $file_name, $img_result[$k]['image_key'], $apcntid);
array_push($img_response, $response);
if (($img_result[$i]['image_key'] == 'selfie_with_person_met')) {
$this->uploadPicInS3($pdid, $destination_path, $bucketname,$apcntid);
if (($img_result[$k]['image_key'] == 'selfie_with_person_met')) {
$this->uploadPicInS3($pdid, $destination_path, $bucketname, $applicants_details[$j]['pd_co_applicant_id']);
}
// faceapi::toMakeFaceBoundingBox($bounding_box,$destination_path,$file_name);
@ -10588,8 +10596,8 @@ class PD_Controller extends REST_Controller
// }
}
$update_where = array('fk_pd_id'=>$pdid,'pd_co_applicant_id'=>$apcntid);
$this->PD_Model->updateRecords(['facecrop' => json_encode($img_response)], PDAPPLICANTSDETAILS, $update_where);
$update_where = array('fk_pd_id' => $pdid, 'pd_co_applicant_id' => $apcntid);
$this->PD_Model->updateRecords(['facecrop' => json_encode($img_response)], PDAPPLICANTSDETAILS, $update_where);
log_message('ERROR', "In PD Controller to Make FaceBoundingBox Done");
// $data['dataStatus'] = true;
// $data['status'] = REST_Controller::HTTP_OK;
@ -10605,16 +10613,16 @@ class PD_Controller extends REST_Controller
}
} else {
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';
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'Faceapi Image Already Generated 2';
}
}
} // for @ $applicants_details = j
} else {
log_message('ERROR', "In PD Controller to Make FaceBoundingBox Applicant is Not Available");
//$data['dataStatus'] = false;
//$data['status'] = REST_Controller::HTTP_NO_CONTENT;
//$data['msg'] = 'Applicant is Not Available';
// $data['dataStatus'] = false;
// $data['status'] = REST_Controller::HTTP_NO_CONTENT;
// $data['msg'] = 'Applicant is Not Available';
}
@ -10622,7 +10630,7 @@ class PD_Controller extends REST_Controller
}
public function uploadPicInS3($pdid,$destination_path,$bucketname,$apcntid){
$file = "face_api_image.jpeg";
$file = "face_api_image_".$apcntid.".jpeg";
$key = 'pd' . $pdid . '/' . $file;
$sourcefile = $destination_path.$file;

View File

@ -2,7 +2,7 @@
class faceapi
{
public static function toMakeFaceBoundingBox($bounding_box, $path, $file_name, $key)
public static function toMakeFaceBoundingBox($bounding_box, $path, $file_name, $key,$apcntid)
{
// ($image_name,$BoundingBox,$destination_path,$extension){
@ -24,7 +24,7 @@ class faceapi
$extension = image_type_to_extension($info[2]);
$SrcBoundingBox = $bounding_box['source_image'];
if (count($CmpBoundingBox) > 0 && ($key == 'selfie_with_person_met')) {
$destination_path = $path . 'face_api_image' . $extension;
$destination_path = $path . 'face_api_image_'.$apcntid . $extension;
if (!copy($file_path, $destination_path)) {
log_message('ERROR', 'failed to copy');
}
@ -41,15 +41,15 @@ class faceapi
$x1 = $Left_coordinate;
$y1 = $Top_coordinate;
$data = self::imgCrop($x1, $y1, $Face_width, $Face_height, $Similarity, $img, $destination_path, $i);
self::DrawLine($x1, $y1, $Face_width, $Face_height, $Similarity, $img, $destination_path);
$data = self::imgCrop($x1, $y1, $Face_width, $Face_height, $Similarity, $img, $destination_path, $i,$apcntid);
self::DrawLine($x1, $y1, $Face_width, $Face_height, $Similarity, $img, $destination_path,$apcntid);
array_push($response,$data);
}
$d['compare_image'] = $response;
return $d;
} else {
$destination_path = $path . 'src_image' . $extension;
$destination_path = $path . 'src_image_'.$apcntid . $extension;
if (!copy($file_path, $destination_path)) {
log_message('ERROR', 'failed to copy');
}
@ -65,7 +65,7 @@ class faceapi
$y1 = $Top_coordinate;
$i = null;
// self::imgCrop($x1,$y1,$Face_width,$Face_height,$path,$file_name,$i);
$data = self::imgCrop($x1, $y1, $Face_width, $Face_height, $Similarity, $img, $destination_path, $i);
$data = self::imgCrop($x1, $y1, $Face_width, $Face_height, $Similarity, $img, $destination_path, $i,$apcntid);
unlink($destination_path);
$response['source_image'] = $data;
return $response;
@ -154,9 +154,9 @@ class faceapi
return imagepolygon($image, $points, 4, $color);
}
public static function imgCrop($x1, $y1, $Face_width, $Face_height, $Similarity, $img, $destination_path, $i)
public static function imgCrop($x1, $y1, $Face_width, $Face_height, $Similarity, $img, $destination_path, $i,$apcntid)
{
$temp_image_name = $i === null ? "id_proof_crop.png" : "face_crop_" . $i . ".png";
$temp_image_name = $i === null ? "id_proof_crop_".$apcntid.".png" : "face_crop_".$apcntid."_" . $i . ".png";
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);