ANPR事件与图片海康威视节点



我已经订阅了海康威视相机向/ISAPI/Event/nootification/alertStream发出获取请求的事件。我对ANPR事件感兴趣,这种类型的事件返回一个多部分响应,其中包括一个带有事件信息的xml、一个车牌图片和一个车辆图片。所有这些信息都在differents缓冲区中,因为有很多信息,为此我将这些缓冲区转换为字符串,并将它们放在一起,直到找到分隔符边界。现在,当我得到一个完整的事件时,我会尝试处理该事件,首先我得到了xml,其中我有信息,我可以正确地获得我需要的所有信息,但我无法将图像保存在我的计算机中。以下是事件信息的示例:

> Content-Disposition: form-data; name="anpr.xml"; filename="anpr.xml"
> Content-Type: text/xml Content-Length: 2230
> 
> <?xml version="1.0" encoding="UTF-8"?> <EventNotificationAlert
> version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
> <ipAddress>192.168.55.6</ipAddress>
> <ipv6Address>::ffff:192.168.55.6</ipv6Address> <portNo>80</portNo>
> <protocol>HTTP</protocol> <macAddress>08:a1:89:ff:6e:1a</macAddress>
> <channelID>1</channelID>
> <dateTime>2022-03-16T13:54:03+01:00</dateTime>
> <activePostCount>1</activePostCount> <eventType>ANPR</eventType>
> <eventState>active</eventState>
> <eventDescription>ANPR</eventDescription> <channelName> asdfg
> </channelName> <ANPR> <country>0</country>
> <licensePlate>unknown</licensePlate> <line>1</line>
> <direction>forward</direction> <confidenceLevel>0</confidenceLevel>
> <plateType>unknown</plateType> <plateColor>unknown</plateColor>
> <licenseBright>0</licenseBright> <dangmark>unknown</dangmark>
> <twoWheelVehicle>yes</twoWheelVehicle>
> <plateCharBelieve></plateCharBelieve>
> <vehicleType>nonmotorVehicle</vehicleType> <detectDir>8</detectDir>
> <detectType>5</detectType> <alarmDataType>0</alarmDataType>
> <vehicleInfo> <index>1344</index> <colorDepth>0</colorDepth>
> <color>unknown</color> <speed>0</speed> <length>0</length>
> <vehicleLogoRecog>0</vehicleLogoRecog>
> <vehileSubLogoRecog>0</vehileSubLogoRecog>
> <vehileModel>0</vehileModel> </vehicleInfo> <pictureInfoList>
> <pictureInfo> <fileName>nonMotorPicture.jpg</fileName>
> <type>nonMotorPicture</type> <dataType>0</dataType>
> <picRecogMode>0</picRecogMode> <absTime>20220316135403615</absTime>
> <pId>2022031613540382300NhqQD51oTGTYE</pId> </pictureInfo>
> <pictureInfo> <fileName>detectionPicture.jpg</fileName>
> <type>detectionPicture</type> <dataType>0</dataType>
> <picRecogMode>0</picRecogMode> <absTime>20220316135403615</absTime>
> <plateRect> <X>0</X> <Y>0</Y> <width>0</width> <height>0</height>
> </plateRect> <pId>2022031613540382300KBGZqPyyVYGta</pId>
> </pictureInfo> </pictureInfoList>
> <originalLicensePlate>unknown</originalLicensePlate>
> <CRIndex>0</CRIndex> </ANPR>
> <UUID>2022031613540382300Y3s6LFDQIWOfg73fuU9UVFguFLf40ucwK0ghCc8iVMPG</UUID>
> <picNum>2</picNum> <monitoringSiteID></monitoringSiteID>
> <isDataRetransmission>false</isDataRetransmission>
> </EventNotificationAlert>
> 
> 
> 
> Content-Disposition: form-data;
> name="2022031613540382300NhqQD51oTGTYE.jpg";
> filename="nonMotorPicture.jpg" Content-Type: image/jpeg
> Content-Length: 62407
> 
> ����►JFIF☺☺☺☺���☻☺☺☺☺☺☻☺☺☺☻☻☻☻☻♦♥☻☻☻☻♣♦♦♥♦♠♣♠♠♠♣♠♠♠    ♠        ♠♂
> 
> 
> 
> 
> ♂♀♂ ♀
> 
> 
> ☺☻☻☻☻☻☻♣♥♥♣ ♠ ....
> 
> Content-Disposition: form-data;
> name="2022031613540382300KBGZqPyyVYGta.jpg";
> filename="detectionPicture.jpg" Content-Type: image/jpeg
> Content-Length: 717259
> 
> ����� [ID = 1344 pr= type=0x60] [cur_frm_num=395344
> snap_frm_num=395344 ps_frm_num=0] [obj_rect = 0.023958x0.566667,
> 0.101562x0.292593] [plate_rect = 0.000000x0.000000, 0.000000x0.000000] �D☻�D☻�?�)♦↑⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂X��♥∟☻♣(=→♥♥☻‼☺
> ♥       ☻♦
> ⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂�☺�)♦↑♀♥♠☺�Q�☺�8♦☺♣♥♦☺☻�8�∟z?☻�?�∟z?♦9��>V♫->♦'1h?♦���>�I�>?5�>d;⌂?♦�K↨?333>☻�?�(<?TDD�<◄◄◄?☻�=�Ε>⌂⌂2☺G.☺d☻�☺�♥⌂
> 6778KZ5↓�♥☻6778KZ5↓�♥☻6778KZ5↓�♥☻6778KZ5↓�♥⌂⌂⌂⌂⌂c6778KZ5↓¶#♣⌂⌂⌂⌂⌂j♠⌂▲6778KZ5↓¶#♣⌂⌂⌂⌂⌂j♠⌂▲6778KZ5↓¶#♣⌂⌂⌂⌂⌂j♠⌂▲6778KZ5↓¶#♣⌂⌂⌂⌂⌂j♠⌂▲6778KZ5↓¶#♣⌂⌂⌂⌂⌂♠⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂♠♥♥
> K.☺d☻�☺�♥♦☺�☺C♥7♦☻♣�☺⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂5♂�������♠♦♣♠♣♦♠♠♣♠♠ ►
> 
> 
> ¶♫☼♀►↨¶↑↑↨¶▬▬→↔%▼→∟▬▬↓▼-(0%()(☺
> 
> ‼
> 
> ‼(→▬→((((((((((((((((((((((((((((((((((((((((((((((((((☻
> 
> ‼
> 
> ‼(→▬→((((((((((((((((((((((((((((((((((((((((((((((((((��♦��♥☺"☻◄☺♥◄☻��☺�☺♣☺☺☺☺☺☺☺☻♥♦♣♠
> ♂►☻☺♥♥☻♦♥♣♣♦♦☺}☺☻♥♦◄♣↕!1A♠‼Qa"q¶2��#B��§R��$3br�
> ▬↨↑↓→%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�������������������������������������������������������������������������☺♥☺☺☺☺☺☺☺☺☺☺☻♥♦♣♠
> ♂◄☻☺☻♦♦♥♦♣♦♦☺☻w☺☻♥◄♦♣!1♠↕AQaq‼"2¶B����  #3R�§br�
> ▬$4�%�↨↑↓→&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������♦x��♀♥☺☻◄♥◄?���N�H�R���r♫☻��☻�j
> ▼�ͱ�♫�◄jijc5♥¶�T�Q榈U!‼�*�x���X��4�0�74��3OZ�→�*�L�)��wݐ§7����⌂�1j;�v��>����A'��☻d���
> ��I�-�ʳ[�4d��E�I↑�#"���8▲���]�‼��_���☻~��صm>�K�7:����P�e♣�☺���6Z4�T}�H!z���:����6���;D↨���RW
> 6=W�zU♂]_I�����♀Я�l��B�♣��Y����:♀IzdK���d�M�F&@�p=�z��.�GZgKk�-n��'9�&f☺dC�i>��>�J������▼��.‼��8↓n���sY�~�⌂-���→5�ݔR����→0�N
> �♫F�9�♠j��s↔����♫�lo��O%ͪH�!�z��C☼�▲�z�w↓Ң4i§Φ�%�q↨f��♫G�►v�rz�Yo(��Ķ�]�ڭ�v�eUg��G&��NB6223Y��)d�►�7→����R������↓[��n�OZ׬[WӯⅥ�d◄O♦��o,��'i�u攛�I∟���It.t�#V��qnLA��
> ʌ���♥W��$Վ�$�O��k��hg���>����♠��▲՝�☺g�,�↕5��O�D7�♫��n
> ���q�*���a�u;$�/4���.�♥�9E]��T‼��↔;P��3��Ҡ�B��-��↕�§
> ��o�ӣ�c:m���g��-���>�Ժ]�1Gl0Q�uK�►☺�򙙑O�m� ⌂��z�o�U�f�#za����pj 
> N�Z�s�p�)���?��n�Xna�u↑I͌��o .....

人类还有很长的路要走。请耐心等待。

  1. 当您获得xml时,我想您已经在相机中正确配置了ANPR侦听端口。现在它
  2. 安装PHP 8.0(目前无需web服务器进行测试(
  3. 默认情况下,相机应发布在<<Listening_Server>>:<<Listening_Port>>/test
  4. 创建一个名为php_anpr的文件夹,并在其中创建一个文件夹测试
  5. 在测试文件夹内创建另一个文件夹映像
  6. 在名为index.php的测试文件夹中创建一个文件,并粘贴以下代码
<?php
//php -S SERVER:PORT -t test
$id = '_'. date('Ymd_hmis');

//file_put_contents('images/LPR_JSON'.$id.'.json', json_encode($_FILES));
function WriteSingleFile($xid) {

foreach ($_FILES as $file) {
$key = $file['name'];
$info = pathinfo($file['name']);
$tempfilename = $file['tmp_name'];
$extension = $info['extension'];
$newname = 'LPR'.$xid.'_'.$key;
$target = 'images/'.$newname;
move_uploaded_file( $tempfilename, $target);
}
}
WriteSingleFile($id);
?>
  1. 现在打开windows终端中的php_anpr文件夹,并在更换电脑和端口(8080(的IP后粘贴以下内容-注意:您还必须配置相机以在相同的IP和端口中发送anpr信息
php -S SERVER:PORT -t test

等待某些车辆在摄像头警报流中被触发

它将向您发送至少2个文件detectionpicture和anpr.xml只有在检测到许可证的情况下,你才会得到车牌图片.jpg

最新更新