コード例 #1
0
ファイル: Detect.php プロジェクト: bryglen/kairos
 /**
  * @param $response
  * @return Image
  */
 public function populateResponse($response)
 {
     if (!$response) {
         return null;
     }
     $responseArrays = json_decode($response, 1);
     $this->checkError($responseArrays);
     $imageArrays = isset($responseArrays['images']) ? $responseArrays['images'] : [];
     $image = new Image();
     foreach ($imageArrays as $imageArray) {
         $image->setAttributes($imageArray);
         $faces = [];
         foreach ($imageArray['faces'] as $faceArray) {
             $face = new Face();
             $face->setAttributes($faceArray);
             if (isset($faceArray['attributes']['gender'])) {
                 $gender = new Gender();
                 $gender->setAttributes($faceArray['attributes']['gender']);
                 $face->attributes['gender'] = $gender;
             }
             $faces[] = $face;
         }
         $image->faces = $faces;
     }
     return $image;
 }
コード例 #2
0
ファイル: Recognize.php プロジェクト: bryglen/kairos
 /**
  * @param $response
  * @return Image
  */
 public function populateResponse($response)
 {
     if (!$response) {
         return null;
     }
     $responseArrays = json_decode($response, 1);
     $this->checkError($responseArrays);
     $imageArrays = isset($responseArrays['images']) ? $responseArrays['images'] : [];
     $image = new Image();
     foreach ($imageArrays as $imageArray) {
         $image->setAttributes($imageArray);
         $transaction = new Transaction();
         $transaction->setAttributes(isset($imageArray['transaction']) ? $imageArray['transaction'] : []);
         if (isset($imageArray['candidates'])) {
             foreach ($imageArray['candidates'] as $candidateArray) {
                 $candidate = new Candidate();
                 $candidate->setAttributes($candidateArray);
                 $image->candidates[] = $candidate;
             }
         }
     }
     return $image;
 }
コード例 #3
0
ファイル: Enroll.php プロジェクト: bryglen/kairos
 /**
  * @param $response
  * @return Image
  */
 public function populateResponse($response)
 {
     if (!$response) {
         return null;
     }
     $responseArrays = json_decode($response, 1);
     $this->checkError($responseArrays);
     $imageArrays = isset($responseArrays['images']) ? $responseArrays['images'] : [];
     $image = new Image();
     foreach ($imageArrays as $imageArray) {
         $image->setAttributes($imageArray);
         $transaction = new Transaction();
         $transaction->setAttributes(isset($imageArray['transaction']) ? $imageArray['transaction'] : []);
         $gender = null;
         if (isset($imageArray['attributes']['gender'])) {
             $gender = new Gender();
             $gender->setAttributes($imageArray['attributes']['gender']);
         }
         $image->attributes['gender'] = $gender;
         $image->transaction = $transaction;
     }
     return $image;
 }