diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 4225bbaa..0655b8cd 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -893,6 +893,7 @@ class PD_Controller extends REST_Controller $pd_details['completed_on'] = date('Y-m-d H:i:s'); log_message('ERROR', "In PD Controller (When Completed status means calling to Make FaceBoundingBox fns below"); // $this->toMakeFaceBoundingBox($exist_pd_details); + $this->toMakeFaceBoundingBox($pd_details['pd_id'],$exist_pd_details[0]['fk_lender_id']); 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'); if(isset($pd_details['random_string'])){ @@ -4644,6 +4645,11 @@ class PD_Controller extends REST_Controller } else { $data['pd_images']['common_images'] = $this->PD_Model->getSignedPDDocsURL($pdid, null, null, 'common', null, 'report'); } + $db_result = $this->PD_Model->selectCustomRecords(array('facecrop'), array('fk_pd_id' => $pdid,'isactive'=>1), PDAPPLICANTSDETAILS); + $string = $db_result[0]['facecrop']; + // echo gettype($string); + $my_array = json_decode($string, true); + $data['facecrop'] = $my_array; // echo "i ahve image"; // print_r($data['pd_images']);die(); $t = 'DEFAULT DATA'; @@ -5795,23 +5801,25 @@ 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']; + $db_result = $this->PD_Model->selectCustomRecords(array('facecrop'), array('fk_pd_id' => $pdid,'isactive'=>1), PDAPPLICANTSDETAILS); + $string = $db_result[0]['facecrop']; // echo gettype($string); $my_array = json_decode($string, true); + $data['facecrop'] = $my_array; // 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($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(); @@ -5827,10 +5835,6 @@ class PD_Controller extends REST_Controller } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-RI') { $t = $this->load->view('report_templates/JSONTOREPORT_RI', $data, true); } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-DI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-AI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SEP_INDV') { - // $fields = array('facecompare_result'); - // $where_condition_array = array('pd_id' => $pdid); - // $data['face_compare'] = json_decode($this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDTRIGGER), true); - // print_r($data['face_compare']); $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI', $data, true); } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SAL') { $t = $this->load->view('report_templates/JSONTOREPORT_SAL', $data, true); @@ -10493,102 +10497,128 @@ 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']; + // 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 + log_message('ERROR', "In PD Controller (to Make FaceBoundingBox called ) PDID : " . $pdid); - $bounding_box = array(); - $img_response = array(); - if (!empty($pdid)) { - //$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); - $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)); - 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']; - } - } - if(!empty($my_array) && !empty($my_array["SourceImageFace"])) { - $bounding_box['source_image'] = $my_array["SourceImageFace"]['BoundingBox']; + $where = array('isactive' => 1, 'fk_form_id' => 18, 'fk_pd_id' => $pdid); + $details = $this->PD_Model->selectCustomRecords(array('json'), $where, PDFORMDETAILSJSON); + // echo "I have"; + // print_r($rec);die(); + $applicant_id_arr = array(); + if (isset($details[0]['json'])) { + $json = json_decode($details[0]['json'], true); + foreach ($json['individuals'] as $key => $value) { + if ($value['is_person_met'] == 1) { + array_push($applicant_id_arr, $value['pd_co_applicant_id']); } + } + } - $where_condition_array = array('fk_pd_id' => $pdid, 'isactive' => 1); - $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); + $where_condition_array = array('fk_pd_id' => $pdid, 'isactive' => 1); + $where_condition_array['faceapi_result is NOT NULL'] = null; + if(!empty($applicant_id_arr)){ + $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(count($img_result)>0){ - for ($i = 0; $i < count($img_result); $i++) { - $bucketname = LENDER_BUCKET_NAME_PREFIX . $master_details[0]['fk_lender_id']; - $file_name = $img_result[$i]['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)) { - file_put_contents($destination_path.$file_name, file_get_contents($singed_uri)); + if (!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++) { + $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']); + $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)); + 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']; } - $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); - - - $response = faceapi::toMakeFaceBoundingBox($bounding_box,$destination_path,$file_name,$img_result[$i]['image_key']); - array_push($img_response,$response); - if (($img_result[$i]['image_key'] == 'selfie_with_person_met')) { - $this->uploadPicInS3($pdid,$destination_path,$bucketname,$extension); - } - - // faceapi::toMakeFaceBoundingBox($bounding_box,$destination_path,$file_name); - // $this->uploadPicInS3($pdid,$comparisonImages[$i],$destination_path,$bucketname); - - // $comparisonImages = faceapi::toGetFaceComparison($temp_image_name, $bounding_box, $destination_path,$source_image_bounding_box); - // if(count($comparisonImages)>0){ - // for ($i = 0; $i < count($comparisonImages); $i++) { - // // $this->uploadPicInS3($pdid,$comparisonImages[$i],$destination_path,$bucketname); - // } - // } - } - $this->db->WHERE('pd_id', $pdid)->UPDATE(PDTRIGGER, array('facecompare_result' => json_encode($img_response))); - // $this->PD_Model->updateRecords(['facecompare_result' => json_encode($res_data)],PDTRIGGER,$where_condition_array); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['msg'] = 'Success '; - $data['dbRecords'] = $img_result; - $data['arrDetails'] = $bounding_box; - $data['imgResponse'] = $img_response; - } else{ - log_message('ERROR', "In PD Controller to Make FaceBoundingBox No Images On DB"); - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'Faceapi Image Already Generated'; + if (!empty($my_array) && !empty($my_array["SourceImageFace"])) { + $bounding_box['source_image'] = $my_array["SourceImageFace"]['BoundingBox']; + } + + $where_condition_array = array('fk_pd_id' => $pdid, 'isactive' => 1); + $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); + + if (count($img_result) > 0) { + for ($i = 0; $i < count($img_result); $i++) { + $bucketname = LENDER_BUCKET_NAME_PREFIX . $len_id; + $file_name = $img_result[$i]['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)) { + 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); + + + $response = faceapi::toMakeFaceBoundingBox($bounding_box, $destination_path, $file_name, $img_result[$i]['image_key']); + array_push($img_response, $response); + if (($img_result[$i]['image_key'] == 'selfie_with_person_met')) { + $this->uploadPicInS3($pdid, $destination_path, $bucketname, $extension); + } + + // faceapi::toMakeFaceBoundingBox($bounding_box,$destination_path,$file_name); + // $this->uploadPicInS3($pdid,$comparisonImages[$i],$destination_path,$bucketname); + + // $comparisonImages = faceapi::toGetFaceComparison($temp_image_name, $bounding_box, $destination_path,$source_image_bounding_box); + // if(count($comparisonImages)>0){ + // for ($i = 0; $i < count($comparisonImages); $i++) { + // // $this->uploadPicInS3($pdid,$comparisonImages[$i],$destination_path,$bucketname); + // } + // } + + } + $update_where = array('pd_id', $pdid,'pd_co_applicant_id'=>$apcntid); + $this->PD_Model->updateRecords(['facecompare_result' => 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; + // $data['msg'] = 'Success '; + // $data['dbRecords'] = $img_result; + // $data['arrDetails'] = $bounding_box; + // $data['imgResponse'] = $img_response; + } else { + log_message('ERROR', "In PD Controller to Make FaceBoundingBox No Images On DB"); + // $data['dataStatus'] = false; + // $data['status'] = REST_Controller::HTTP_NO_CONTENT; + // $data['msg'] = 'Faceapi Image Already Generated'; + } + } 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'; } - - } 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'; } } else { - log_message('ERROR', "In PD Controller to Make FaceBoundingBox PDID is Not Available"); + 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'] = 'PDID is Not Available'; + //$data['msg'] = 'Applicant is Not Available'; } - $this->response($data,REST_Controller::HTTP_OK); + + // $this->response($data, REST_Controller::HTTP_OK); } public function uploadPicInS3($pdid,$destination_path,$bucketname,$extension){ diff --git a/api/application/controllers/Test.php b/api/application/controllers/Test.php index 727281f2..7d87ebb1 100644 --- a/api/application/controllers/Test.php +++ b/api/application/controllers/Test.php @@ -84,6 +84,7 @@ class Test extends REST_Controller { $pdid = $this->post('pdid'); $src = $this->post('src'); $dest = $this->post('dest'); + $coapplicant = $this->post('applicant_id'); $src_url_type = $this->post('src_url_type'); $dest_url_type = $this->post('dest_url_type'); $res_data = array('nxt_action' => null); @@ -135,8 +136,9 @@ class Test extends REST_Controller { } } //update face api result in main table - $where_condition_array = array('pd_id' => $pdid); - $this->PD_Model->updateRecords(['faceapi_result' => json_encode($res_data)],PDTRIGGER,$where_condition_array); + //$where_condition_array = array('pd_id' => $pdid);// pdid coapplicant id get store in coapp + $where_condition_array = array('pd_id' => $pdid,'isactive' => 1,'pd_co_applicant_id' => $coapplicant); + $this->PD_Model->updateRecords(['faceapi_result' => json_encode($res_data)],PDAPPLICANTSDETAILS,$where_condition_array); //delete local files if created if($dest_url_type == 'base64') diff --git a/api/application/helpers/faceapi_helper.php b/api/application/helpers/faceapi_helper.php index 2ef4859f..2a331cd4 100644 --- a/api/application/helpers/faceapi_helper.php +++ b/api/application/helpers/faceapi_helper.php @@ -2,142 +2,184 @@ class faceapi { - public static function toMakeFaceBoundingBox($image_name,$BoundingBox,$destination_path){ - log_message('ERROR',"In faceapi helper @ line no : 6 to Make FaceBoundingBox"); - $get_image_format = explode(".",$image_name); - $image_format = $get_image_format[1]; - log_message('ERROR','In faceapi helper @ line no : 9 to Make FaceBoundingBox image_format :'.$image_format); - // print_r($get_image_format);die(); - $img = imagecreatefrompng($destination_path); - // if($image_format == 'png'){ - // $img = imagecreatefrompng($destination_path); - // }else if($image_format == 'jpeg'){ - // $img = imagecreatefromjpeg($destination_path); - // }else if($image_format == 'jpg'){ - // $img = imagecreatefromjpg($destination_path); - // } - - $red = imagecolorallocate($img, 255, 0, 0); - $black = imagecolorallocate($img, 0, 0, 0); - $white = imagecolorallocate($img, 255, 255, 255); - - list($imagewidth, $imageheight) = getimagesize($destination_path); - log_message('ERROR','In faceapi helper @ line no : 25 to Make FaceBoundingBox image_width'.$imagewidth.'image_height'.$imageheight); - for($i=0;$i 0) { + $response = array(); + $CmpBoundingBox = $bounding_box['compare_image']; + $file_path = $path . $file_name; + $info = getimagesize($file_path); + $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; + if (!copy($file_path, $destination_path)) { + log_message('ERROR', 'failed to copy'); + } + $img = imagecreatefrompng($destination_path); + + for ($i = 0; $i < count($CmpBoundingBox); $i++) { + + $Left_coordinate = ($CmpBoundingBox[$i]['Left'] * $imagewidth); + $Top_coordinate = ($CmpBoundingBox[$i]['Top'] * $imageheight); + $Face_width = ($CmpBoundingBox[$i]['Width'] * $imagewidth); + $Face_height = ($CmpBoundingBox[$i]['Height'] * $imageheight); + $Similarity = $CmpBoundingBox[$i]['Similarity']; + + $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); + array_push($response,$data); + + } + $d['compare_image'] = $response; + return $d; + } else { + $destination_path = $path . 'src_image' . $extension; + if (!copy($file_path, $destination_path)) { + log_message('ERROR', 'failed to copy'); + } + $img = imagecreatefrompng($destination_path); + + $Left_coordinate = ($SrcBoundingBox['Left'] * $imagewidth); + $Top_coordinate = ($SrcBoundingBox['Top'] * $imageheight); + $Face_width = ($SrcBoundingBox['Width'] * $imagewidth); + $Face_height = ($SrcBoundingBox['Height'] * $imageheight); + $Similarity = 0; + + $x1 = $Left_coordinate; + $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); + unlink($destination_path); + $response['source_image'] = $data; + return $response; + } } - - } - public static function DrawLine($x1,$y1,$Face_width,$Face_height,$Similarity,$img,$destination_path){ - log_message('ERROR','In faceapi helper @ line no : 45 Draw Line x1 : '.$x1.' y1 : '.$y1.' Face_width : '.$Face_width.' Face_height : '.$Face_height.' Similarity : '.$Similarity.' img : '.$img.' destination_path : '.$destination_path); - $Similarity_split = explode(".",$Similarity); + public static function DrawLine($x1, $y1, $Face_width, $Face_height, $Similarity, $img, $destination_path) + { + log_message('ERROR', 'In faceapi helper @ line no : 45 Draw Line x1 : ' . $x1 . ' y1 : ' . $y1 . ' Face_width : ' . $Face_width . ' Face_height : ' . $Face_height . ' Similarity : ' . $Similarity . ' img : ' . $img . ' destination_path : ' . $destination_path); + $Similarity_split = explode(".", $Similarity); $Similarity_value = $Similarity_split[0]; list($imagewidth, $imageheight) = getimagesize($destination_path); - if($Similarity_value >= 70 ){// above 70 green + if ($Similarity_value >= 70) { // above 70 green $color = imagecolorallocate($img, 0, 153, 0); - }else if($Similarity_value < 70 ){// below 70 red + } else if ($Similarity_value < 70) { // below 70 red $color = imagecolorallocate($img, 255, 0, 0); } $white = imagecolorallocate($img, 255, 255, 255); - log_message('ERROR','In faceapi helper @ line no : 45 Draw Line color : '.$color); - $Similarity = $Similarity_value." %"; + log_message('ERROR', 'In faceapi helper @ line no : 45 Draw Line color : ' . $color); + $Similarity = $Similarity_value . " %"; //TOP LINe $t_x1 = $x1; $t_y1 = $y1; - $t_x2 = ($x1+$Face_width); + $t_x2 = ($x1 + $Face_width); $t_y2 = $y1; - + //bottom line $b_x1 = $x1; - $b_y1 = ($y1+$Face_height); - $b_x2 = ($x1+$Face_width); - $b_y2 = ($y1+$Face_height); + $b_y1 = ($y1 + $Face_height); + $b_x2 = ($x1 + $Face_width); + $b_y2 = ($y1 + $Face_height); - $imgl = self::imagelinethick($img,$t_x1,$t_y1,$t_x2,$t_y2,$color,7);//top line - $imgl = self::imagelinethick($img,$b_x1,$b_y1,$b_x2,$b_y2,$color,7);//bottom line - $imgl = self::imagelinethick($img,$t_x1,$t_y1,$b_x1,$b_y1,$color,7);//left line - $imgl = self::imagelinethick($img,$t_x2,$t_y2,$b_x2,$b_y2,$color,7);//right line + $imgl = self::imagelinethick($img, $t_x1, $t_y1, $t_x2, $t_y2, $color, 7); //top line + $imgl = self::imagelinethick($img, $b_x1, $b_y1, $b_x2, $b_y2, $color, 7); //bottom line + $imgl = self::imagelinethick($img, $t_x1, $t_y1, $b_x1, $b_y1, $color, 7); //left line + $imgl = self::imagelinethick($img, $t_x2, $t_y2, $b_x2, $b_y2, $color, 7); //right line // apppath / doc la roboto.tff - $font = APPPATH."docs/roboto.ttf"; - // imagettftext($img, 20, 0, ($t_x1), ($t_y1-5), $color,$font, $Similarity); + $font = APPPATH . "docs/roboto.ttf"; + // imagettftext($img, 20, 0, ($t_x1), ($t_y1-5), $color,$font, $Similarity); // imagepng($img, $destination_path); // imagepng($img, "face4.png"); - // imagefilledrectangle($img, $t_x1-5, $t_y1-18, $t_x1+28, $t_y1, $white); + // imagefilledrectangle($img, $t_x1-5, $t_y1-18, $t_x1+28, $t_y1, $white); // imagettftext($img, 10, 10, ($t_x1), ($t_y1-5), $color,$font, $Similarity); - imagefilledrectangle($img, $t_x1-5, $t_y1-30, $t_x1+60, $t_y1, $white); - imagettftext($img, 17, 8, ($t_x1), ($t_y1-5), $color,$font, $Similarity); - - $get_image_format = explode(".",$destination_path); + imagefilledrectangle($img, $t_x1 - 5, $t_y1 - 30, $t_x1 + 60, $t_y1, $white); + imagettftext($img, 17, 8, ($t_x1), ($t_y1 - 5), $color, $font, $Similarity); + + $get_image_format = explode(".", $destination_path); $image_format = $get_image_format[1]; - if($image_format == 'png'){ - imagepng($img, $destination_path); - }else if($image_format == 'jpeg'){ - imagejpeg($img, $destination_path); - }else if($image_format == 'jpg'){ + if ($image_format == 'png') { + imagepng($img, $destination_path); + } else if ($image_format == 'jpeg') { + imagejpeg($img, $destination_path); + } else if ($image_format == 'jpg') { // $destination_path = $get_image_format[0].".jpeg"; - imagejpg($img, $destination_path); + imagejpg($img, $destination_path); } - + // $image_data = file_get_contents($destination_path); + // $base64 = base64_encode($image_data); + // return array('name' => $temp_image_name, 'base64' => $base64, 'Similarity' => $Similarity); } public static function imagelinethick($image, $x1, $y1, $x2, $y2, $color, $thick = 1) -{ - /* this way it works well only for orthogonal lines + { + /* this way it works well only for orthogonal lines imagesetthickness($image, $thick); return imageline($image, $x1, $y1, $x2, $y2, $color); */ - if ($thick == 1) { - return imageline($image, $x1, $y1, $x2, $y2, $color); - } - $t = $thick / 2 - 0.5; - if ($x1 == $x2 || $y1 == $y2) { - return imagefilledrectangle($image, round(min($x1, $x2) - $t), round(min($y1, $y2) - $t), round(max($x1, $x2) + $t), round(max($y1, $y2) + $t), $color); - } - $k = ($y2 - $y1) / ($x2 - $x1); //y = kx + q - $a = $t / sqrt(1 + pow($k, 2)); - $points = array( - round($x1 - (1+$k)*$a), round($y1 + (1-$k)*$a), - round($x1 - (1-$k)*$a), round($y1 - (1+$k)*$a), - round($x2 + (1+$k)*$a), round($y2 - (1-$k)*$a), - round($x2 + (1-$k)*$a), round($y2 + (1+$k)*$a), - ); - imagefilledpolygon($image, $points, 4, $color); - 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); + if ($thick == 1) { + return imageline($image, $x1, $y1, $x2, $y2, $color); } -} - + $t = $thick / 2 - 0.5; + if ($x1 == $x2 || $y1 == $y2) { + return imagefilledrectangle($image, round(min($x1, $x2) - $t), round(min($y1, $y2) - $t), round(max($x1, $x2) + $t), round(max($y1, $y2) + $t), $color); + } + $k = ($y2 - $y1) / ($x2 - $x1); //y = kx + q + $a = $t / sqrt(1 + pow($k, 2)); + $points = array( + round($x1 - (1 + $k) * $a), round($y1 + (1 - $k) * $a), + round($x1 - (1 - $k) * $a), round($y1 - (1 + $k) * $a), + round($x2 + (1 + $k) * $a), round($y2 - (1 - $k) * $a), + round($x2 + (1 - $k) * $a), round($y2 + (1 + $k) * $a), + ); + imagefilledpolygon($image, $points, 4, $color); + return imagepolygon($image, $points, 4, $color); + } + public static function imgCrop($x1, $y1, $Face_width, $Face_height, $Similarity, $img, $destination_path, $i) + { + $temp_image_name = $i === null ? "id_proof_crop.png" : "face_crop_" . $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); + $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); + } + $image_data = file_get_contents($destination_path_2); + $base64 = base64_encode($image_data); + unlink($destination_path_2); + // if($i === null){ + return array('name' => $temp_image_name, 'base64' => $base64, 'Similarity' => $Similarity); + // }else{ + // return array($i => array('name' => $temp_image_name, 'base64' => $base64, 'Similarity' => $Similarity)); + // } + // return array('name' => $temp_image_name, 'base64' => $base64, 'Similarity' => $Similarity); + // unlink($destination_path); + } } -?> \ No newline at end of file diff --git a/api/application/views/report_templates/JSONTOREPORT_DI_AI.php b/api/application/views/report_templates/JSONTOREPORT_DI_AI.php index b9a3e68b..763ed39a 100644 --- a/api/application/views/report_templates/JSONTOREPORT_DI_AI.php +++ b/api/application/views/report_templates/JSONTOREPORT_DI_AI.php @@ -1,7 +1,6 @@ @@ -474,7 +473,10 @@ $loan_word = $pd_master_details[0]['lender_short_name'] != 'CFPL' ? 'Loan' : 'Fa padding: 5px; /*margin: 10px;*/ } - +.facecrop { + height: 100px; + width: 600px; +} /* ######### TOOLTIP CSS END ######### */ @@ -732,6 +734,32 @@ if ( isset($pdf) ) { ?>
+ Face Comparison" ; + $notequal_mark =''; + $equal_mark ='='; + for ($i = 0; $i < count($ci); $i++) { + $symbol = (round($ci[$i]["Similarity"]) > 50) ? '

'.$equal_mark.'

': '

'.$notequal_mark.'

'; + echo '
'; + echo ''.$si['; + echo $symbol; + // if(round($ci[$i]["Similarity"]) > 50){ echo '

'.$equal_mark.'

'; }else{ echo '

'.$notequal_mark.'

'; } + echo ''.$ci[$i]['; + echo '
'; + echo '
+
+ '.round($ci[$i]["Similarity"]).' +
+
'; + } + // echo '
'; + // ########################### End of Percentage Bar Section ######################################### + } + ?>

Applicants:

@@ -5113,30 +5141,6 @@ if($total_no_of_business > 0) { echo "
"; } // ########################### End Of Score Card Section ######################################### -// ########################### Percentage Bar Section ######################################### -// print_r($faceapi_result); -// echo "**********************"; -// print_r($bounding_box); -echo '
-

Face Comparison

'; - $equal_mark =''; - $notequal_mark ='='; - - echo ''; - echo $equal_mark; - echo ''; - echo '
-
- 70% -
-
'; - echo ''; - echo $notequal_mark; - echo ''; - -echo'
'; - -// ########################### End of Percentage Bar Section ######################################### ?>