I have subscrived to the events of a Hikvision camera doing a get request to /ISAPI/Event/notification/alertStream. I am interested in ANPR events, this type of events return a multipart response which includes an xml with the event info, a license plate picture and a vehicle picture. All this info came in differents buffers because is a lot of information, for that I convert those buffers in strings and I put them together until I found the separator --boundary--. Now, when I got a complete events I try to handle the event, first I got the xml in which I have the info and I can get correctly all I need, but I am not able to save the image in my computer. Here is an example of the event info:
> 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 .....
Man its a long way ahead. Bear with me.
<<Listening_Server>>:<<Listening_Port>>/testphp_anprand inside it create a folder testindex.phpand paste the following codephp_anprfolder in windows terminal and paste the following after replacing the IP of your pc and port (8080) - Note: you must also configure camera to send anpr information in the same IP and portWait for some vehicle to be triggered in the camera alarmstream
It will send you at least 2 files detectionpicture and anpr.xml Only if licenseplate is detected, you will get License plate picture.jpg