code committed : ps
This commit is contained in:
parent
9d8e793e56
commit
fe900188dc
@ -892,7 +892,7 @@ class PD_Controller extends REST_Controller
|
||||
$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 (When Completed status means calling to Make FaceBoundingBox fns below");
|
||||
$this->toMakeFaceBoundingBox($exist_pd_details);
|
||||
// $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');
|
||||
if(isset($pd_details['random_string'])){
|
||||
@ -4649,7 +4649,6 @@ class PD_Controller extends REST_Controller
|
||||
$t = 'DEFAULT DATA';
|
||||
// if(!count($add_on_pd))
|
||||
// {
|
||||
|
||||
if ($data['pd_master_details'][0]['fk_pd_type'] == 1) //Full PD
|
||||
{
|
||||
|
||||
@ -5828,6 +5827,10 @@ 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);
|
||||
@ -10497,6 +10500,7 @@ class PD_Controller extends REST_Controller
|
||||
// $pdid = $master_details[0]['pd_id'];
|
||||
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']) {
|
||||
@ -10510,45 +10514,67 @@ class PD_Controller extends REST_Controller
|
||||
$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[$i] = $arr[$i]['Face']['BoundingBox'];
|
||||
$bounding_box[$i]['Similarity'] = $arr[$i]['Similarity'];
|
||||
$bounding_box['compare_image'][$i] = $arr[$i]['Face']['BoundingBox'];
|
||||
$bounding_box['compare_image'][$i]['Similarity'] = $arr[$i]['Similarity'];
|
||||
}
|
||||
}
|
||||
$where_condition_array = array('fk_pd_id' => $pdid, '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);
|
||||
|
||||
$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 to Make FaceBoundingBox FaceMatches singed_uri : " . $singed_uri);
|
||||
|
||||
// $temp_image_name = "sample.png";
|
||||
$temp_image_name = "face_api_image.jpeg";
|
||||
$destination_path = $this->external_path . "/pd_reports/" . $pdid . "/" . $temp_image_name;
|
||||
file_put_contents($destination_path, file_get_contents($singed_uri));
|
||||
|
||||
faceapi::toMakeFaceBoundingBox($temp_image_name, $bounding_box, $destination_path);
|
||||
|
||||
$key = 'pd' . $pdid . '/' . $temp_image_name;
|
||||
$sourcefile = $destination_path;
|
||||
|
||||
$bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile);
|
||||
$s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data);
|
||||
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 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 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);
|
||||
if(!empty($my_array) && !empty($my_array["SourceImageFace"])) {
|
||||
$bounding_box['source_image'] = $my_array["SourceImageFace"]['BoundingBox'];
|
||||
}
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['msg'] = 'Success ';
|
||||
$data['details'] = $bounding_box;
|
||||
|
||||
$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 . $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));
|
||||
}
|
||||
$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';
|
||||
}
|
||||
|
||||
} else {
|
||||
log_message('ERROR', "In PD Controller to Make FaceBoundingBox Faceapi Image Already Generated");
|
||||
$data['dataStatus'] = false;
|
||||
@ -10564,4 +10590,27 @@ class PD_Controller extends REST_Controller
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
|
||||
}
|
||||
|
||||
public function uploadPicInS3($pdid,$destination_path,$bucketname,$extension){
|
||||
$file = 'face_api_image'.$extension;
|
||||
$key = 'pd' . $pdid . '/' . $file;
|
||||
$sourcefile = $destination_path.$file;
|
||||
|
||||
$bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile);
|
||||
$s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data);
|
||||
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 to Make FaceBoundingBox updating pdtrigger table facemark_image_generated as 1");
|
||||
// Make inactive old entries with same data
|
||||
$this->db->WHERE('fk_pd_id', $pdid)
|
||||
->WHERE('pd_document_title', 'face_api_result_image')->UPDATE(PDDOCUMENTS, array('isactive' => 0));
|
||||
// then update
|
||||
$this->db->WHERE('pd_id', $pdid)->UPDATE(PDTRIGGER, array('facemark_image_generated' => 1));
|
||||
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' => $file);
|
||||
$this->PD_Model->saveRecords($record_data, PDDOCUMENTS);
|
||||
unlink($destination_path.$file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user