That sounds like a fantastic idea! I would love to implement it, but I'm not entirely sure where to start. If you wouldn’t mind, could you guide me through the process? I’d really appreciate any help you could offer. Thank you so much in advance!I would highly suggest using Alarm server and parsing real time data and storing to some database.
I configured IP camera and started listening from the specified port. But unfortunately License Plate number is not being received through the socket.Its fairly simple. Lets start with steps:
1. Create a TCP server listener on your server ip address and desired port. I use 9091 does not need to be 80
Basic Listener without parsing
View attachment 207233
2. Log in to your camera and navigate to Alarm settings
3. Under Server Alarm add ip address of your TCP server listener and port
4. ANR option is optional. This means that if event wasnt handled by server, camera will repeat the same event until server actually said OK. So if you have ANR enabled, on each event you need to send response bytes:
string responseString = "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n";
5.Once you start receiving events you then parse the data. The data is multipart, meaning it contains XML data depending on vehicle pass and all the information + images. Images are byte array that you can parse and save.
6. Each event you parse, store to database table such as LPRevents.
Thats about it. now you have database of passes which you can pull up anytime you want without interacting and relaying on camera itself.
Change recognition type to LicencePlate & Vehicle not just Vehicle.I configured IP camera and started listening from the specified port. But unfortunately License Plate number is not being received through the socket.
View attachment 207239View attachment 207238
ANR has been disabled. Detection mode were 'License Plate & Vehicle':Also i noted you have ANR enabled, all the listener apps wont work with it. It will just loop the 1st event it got. Since it does not responds with OK 200 back to camera.
Disable ANR temporary to catch other events.
POST / HTTP/1.1
Content-Type: multipart/form-data; boundary=boundary
Host: 192.168.2.107:9091
Connection: close
Content-Length: 776357
--boundary
Content-Disposition: form-data; name="anpr.xml"; filename="anpr.xml"
Content-Type: text/xml
Content-Length: 3059
<?xml version="1.0" encoding="UTF-8"?>
<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>192.168.2.46</ipAddress>
<portNo>9091</portNo>
<protocol>HTTP</protocol>
<macAddress>bc:9b:5e:b3:66:5d</macAddress>
<channelID>1</channelID>
<dateTime>2023-11-02T21:10:32+08:00</dateTime>
<activePostCount>1</activePostCount>
<eventType>ANPR</eventType>
<eventState>active</eventState>
<eventDescription>ANPR</eventDescription>
<channelName>Camera 01</channelName>
<ANPR>
<country>19</country>
<licensePlate>ZG6140G</licensePlate>
<line>1</line>
<direction>forward</direction>
<confidenceLevel>100</confidenceLevel>
<plateType>unknown</plateType>
<plateColor>unknown</plateColor>
<licenseBright
>0</licenseBright>
<dangmark>no</dangmark>
<twoWheelVehicle>no</twoWheelVehicle>
<threeWheelVehicle>no</threeWheelVehicle>
<plateCharBelieve>99,99,99,99,99,99,99</plateCharBelieve>
<vehicleType>vehicle</vehicleType>
<detectDir>8</detectDir>
<detectType>0</detectType>
<alarmDataType>0</alarmDataType>
<vehicleInfo>
<index>405</index>
<colorDepth>2</colorDepth>
<color>gray</color>
<length>0</length>
<vehicleLo
goRecog>1134</vehicleLogoRecog>
<vehileSubLogoRecog>0</vehileSubLogoRecog>
<vehileModel>0</vehileModel>
</vehicleInfo>
<pictureInfoList>
<pictureInfo>
<fileName>licensePlatePicture.jpg</fileName>
<type>licensePlatePicture</type>
<dataType>0</dataType>
<picRecogMode>0</picRecogMode>
<absTime>20231102211032591</absTime>
<pId>2023110221103333400Eqh1QVsXguPWo</pId>
</pictureInfo>
<pictureInfo>
<fileName>vehiclePicture.jpg</fileName>
<type>vehiclePicture</type>
<dataType>0</dataType>
<picRecogMode>0</picRecogMode>
<absTime>20231102211032591</absTime>
<plateRect>
<X>448</X>
<Y>406</Y>
<width>117</width>
<height>40</height>
</plateRect>
<pId>2023110221103333400dMbnmyWOBEl9E</pId>
</pictureInfo>
<pictureInfo>
<fileName>detectionPicture.jpg</fileName>
<type>detectionPicture</type>
<dataType>0</dataType>
<picRecogMode>0</picRecogMode>
<absTime>20231102211032591</absTime>
<plateRect>
<X>448</X>
<Y>406</Y>
<width>117</width>
<height>40</height>
</plateRect>
<pId>2023110221103333400F
2DLcGhtwvQgq</pId>
</pictureInfo>
</pictureInfoList>
<originalLicensePlate>ZG6140G</originalLicensePlate>
<CRIndex>19</CRIndex>
<vehicleListName>otherList</vehicleListName>
<plateCategory></plateCategory>
<plateSize>0</plateSize>
</ANPR>
<UUID>2023110221103333200phCHLeHslaDArysAvVOz5HhA01u9tYrAz9UphtSwRP8c</UUID>
<picNum>3</picNum>
<monitoringSiteID></monitoringSiteID>
<isDataRetransmission>false</isDataRetra
nsmission>
<DeviceGPSInfo>
<longitudeType>E</longitudeType>
<latitudeType>N</latitudeType>
<Longitude>
<degree>0</degree>
<minute>0</minute>
<sec>0.000000</sec>
</Longitude>
<Latitude>
<degree>0</degree>
<minute>0</minute>
<sec>0.000000</sec>
</Latitude>
</DeviceGPSInfo>
<detectionBackgroundImageResolution>
<height>1328</height>
<width>1920</width>
</detectionBackgroundImageResolution>
</EventNotificationAlert>
--boundary
Content-Disposition: form-data; name="licensePlatePicture.jpg"; filename="2023110221103333400Eqh1QVsXguPWo.jpg"
Content-Type: image/jpeg
Content-Length: 5008
JFIF C
This is how my listener receives the data:
XML:POST / HTTP/1.1 Content-Type: multipart/form-data; boundary=boundary Host: 192.168.2.107:9091 Connection: close Content-Length: 776357 --boundary Content-Disposition: form-data; name="anpr.xml"; filename="anpr.xml" Content-Type: text/xml Content-Length: 3059 <?xml version="1.0" encoding="UTF-8"?> <EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema"> <ipAddress>192.168.2.46</ipAddress> <portNo>9091</portNo> <protocol>HTTP</protocol> <macAddress>bc:9b:5e:b3:66:5d</macAddress> <channelID>1</channelID> <dateTime>2023-11-02T21:10:32+08:00</dateTime> <activePostCount>1</activePostCount> <eventType>ANPR</eventType> <eventState>active</eventState> <eventDescription>ANPR</eventDescription> <channelName>Camera 01</channelName> <ANPR> <country>19</country> <licensePlate>ZG6140G</licensePlate> <line>1</line> <direction>forward</direction> <confidenceLevel>100</confidenceLevel> <plateType>unknown</plateType> <plateColor>unknown</plateColor> <licenseBright >0</licenseBright> <dangmark>no</dangmark> <twoWheelVehicle>no</twoWheelVehicle> <threeWheelVehicle>no</threeWheelVehicle> <plateCharBelieve>99,99,99,99,99,99,99</plateCharBelieve> <vehicleType>vehicle</vehicleType> <detectDir>8</detectDir> <detectType>0</detectType> <alarmDataType>0</alarmDataType> <vehicleInfo> <index>405</index> <colorDepth>2</colorDepth> <color>gray</color> <length>0</length> <vehicleLo goRecog>1134</vehicleLogoRecog> <vehileSubLogoRecog>0</vehileSubLogoRecog> <vehileModel>0</vehileModel> </vehicleInfo> <pictureInfoList> <pictureInfo> <fileName>licensePlatePicture.jpg</fileName> <type>licensePlatePicture</type> <dataType>0</dataType> <picRecogMode>0</picRecogMode> <absTime>20231102211032591</absTime> <pId>2023110221103333400Eqh1QVsXguPWo</pId> </pictureInfo> <pictureInfo> <fileName>vehiclePicture.jpg</fileName> <type>vehiclePicture</type> <dataType>0</dataType> <picRecogMode>0</picRecogMode> <absTime>20231102211032591</absTime> <plateRect> <X>448</X> <Y>406</Y> <width>117</width> <height>40</height> </plateRect> <pId>2023110221103333400dMbnmyWOBEl9E</pId> </pictureInfo> <pictureInfo> <fileName>detectionPicture.jpg</fileName> <type>detectionPicture</type> <dataType>0</dataType> <picRecogMode>0</picRecogMode> <absTime>20231102211032591</absTime> <plateRect> <X>448</X> <Y>406</Y> <width>117</width> <height>40</height> </plateRect> <pId>2023110221103333400F 2DLcGhtwvQgq</pId> </pictureInfo> </pictureInfoList> <originalLicensePlate>ZG6140G</originalLicensePlate> <CRIndex>19</CRIndex> <vehicleListName>otherList</vehicleListName> <plateCategory></plateCategory> <plateSize>0</plateSize> </ANPR> <UUID>2023110221103333200phCHLeHslaDArysAvVOz5HhA01u9tYrAz9UphtSwRP8c</UUID> <picNum>3</picNum> <monitoringSiteID></monitoringSiteID> <isDataRetransmission>false</isDataRetra nsmission> <DeviceGPSInfo> <longitudeType>E</longitudeType> <latitudeType>N</latitudeType> <Longitude> <degree>0</degree> <minute>0</minute> <sec>0.000000</sec> </Longitude> <Latitude> <degree>0</degree> <minute>0</minute> <sec>0.000000</sec> </Latitude> </DeviceGPSInfo> <detectionBackgroundImageResolution> <height>1328</height> <width>1920</width> </detectionBackgroundImageResolution> </EventNotificationAlert> --boundary Content-Disposition: form-data; name="licensePlatePicture.jpg"; filename="2023110221103333400Eqh1QVsXguPWo.jpg" Content-Type: image/jpeg Content-Length: 5008 JFIF C
And it keeps going for image bytes,...
I wouldnt rely on done listeners, create your own.
import socket
IP_ADDRESS = '10.142.47.118'
PORT = 21
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind((IP_ADDRESS, PORT))
print(f"Server is listening on {IP_ADDRESS}:{PORT}")
server_socket.listen(1)
while True:
client_socket, client_address = server_socket.accept()
print(f"Connected by {client_address}")
data = client_socket.recv(776357)
if data:
print("Received:", data.decode())
client_socket.close()
Connected by ('172.16.66.230', 59186)
Received: POST / HTTP/1.1
Content-Type: multipart/form-data; boundary=boundary
Host: 10.142.47.118:21
Connection: close
Content-Length: 1125
--boundary
Content-Disposition: form-data; name="TrafficFlow"
Content-Type: application/json
Content-Length: 990
{
"ipAddress": "172.16.66.230",
"portNo": 21,
"protocol": "HTTP",
"macAddress": "5c:34:5b:9e:c8:cc",
"channelID": 1,
"dateTime": "2024-11-15T08:46:54+05:00",
"activePostCount": 1,
"eventState": "active",
"channelName": "Kirish",
"eventType": "TPSRealTime",
"eventDescription": "traffic pass statistics real-time",
"Target": [{
"recognitionType": "vehicle",
"TargetInfo": {
"snapTime": "2024-11-15T08:46:54+05:00",
"totalLaneNum": 1,
"LaneInfo": [{
"laneNo": 1,
"volum": 100,
"downwardFlow": 99,
"upwardFlow": 1
}],
"speed": "unknown",
"vehicleType": "unknown",
"plateNo": "unknown"
}
}, {
"recognitionType": "motorcycle",
"TargetInfo": {
"snapTime": "2024-11-15T08:46:54+05:00",
"totalLaneNum": 1,
"LaneInfo": [{
"laneNo": 1,
"volum": 0,
"downwardFlow": 0,
"upwardFlow": 0
}],
"speed": "unknown",
"vehicleType": "unknown",
"plateNo": "unknown"
}
}]
}
--boundary--
PUT /ISAPI/Event/notification/httpHosts/1What you are getting is not ANPR event, you are getting TPSRealTime event which is vehicle counter not ANPR.
Factory restore and try again if you upgraded firmware.