I am rendering a Property Detail page like below (can be accessed Here)
I have an image slider and a 360 Image viewer. Currently the user uploads both type of images manually i.e plain images from one interface and 360 images from other interface. I check if the property has 360 images and display them using the panorama viewer.
I use the following Controller to upload the 360 Images which is similar to uploading plain images.
public function upload_360_images()
{
if($this->session->userdata['id'] && $this->session->userdata['type']=='user')
{
if($_FILES)
{
if(isset($_FILES['files'])){
$data['errors']= array();
$extensions = array("jpeg","jpg","png");
foreach($_FILES['files']['tmp_name'] as $key => $tmp_name ){
$file_name = $key.$_FILES['files']['name'][$key];
$file_size =$_FILES['files']['size'][$key];
$file_tmp =$_FILES['files']['tmp_name'][$key];
$file_type=$_FILES['files']['type'][$key];
/*$file_ext=explode('.',$_FILES['image']['name'][$key]) ;
$file_ext=end($file_ext);*/
$i=1;
if($file_size > 7097152){
$data['errors'][$i]='File '.$i.' size must be less than 7 MB';
$i++;
}
$desired_dir="uploads";
if(empty($data['errors'])==true){
if(is_dir($desired_dir)==false){
mkdir("$desired_dir", 0700); // Create directory if it does not exist
}
if(is_dir("$desired_dir/".$file_name)==false){
move_uploaded_file($file_tmp,"uploads/".$file_name);
$this->post_model->add360Image('property_360_images',$file_name,$this->uri->segment(3));
}else{ //rename the file if another one exist
$new_dir="uploads/".$file_name.time();
rename($file_tmp,$new_dir) ;
}
}else{
$data['contact']=$this->admin_model->getContactDetails();
$data['images']=$this->post_model->getProperty360Images($this->uri->segment(3));
$data['title']='My Profile Image';
$this->load->view('site/static/head',$data);
$this->load->view('site/static/header');
$this->load->view('site/content/upload_360_images');
$this->load->view('site/static/footer');
$this->load->view('site/static/footer_links');
}
}
if(empty($data['errors']))
{
redirect(base_url().'dashboard');
}
else
{
$data['contact']=$this->admin_model->getContactDetails();
$data['images']=$this->post_model->getProperty360Images($this->uri->segment(3));
$data['title']='My Profile Image';
$this->load->view('site/static/head',$data);
$this->load->view('site/static/header');
$this->load->view('site/content/upload_360_images');
$this->load->view('site/static/footer');
$this->load->view('site/static/footer_links');
}
}
}
else
{
$data['contact']=$this->admin_model->getContactDetails();
$data['images']=$this->post_model->getProperty360Images($this->uri->segment(3));
$data['title']='My Profile Image';
$this->load->view('site/static/head',$data);
$this->load->view('site/static/header');
$this->load->view('site/content/upload_360_images');
$this->load->view('site/static/footer');
$this->load->view('site/static/footer_links');
}
}
else
{
redirect(base_url().'user/login');
}
}
Please ignore the long code, this code is from a production so i have to put a lot of checks and conditions.
Problem Now my employer wants me to use single interface to upload both plain and 360 images and detect the nature of the image using some detection algorithm and then display the image in the same image slider which I am using for static/plain images.
Research
I read this thread on Stackoverflow which made a little sense about reading the meta data of the file using EXIF tool but that makes this process pretty manual.
Question
I want to automate that image reading use it in my php image upload code or write that detection algorithm in a function which gets image name as parameter and return the image type as plain or 360. Based on that return I can easily render the views. So My question is how to do that detection in php?
To auto detect faces in a photo and draw pink box around the faces with a php script running a linux centos server. Please note that face detection and face recognition are two different things. To recognize a face you have to first detect a face and then do the required processing. PHP facedetect extension is very simple.
In some scenarios with web application development it may be necessary to be able to detect the facial features of a photo. For example an application that detects how many people are in a picture, or perhaps an app that modifies the faces of the people in a photo.
I have given multiple frontal detection photos to the script and the script performed well, despite few false face detections. One sample output file is shown below with the pink boxes detected by the script as faces. Unfortunately i can only show the blurred faces because of personal reasons.
In the current post we will look into a PHP port of a JavaScript face detection algorithm without using openCV. Since the code is completed written in PHP it cannot attain the raw speed that C,C++ provides, but for many trivial application a PHP version can do. Before reading further you can download the code below.
According to Facebook 360 Group:
There isn't yet a standard for tagging a photo as containing 360 content.
It suggest that you look for the EXIF tag
Projection Type : equirectangular
You can also look for
Use Panorama Viewer : True
Those two tags are present on photos taken with my LG 360.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With