.. _DeviceConfigurationAvutecAnpr:
#######################################
ANPR - Avutec module-X IR Configuration
#######################################
1. In ALIOT portal add an Avutec ANPR device to the device module.
- Add an IP address
2. Go to the info panel in the ALIOT portal and copy the generated password for the Avutec ANPR device
3. Go to the designer window of CortexDesigner in the CortexClient and add a **WebServiceAxon**
.. image:: /content/HALAPI/DeviceConfiguration/CortexDesigner_Screenshot.png
4. Add the following `ChaiScript `_ to the axon WebService0
::
trigger:
message.Type()==MSG_IMAGE && message.Has(MI_ANPR_THRESHOLD)
action:
auto threshold = PbAnprThreshold();
message.GetMessageInfo(MI_ANPR_THRESHOLD, threshold);
//optional if image must be sent
// auto img=message.GetImage();
for (auto i = 0; i < threshold.license_plates_size(); ++i)
{
auto anpr_data = PbAnprResult();
message.GetMessageInfo(MI_ANPR_RESULT, anpr_data);
auto lp = FindPbLicensePlate(anpr_data, threshold.license_plates(i));
LOG(L_INFO,"Licence plate:"+to_string(lp.license_plate()));
auto j=Json();
j["timeStampUtc"]=GetUTCString();
j["licensePlate"]=lp.license_plate();
j["country"]=lp.license_plate().substr(0,2);
j["score"]=lp.confidence();
j["context"]="IN";
//optional if image must be sent
//j["base64Image"]=img;
auto json_serialized = j.Serialize();
LOG(L_INFO,json_serialized);
//escape special characters, otherwise not working
json_serialized = json_serialized.replace("\"","\\\"");
auto response="";
auto curl_command = "--insecure -H \"Content-Type: application/json\" -u "+this.User()+":"+this.Password()+" --data '"+json_serialized+"' "+this.Url();
//in cases where the gateway cannot resolve the source ipv4 address from the incoming http post message, an extra header X-ALIOT-Device containing the device name can be used instead
// auto curl_command = "--insecure -H \"Content-Type: application/json\" -H\"X-ALIOT-Device:anpr1\" -u "+this.User()+":"+this.Password()+" --data '"+json_serialized+"' "+this.Url();
auto ret = this.Curl(curl_command,response);
}
5. In the CortextView of the CortexClient, go to the WebService settings and add the following settings:
::
Url: https://:9443/devicewebhooks/avutec/scannedlicenseplate
Username: DeviceModule1
Password: password mentioned in the ALIOT webportal when adding an Avutec ANPR slave device to the device module
.. image:: /content/HALAPI/DeviceConfiguration/CortexView_Screenshot.png
6. Restart the cortex engine.
.. attention::
The data fields of the incoming json message for a scanned license plate are limited in range or length:
- LicensePate: max 20 chars
- Country: max 20 chars
- Score: [0,100]
- Base64Image: max 300000 chars
- TimeStampUtc: utc, YYYY-MM-DDTHH:mm:ssZ (eg: 2024-10-16T14:59:19Z)
- Context: max 20 chars
Including an Image
******************
The default image resolution and size, processed by the ANPR, is too large to send through http. Add an extra **ImageResizeAxon** to reduce the image resolution and size.
.. image:: /content/HALAPI/DeviceConfiguration/CortexDesigner_ImageResizing.png
.. image:: /content/HALAPI/DeviceConfiguration/CortexDesigner_ImageResizingSettings.png
Troubleshooting
***************
* See the `Avutec CortexClient client manual `_ for more info about Cortex configuration
* Use the 'health check' button in the device module info panel in the ALIOT portal, to test if the gateway can 'ping' to the avutec ANPR
* Use the LogAxon window and the AnprThreshold window in the CortexView of the CortexClient to check:
- If a licenseplate is read (Passed threshold datagrid in AnprThreshold window)
- If a http post is sent (log data grid in LogAxon window)
* The gateway tries to resolve the source ipv4 address of the incoming http post message. In cases were this ip address cannot be resolved (eg: routing issues) an extra http header **X-ALIOT-Device** can be added to the chaiscript of the WebServiceAxon (see sample script above). The value of the header must be the name of the device as mentioned in the webportal. Note that this header has precedence over the ipv4 address.
* To check if the ANPR sends https messages, use the website `webhook.site `_