/**
  * @param $imageId integer Run the algorithm on a single image
  * @param boolean $store Store the result
  * @param MammalClassifier|null $classifier An instance of MammalClassifier
  * @param bool $scientistDataset Whether to store in the scientist dataset table
  * @return array|string The result
  */
 public function runOnImage($imageId, $store, $classifier, $scientistDataset = false)
 {
     if (!$classifier) {
         $classifier = new MammalClassifier(null, $scientistDataset);
     }
     try {
         if ($store) {
             return $classifier->on($imageId)->classify()->store()->getResult();
         } else {
             return $classifier->on($imageId)->classify()->getResult();
         }
     } catch (Exception $e) {
         return "No classifications.";
     }
 }
Beispiel #2
0
<?php

require 'core.php';
$classifier = new MammalClassifier();
// Usage:
/* Create a MammalClassifier object
    -> call on() to specify the id of the image
        this will load up the image classifications from the database
    -> call classify to run the classification algorithm
    -> call store() to store result back in database
    -> call getResult() to get the result

    Order is (most of the time) important!
*/
$controller = new AlgorithmController();
$controller->runAlgorithm();
$id = 311;
while ($id <= 311) {
    $res = $classifier->on($id)->classify()->store()->getResult();
    $id++;
    print "id: " . $id . " =>";
    print_r($res);
    print "\n";
}