CreditPD json key added 1 : ps
This commit is contained in:
parent
34a5d94fe7
commit
fe632c8cc6
@ -38,6 +38,7 @@ class PD_Controller extends REST_Controller {
|
||||
$this->load->helper('MYUTIL');
|
||||
$this->load->helper('satellite_image');
|
||||
$this->load->library('pdfgenerator');
|
||||
$this->load->helper('faceapi');
|
||||
|
||||
//$this->load->library('excel');
|
||||
$this->load->library('phpmailer_library');
|
||||
@ -11862,6 +11863,57 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post()
|
||||
}
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
public function facemark_get(){
|
||||
$get = $this->get('pd');//pdid 3184
|
||||
$bounding_box = array();
|
||||
if(!empty($get)){
|
||||
$master_details = $this->PD_Model->getPDMasterDetails($get);
|
||||
if($master_details[0]['pd_status'] !== COMPLETED){
|
||||
$db_result = $this->PD_Model->selectCustomRecords(array('faceapi_result'),array('pd_id' => $get),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"];
|
||||
for($i=0;$i<count($arr);$i++){
|
||||
$bounding_box[$i] = $arr[$i]['Face']['BoundingBox'];
|
||||
$bounding_box[$i]['Similarity'] = $arr[$i]['Similarity'];
|
||||
}
|
||||
}
|
||||
$where_condition_array = array('fk_pd_id' => $get,'isactive' => 1,'image_key' => "selfie_with_person_met");
|
||||
$img_result = $this->PD_Model->selectCustomRecords(array('pd_document_id','pd_document_name','pd_document_title','image_key'),$where_condition_array,PDDOCUMENTS);
|
||||
$image_name = $img_result[0]['pd_document_name'];
|
||||
$bucketname = LENDER_BUCKET_NAME_PREFIX.$master_details[0]['fk_lender_id'];
|
||||
$key = 'pd'.$get.'/'.$image_name;
|
||||
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes');
|
||||
$destination_path = $this->external_path."/pd_reports/". $get ."/".$image_name;
|
||||
//$getimage = getcontent first ($singed_uri)
|
||||
$image_name = file_put_contents($destination_path, file_get_contents($singed_uri));
|
||||
// $image_name = "sample.png";
|
||||
// $destination_path = $this->external_path."/pd_reports/". $get ."/".$image_name;
|
||||
|
||||
faceapi::toMakeFaceBoundingBox($image_name,$bounding_box,$destination_path);
|
||||
// save table s3
|
||||
|
||||
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['msg'] = 'Given PDID ';
|
||||
$data['details'] = $bounding_box;
|
||||
}else{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
$data['msg'] = 'Given PDID is Not in Completed Status';
|
||||
}
|
||||
}else{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
$data['msg'] = 'PDID is Not Available';
|
||||
}
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
106
api/application/helpers/faceapi_helper.php
Normal file
106
api/application/helpers/faceapi_helper.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
class faceapi
|
||||
{
|
||||
private static $current_pd_id = null;
|
||||
public static function toMakeFaceBoundingBox($image_name,$BoundingBox,$destination_path){
|
||||
|
||||
$get_image_format = explode(".",$image_name);
|
||||
$image_format = $get_image_format[1];
|
||||
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);
|
||||
|
||||
for($i=0;$i<count($BoundingBox);$i++){
|
||||
|
||||
$Left_coordinate = ($BoundingBox[$i]['Left'] * $imagewidth) ;
|
||||
$Top_coordinate = ($BoundingBox[$i]['Top'] * $imageheight) ;
|
||||
$Face_width = ($BoundingBox[$i]['Width'] * $imagewidth) ;
|
||||
$Face_height = ($BoundingBox[$i]['Height'] * $imageheight) ;
|
||||
$Similarity = round($BoundingBox[$i]['Similarity'])."%";
|
||||
$x1 = $Left_coordinate;
|
||||
$y1 = $Top_coordinate;
|
||||
|
||||
self::DrawLine($x1,$y1,$Face_width,$Face_height,$Similarity,$img,$image_format,$destination_path);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static function DrawLine($x1,$y1,$Face_width,$Face_height,$Similarity,$img,$image_format,$destination_path){
|
||||
// 70 - green
|
||||
// 70 below red
|
||||
$color = imagecolorallocate($img, 0, 153, 0);
|
||||
//TOP LINe
|
||||
$t_x1 = $x1;
|
||||
$t_y1 = $y1;
|
||||
$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);
|
||||
|
||||
$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
|
||||
$string = str_replace("sample.png", "roboto.ttf", $destination_path);
|
||||
imagettftext($img, 20, 0, ($t_x1), ($t_y1-5), $color,$string, $Similarity);
|
||||
|
||||
// imagepng($img, "face4.png");
|
||||
if($image_format == 'png'){
|
||||
imagepng($img, $destination_path);
|
||||
}else if($image_format == 'jpeg'){
|
||||
imagejpeg($img, $destination_path);
|
||||
}else if($image_format == 'jpg'){
|
||||
imagejpg($img, $destination_path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function imagelinethick($image, $x1, $y1, $x2, $y2, $color, $thick = 1)
|
||||
{
|
||||
/* 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@ -34,6 +34,7 @@ class smc_creditpd
|
||||
break;
|
||||
case 8://assest
|
||||
$return_data = SELF::getAssestSectionData($section);
|
||||
// print_r($return_data);
|
||||
break;
|
||||
|
||||
case 11://supplier
|
||||
@ -185,7 +186,9 @@ class smc_creditpd
|
||||
$seven_row = '<tr>'.'<td> Is there a Loan Against the Asset? (Yes / No) </td>';
|
||||
foreach ($json['business_assets_details'] as $key => $value)
|
||||
{
|
||||
|
||||
$json['business_assets_details'][$key]['business_assets_mode_name'] = ( $value['business_assets_mode'] == 1 ? $value['other_asset_description'] : $asset_type [ $value['business_assets_mode'] ]);
|
||||
$json['business_assets_details'][$key]['business_owner_name'] = (isset($value['business_name_of_the_owner']) ? (applicantname_grabber::getApplicantsNameById($value['business_name_of_the_owner'],$applicant_details)): 'NA');
|
||||
|
||||
$description = $value['other_asset_description'];
|
||||
if(isset($value['property_type']))
|
||||
{
|
||||
@ -381,6 +384,7 @@ class smc_creditpd
|
||||
$eight_row = '<tr>'.'<td> Balance Tenure (Mnts) </td>';
|
||||
foreach ($json['existing_loan_details'] as $key => $value)
|
||||
{
|
||||
$json['existing_loan_details'][$key]['business_owner_name'] = (isset($value['business_name_of_the_owner']) ? (applicantname_grabber::getApplicantsNameById($value['business_name_of_the_owner'],$applicant_details)): 'NA');
|
||||
|
||||
$header_row .= '<th>Loan '.($key + 1).'</th>';
|
||||
$first_row .= '<td style="text-align:center;">'. $value['loan_type'] .'</td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user