PHP code example of mgrechanik / image-points-searcher

1. Go to this page and download the library: Download mgrechanik/image-points-searcher library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mgrechanik / image-points-searcher example snippets


try {
  $searcher = new \mgrechanik\imagepointssearcher\Searcher(
    './images/graph.jpg'
  );
  $count = $searcher->run();
  print 'Found - ' . $count;
  $points = $searcher->getPoints();
  var_dump($points);
} catch (Exception $e) {
	
}

try {
  $searcher = new \mgrechanik\imagepointssearcher\Searcher(
    './images/usa.jpg',
    new \mgrechanik\imagepointssearcher\ChoosenColorStrategy(60, 132, 253)
  );
  $count = $searcher->run();
  print 'Found - ' . $count;
  $points = $searcher->getPoints();
  var_dump($points);
} catch (Exception $e) {
	
}

$imageResult = new \mgrechanik\imagepointssearcher\ImageResult($searcher);

// We can set colors
$imageResult->setLabelsColor(1, 14, 230);
$imageResult->setLinesColor(255, 33, 73);
$imageResult->setMarginsColor(255, 106, 0);


// Draw default labels
$imageResult->drawLabels();
// Draw labels with the text we want
$imageResult->drawLabels(function($key, $point) { return "{$point['x']},{$point['y']}";});

// Draw borders of the points we found
$imageResult->drawMargins();

// Draw the path between points
$imageResult->drawPath([2,9,20,28,41,48,44]);

// Save the result as the image. See Demo.
$imageResult->save('./images/result.jpg');