300万高清车牌识别一体机Http推送

搭建PHP服务器,阿里云虚拟Web空间有限制频繁发送数据的策略,WAMP在Windows下即可。分别建立路径:

/devicemanagement/php/receivedeviceinfo.php;

/devicemanagement/php/plateresult.php;

/devicemanagement/php/gio.php;

/devicemanagement/php/serial.php

300万高清车牌识别一体机设置见图:

plateresult.php源代码

<?php
$doc = file_get_contents("php://input");

$fp = fopen("snap_shot.txt", "w");
if(!$fp){
    return;
}
$flag=fwrite($fp, $doc); 
//$flag=fwrite($fp, $jsondecode['AlarmInfoPlate']['result']['PlateResult']['imagePath']); 
if(!$flag) 
{ 
    fclose($fp);
    return;
} 
fclose($fp);

$jsondecode = json_decode($doc,true);

if($jsondecode == null){
    return;
}

// 小图片
if(isset($jsondecode['AlarmInfoPlate']['result']['PlateResult']['imageFragmentFile']))
{
  $small_image = $jsondecode['AlarmInfoPlate']['result']['PlateResult']['imageFragmentFile'];
  if( $small_image != null){
      $fs_image = fopen("smallimage.jpg", "w");
      if(!$fs_image){
          return;
      }
      $simage_decoded = base64_decode($small_image);
      $flag2=fwrite($fs_image, $simage_decoded); 
      fclose($fs_image);
  }
}

// 大图片
if(isset($jsondecode['AlarmInfoPlate']['result']['PlateResult']['imageFile']))
{
  $image = $jsondecode['AlarmInfoPlate']['result']['PlateResult']['imageFile'];
  if( $image != null){
      $fp_image = fopen("image.jpg", "w");
      if(!$fp_image){
          return;
      }
      $image_decoded = base64_decode($image);
      $flag=fwrite($fp_image, $image_decoded); 
      fclose($fp_image);
  }
}

$license = $jsondecode['AlarmInfoPlate']['result']['PlateResult']['license'];
$fp_license  = fopen("license.txt", "w");  //将W改为a参数  追加保存日志,  \r\n  换行
if($fp_license  )
{ 
    $flag=fwrite($fp_license  , $license ); 
    fclose($fp_license);
}

// 发送开闸命令
//echo '{"Response_AlarmInfoPlate":{"info":"ok","content":"...","is_pay":"true"}}';

?>

 

receivedeviceinfo.php源代码 服务器返回给相机心跳包,  是否在线

<?php

echo '{"heartbeat":{"countid":158,"timeStamp":{"Timeval":{"sec":1571932096,"usec":0}},"serialno":"e0fade1063f0fe93"}}';

?>

 两个相机,相隔几秒多次发送数据,排除相同的车号,可以利用session判断

<?php

date_default_timezone_set('PRC'); // 中国时区
$timechuo = date('YmdHis');
$license = $_GET["license"];
session_start();
$_SESSION['name'][$license][]=$timechuo;
//unset($_SESSION['license']);
$nameArray=$_SESSION['name'];
//var_dump($chehaoArray[$license]);
//echo json_encode($nameArray);
if( count($nameArray[$license])==1){
echo "<br>只有一个时间,执行任务";
}
if( count($nameArray[$license])>1){
if ($timechuo-$nameArray[$license][count($nameArray[$license])-2]>15){
echo "<br>时间大于15秒,执行任务";
}else{
echo "<br>有两个时间,但相邻时间未超过15秒,放弃<br>";
}
}

 相机文档:

相机识别到车号后向服务器推送JSON格式数据,利用PHP 的函数file_get_contents("php://input");接收处理逻辑

{"AlarmInfoPlate":{"channel":0,"deviceName":"default","ipaddr":"192.168.0.100","result":{"PlateResult":{"bright":0,"carBright":0,"carColor":0,"colorType":0,"colorValue":0,"confidence":0,"direction":0,"license":"_无_","location":{"RECT":{"bottom":0,"left":0,"right":0,"top":0}},"timeStamp":{"Timeval":{"sec":1441815171,"usec":672241}},"timeUsed":0,"triggerType":1,"type":0}},"serialno":"e10b2d6c8c07b422361457935b518642"}}

 

说明: 字段名

含义

AlarmInfoPlate  

推送结果为车牌识别结果

serialno  

设备序列号

channel  

默认通道号(预留)

deviceName  

设备名称

ipaddr  

设备ip地址

result  

实际数据

PlateResult  

车牌识别信息

license  

车牌号字符串,如“京AAAAAA”

colorValue  

(预留)

colorType  

车牌颜色 1:蓝色、2:黄色、3:白色、4:黑色、5:绿色、6:黄绿色

type  

车牌类型 0:未知车牌:、1:蓝牌小汽车、2::黑牌小汽车、3:单排黄牌、4:双排黄牌、 5:警车车牌、6:武警车牌、7:双层武警车牌、8:单排军车牌、9:双排军车牌、11:新能源小车、12:新能源大车、13:使馆牌、14:领馆牌、15:民航牌

confidence  

识别结果可行度 1-100  

bright  

(预留)

direction  

车的行进方向(预留)

location  

车牌在图片中位置

RECT  

位置为矩形区域;

left\right\top\bottom:车牌在图片中位置

timeUsed  

识别所用时间(预留)

carBright  

车身亮度(预留)

carColor  

车身颜色(预留)

timeStamp  

识别结果对应帧的时间戳

Timeval  

时间戳结构体类型

sec/usec  

从1970年1月1日到对应帧的秒和毫秒

triggerType  

当前结果的触发类型:由以下值取并的结果:1:手动抓拍、2:视频抓拍、3:线圈抓拍

imageFile,  

imageFileLen

开启发送图片后,加入"imageFile"   :base64编码的图像数据,"imageFileLen"   : 图像数据实际长度,这两项内容。

 

imageFragmentFile,  

imageFragmentFileLen

开启发送小图片后,加入"   imageFragmentFile " :base64编码的图像数据,"   imageFragmentFileLen " : 图像数据实际长度,这两项内容.

 

 

 

中心服务器回复JSON数据,

{"Response_AlarmInfoPlate":{"info":"ok",//回复ok开闸停止当前车牌信息重传(重传停止控制)"content":"retransfer_stop",//回复retransfer_stop停止当前车牌信息重传(重传停止控制)"is_pay":"true",//回复串口数据可以发送到相应串口“serialData”:[{“serialChannel”:0,“data”:”…”,“dataLen”:123},//数据1,可以有或者没有,收到后将发送到对应串口{“serialChannel”:1,“data”:”…”,“dataLen”:123}//数据2,可以有或者没有,收到后将发送到对应串口]}}

 

端口触发信息推送

当开启时,当有车检器输入有变化时,会推送json格式数据,内容如下:

{"AlarmGioIn":{"deviceName":"default","ipaddr":"192.168.0.100","result":{"TriggerResult":{"source":0,"value":0}},"serialno":"e10b2d6c8c07b422361457935b518642"}}

其中,TriggerResult中source=0代表是输入1,source=1代表输入2,value表示触发时输入的状态,其他参数的含义和车牌识别结果推送中相同。

中心服务器回复内容:任意内容。

串口数据推送:

//推送串口接收到的数据

{“SerialData”:{"channel":0,//通道号,当前为0"serialno":"e10b2d6c8c07b422361457935b518642",//设备序列号"ipaddr":"192.168.0.100"//设备ip“serialChannel”:0,//串口的通道号,通道0为485口1,通道1为485口2“data“:"MTEyMzQ1Njc4OQ==",//串口数据,采用base64编码“dataLen”:10//串口数据实际长度}}

中心服务器回复内容:

{"Response_SerialData":{"info":"ok",//暂时没有实际意义//回复串口数据可以发送到相应串口“serialData”:[{“serialChannel”:0,“data”:”…”,“dataLen”:123},//数据1,可以有或者没有,收到后将发送到对应串口{“serialChannel”:1,“data”:”…”,“dataLen”:123}//数据2,可以有或者没有,收到后将发送到对应串口]}}

心跳包发送

当开启时,会按指定间隔时间,发送心跳包:

{"Heartbeat":{"countid":1,"timeStamp":{"Timeval":{"sec":1441815171,"usec":672241}},"serialno":"e10b2d6c8c07b422361457935b518642"}}

对于心跳包,中心服务器可回复,可不回复  内容:

{"Response_Heartbeat":{"info":"ok",//回复ok开闸//回复串口数据可以发送到相应串口“serialData”:[{“serialChannel”:0,“data”:”…”,“dataLen”:123},//数据1,可以有或者没有,收到后将发送到对应串口{“serialChannel”:1,“data”:”…”,“dataLen”:123}//数据2,可以有或者没有,收到后将发送到对应串口],"shutoff":"ok",//回复ok关闸,可以有或者没有"snapnow":"yes",//回复yes相机抓拍,可以有或者没有}}

1,当超时时间大于心跳时间时,http 连接为长连接

2,重传使能时,重传停止条件为相机端收到车牌信息应答中有”info”:”ok”或者 “content”:“retransfer_stop”

白名单发送 中心请求白名单

{“whiteList”:{“queryNumList”:5000 //请求名单数量,不能为0,最大1000“listPosition”:0                 //请求名单的位置}}

 

 

相机回应

{“Response_whiteList”:{“totalList”:5000,“queryNumList”:5000,

“listPosition”:0                      //从0开始

“data”:[{“carnum”:”粤B88888”,“startime”:”20181029165012”,“endtime”:”20181105165012”},...]}"serialno" : "e10b2d6c8c07b422361457935b518642"}

 

中心添加白名单,一次可添加最多2000条

{“addWhiteList”:{“add_data”:[{“carnum”:”粤B88888”,“startime”:”20181029165012”,“endtime”:”20181105165012”},...]}}

 

 

相机回应

{“addWhiteList”:{“reponse”:”ok”"serialno" : "e10b2d6c8c07b422361457935b518642"}}

 

中心删除白名单,一次可删除最多10条

{“deleteWhiteList”:{“del_data”:[{“carnum”:“粤B88888”},...]}}

 

相机回应

{“deleteWhiteList”:{“reponse”:”ok”,"serialno" : "e10b2d6c8c07b422361457935b518642"}}

 

中心删除全部白名单

{“deleteWhiteListAll”:1}

 

相机回应

{“deleteWhiteListAll”:{“reponse”:”ok”,"serialno" : "e10b2d6c8c07b422361457935b518642"}}

 

另一个相机参数

https://www.cnblogs.com/zclaude/p/9781645.html

posted @ 2021-01-30 09:28  钢锅  阅读(2351)  评论(0编辑  收藏  举报