4

我喜欢渲染之下的属性详细信息页面(可访问Hereenter image description here自动检测图像360自然在PHP

我有一个形象的滑块和360的图像查看器。目前,用户手动上传两种图像类型,即来自一个界面的纯图像和来自其他界面的360个图像。我查看该酒店是否有360个图像并使用全景浏览器进行显示。

我使用以下控制器上传类似于上传纯文本图像的360图像。

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'); 
    } 

} 

请忽略长代码,这段代码是来自一个生产,所以我必须投入大量的检查和条件。

问题 现在我的老板要我用单一界面来同时上传平原和360张,并使用一些检测算法检测图像的性质,然后在我使用了相同的图像滑块显示图像静态/平原图像。

研究

我读this线#2这使得有关使用EXIF工具读取文件的元数据的意义不大,但使这个过程相当手册。

问题

我要自动执行图像读取使用它在我的PHP图片上传代码或写在其中得到图像名称作为参数的函数检测算法,并返回图像类型为纯或360。根据这一回报,我可以轻松呈现视图。所以我的问题是如何在PHP中做这种检测?

+0

看看exiftool - 显示“视场”,从EXIF标签元信息。虽然不能保证它的存在...... – Hokascha

回答

1

根据Facebook 360 Group

目前还没有用于标记照片作为含有360内容的标准。

它建议您要查找的EXIF标签

Projection Type : equirectangular

你也可以寻找

Use Panorama Viewer : True

这两个标签都存在于我的LG 360拍摄的照片

2

我遇到了单元类似的问题y3D平台,但我认为这是考虑到Equirectangular图像通常具有2:1的比例。

可能的宽度2000像素和1000像素高(I已经看到软件产生高度高一点)。

这里是伪代码,请记住,这个代码考虑POSX和波西从左下角开始:

//this is how much the image should be close the 2:1 proportion, or 0.5-proportionThreshold. 
proportionThreshold = 0.01; 

//images smaller than this should not have resolution enough to be a panorama. 
//it is important here to 
minimumWidth = 2000; 
minimumHeight = 1080; 

//in case of the image is not a panorama, this variable determines the maximum size it could be projected 
maxFill = 0.65; 

//what is the amount of the view the pamorama should view: 
scaleX = 1; 
scaleY = 1; 

//where the panorama should be positioned in the view: 
posX = 0; 
posY = 0; 

currentWidth = source.width; 
currentHeight = source.height; 

if(isFullPanorama()){ 
    Log("Full Panorama"); 
    //the variables are already set for that 
}else if(isPartialPanorama()){ 
    Log("Partial Panorama"); 
    scale = currentHeight/currentWidth * 2f; 
    scaleX = 1; 
    scaleY = scale; 
    posX = 0; 
    posY = 0.5-scale/2; 
}else{ 
    Debug.Log("Not Panorama"); 
    proportion = currentHeight/currentWidth; 
    w = currentWidth > minimumWidth*maxFill ? minimumWidth*maxFill : currentWidth; 
    scaleX = w/minimumWidth/2; 
    scaleY = scaleX * proportion * 2; 
    if(scaleY>1) { 
     h = currentHeight > minimumHeight*maxFill ? minimumHeight*maxFill : currentHeight; 
     scaleY = h/minimumHeight/2; 
     scaleX = scaleY * proportion/2; 
    } 
    posX = 0.5-scaleX/2; 
    posY = 0.5-scaleY/2; 
} 

bool isFullPanorama(){ 
    proportion = currentHeight/currentWidth; 
    return proportion>=0.5-proportionThreshold && 
    proportion<=0.5+proportionThreshold && 
    source.height >= minimumHeight; 
} 

bool isPartialPanorama(){ 
    return currentHeight/currentWidth<=0.5 && 
    source.width >= minimumWidth; 
}