Giter Site home page Giter Site logo

openalpr-server's People

Contributors

adrianlthomas avatar samuelbr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

openalpr-server's Issues

Update for latest php forms version

Hi Mate, thanks for this - I needed to update to the following to get it to work. I also removed the "data" element so I could use this as an LPR endpoint for AgentDVR.

If anyone wants a free alpr for AgentDVR then use this. Wonder if search results pick up comments?

And sorry - code tags not working for some reason....

`

//Shorten
define('DS',DIRECTORY_SEPARATOR);

/**
from https://raw.githubusercontent.com/stefanvangastel/openalpr-php-rest-api/master/check.php
*/

/**

  • Check tmp dir and write permissions
    */
    if( ! file_exists('tmp') ){

    if( ! mkdir('tmp') ){
    //Try to create
    $response['error']= 'Error: Cannot create tmp dir in current dir, please check webserver permissions.';
    respond($response);
    }
    }

/**

  • Check exec and ALPR command
    */
    if( ! function_exists("exec")){
    $response['error']= 'Error: php exec not available, safe mode?';
    respond($response);
    }

if( empty(run('/usr/local/bin/alpr --version')) ){
$mypath = run('echo $PATH');
$response['error']= 'Error: alpr command not found, is it installed and in your PATH? PATH:' . $mypath[0] . $alpr[0];
respond($response);
}

/**

  • Check POSTED data.
    */
    if( empty($_FILES['upload']) ){
    var_dump($_REQUEST);
    var_dump($_POST);
    var_dump($_FILES);
    $response['error']= 'Error: No image data recieved. Please send a base64 encoded image' ;
    respond($response);
    }

/**

  • Save image to disk (tmp)
    */
    if (move_uploaded_file($_FILES['upload']['tmp_name'], 'tmp'.DS.'check.jpg')) {
    //echo "File is valid, and was successfully uploaded.\n";
    } else {
    $POSTVARS = var_dump($_POST);
    $response['error']= 'Error: Failed saving image to disk, please check webserver permissions.' . $POSTVARS;
    respond($response);
    }

/**

  • Run ALPR command on image
    */
    $result = run('alpr --country au --json tmp'.DS.'check.jpg');

/**

  • Remove image
    */
    unlink('tmp'.DS.'check.jpg');

/**

  • Check result.
    */
    if( empty( $result[sizeof($result)-1] ) ){
    $response['error']= 'Error: ALPR returned no result:'+$result;
    respond($response);
    }

//Add results to response
//var_dump($result);
//$response['data'] = json_decode( $result[sizeof($result)-1], TRUE);
$response = json_decode( $result[sizeof($result)-1], TRUE);

//Respond with results
respond($response);

/**

  • Aux functions
    */

//Sets headers and responds json
function respond($response){
header('Access-Control-Allow-Origin: *');
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/json');

echo json_encode($response);
exit;

}

//Runs command and returns output
function run($command){
$output = array();
exec($command,$output);
return $output;
}
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.