RealTime LPR response

Monakhov

n3wb
Joined
Feb 3, 2017
Messages
3
Reaction score
0
Hi guys! Need help!
Can anyone explain how to get real time plate number from DS-2CD4026FWDP-IRA in text or XML via SDK or ISAPI?

I`m reading SDK, ISAPI and so on but all I can is GET requests like http://admin:admin123@192.168.0.67/ISAPI/Traffic/channels/1/vehicleDetect/plates, with response "<subStatusCode>badXmlContent</subStatusCode>"

SDK for C++ doesn`t help at all because i`m newguy in programming

maybe someone have working piece of code and can share with me or have some explanation more useful for me
 

tangent

IPCT Contributor
Joined
May 12, 2016
Messages
4,338
Reaction score
3,519
Sorry I haven't seen that documented anywhere, but the docs are a few years old. I'd suggest you stick to the term Hikvision uses "ANPR" in your searches, it might yield better results.
 
Last edited:

Monakhov

n3wb
Joined
Feb 3, 2017
Messages
3
Reaction score
0
Sorry for my language

Here we go:

1) My IPC setted for getting LPR by Alarm trigger
2) I connected button to AlarmInput

PHP:
<?php
   set_time_limit(60); //time for script exec
 
   $input_xml = '<AfterTime></AfterTime>';
   $url = "http://admin:admin123@192.168.0.67/ISAPI/Traffic/channels/1/vehicleDetect/plates";
     $array_data = array('0' => 0);
   echo '<HTML>
       <head>
           <title>ANPR</title>
           <link href="style.css" rel="stylesheet">
       </head>
       <body>
       <table><tr><th>captureTime</th><th>plateNumber</th><th>plateCountry</th></tr>'; //table head
 
    while (isset($array_data)) { //main cycle. I think its ugly((
     
       if (isset($lastNumberObject['captureTime'])) {
           $prevTime[$i] = $lastNumberObject['captureTime'];
       }   else $prevTime[$i] = 0;

       $now_day = date("Ymd");
       $now_time = date("His", time() + 3599); // I have little trouble with timezone on IPC. and i work with camera in NOW-TIME minus 1 second (while script gets result passing 1 sec)

// Next - curl options
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POSTFIELDS, "xmlRequest=" . $input_xml);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
        $data = curl_exec($ch);
        
        // Making readable result
        $array_data = json_decode(json_encode(simplexml_load_string($data)), true);
     
        //...
        $lastNumber = count($array_data['Plate'])-1;
        $lastNumberObject = $array_data['Plate'][$lastNumber];
     
        // Getting true capture time
        $capture_time = substr($lastNumberObject['picName'], 0, -1);
     
       // Checking + some magic)) and output result string by string while main cycle working
        if ($lastNumberObject['captureTime']==$now_day."T".$now_time."+0200") {             
            echo '<tr><td>'.$lastNumberObject['captureTime'].'</td><td>'.$lastNumberObject['plateNumber'].'</td><td>'.$lastNumberObject['country'].'</td><td><img src="ftp://192.168.0.109:2121/192.168.0.67/anpr-ftp/'.$capture_time.'_'.$lastNumberObject['plateNumber'].'.jpg"></td></tr>';
           break;
           flush();
           curl_close($ch);
     
       }
       }
     
// Finishing html table
    echo '</table>
       </body>
       </HTML>';

?>
This code is making HTML table whith CaptureTime, PlateNumber and PlateNumber Country in a realtime. When I press the button camera get about 20-30 identical results
If I add if checking for capture time to skip same data, script shows needed data just after full exec (set_time_limit(60))

Maybe someone can help me edit this code to work better (maybe AJAX)
 
Last edited:

rizome

n3wb
Joined
Nov 19, 2019
Messages
1
Reaction score
0
Location
UK
I`m reading SDK, ISAPI and so on but all I can is GET requests like , with response "<subStatusCode>badXmlContent</subStatusCode>"

POST for the method not get, a get will never give any content to the http server ;)

And the xml is like :

Code:
<AfterTime><picTime>0</picTime></AfterTime>
Hi can you please give more info on how you got this to work, I am trying to do exactly the same thing and I am getting the same error, I am using the following XML POST method using Postman and I am hitting the ANPR camera via the NVR:

http://<username>:<password>@192.xxx.x.xx:XXXX/ISAPI/Traffic/channels/n/vehicleDetect/plates

<?xml version:"1.0" encoding="UTF-8"?>
xmlns:"http=/www.isapi.org/ver20/XMLSchema">
<AfterTime>:
<picTime>2019-11-19T22:00:00Z</picTime>
</AfterTime>:

Response I get is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<ResponseStatus version="2.0" xmlns="">
<requestURL>/ISAPI/Traffic/channels/1/vehicleDetect/plates</requestURL>
<statusCode>6</statusCode>
<statusString>Invalid XML Content</statusString>
<subStatusCode>badXmlContent</subStatusCode>
</ResponseStatus>

Many Thanks!
 
Joined
Jun 27, 2020
Messages
1
Reaction score
0
Location
Latvia
<?php
$username = 'xxxxx';
$password = 'yyyyy';

$url = "";



$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch,CURLOPT_TIMEOUT, 30);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "<AfterTime version=\"2.0\"><picTime>2020-06-20T00:00:00Z</picTime></AfterTime>");
$first_response = curl_exec($ch);
$info = curl_getinfo($ch);

preg_match('/WWW-Authenticate: Digest (.*)/', $first_response, $matches);

if(!empty($matches))
{
$auth_header = $matches[1];
$auth_header_array = explode(',', $auth_header);
$parsed = array();

foreach ($auth_header_array as $pair)
{
$vals = explode('=', $pair);
$parsed[trim($vals[0])] = trim($vals[1], '" ');
}

$response_realm = (isset($parsed['realm'])) ? $parsed['realm'] : "";
$response_nonce = (isset($parsed['nonce'])) ? $parsed['nonce'] : "";
$response_opaque = (isset($parsed['opaque'])) ? $parsed['opaque'] : "";

$authenticate1 = md5($username.":".$response_realm.":".$password);
$authenticate2 = md5("POST:".$url);

$authenticate_response = md5($authenticate1.":".$response_nonce.":".$authenticate2);

$request = sprintf('Authorization: Digest username="%s", realm="%s", nonce="%s", opaque="%s", uri="%s", response="%s"',
$username, $response_realm, $response_nonce, $response_opaque, $url, $authenticate_response);

$request_header = array($request);
$request_header[] = 'Content-Type:application/json';

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch,CURLOPT_TIMEOUT, 30);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, "<AfterTime version=\"2.0\"><picTime>2020-06-20T00:00:00Z</picTime></AfterTime>");
curl_setopt($ch, CURLOPT_HTTPHEADER, $request_header);

$result['response']= curl_exec($ch);

print_r($result['response']);

}
?>
 
Top