English Română
Overview This document explains how to use luxriot_lpr.php, a helper that receives a License‑Plate‑Recognition (LPR) HTTP POST request from a Metrici LPR engine, validates it, builds a JSON payload and forwards it to a LuxRiot VCA server using Digest authentication.

1. Overview

2. POST Fields (sent in the request body)

FieldDescriptionRequired?
idCamera identifier (integer)Yes
numberDetected licence‑plate numberYes
country_codeCountry code of the plateYes
first_seenTimestamp when the plate was first seenYes
last_seenTimestamp when the plate was last seenYes
probabilityConfidence (0‑1)Yes
directionVehicle direction (e.g., "in", "out")Yes
plate_imageURL or base64 image of the plate (optional)No
car_imageURL or base64 image of the vehicle (optional)No
transactionkeyTransaction identifier for the eventYes
gps_latitudeLatitude (optional)No
gps_longitudeLongitude (optional)No
have_companionFlag indicating a companion plate (optional)No
companion_imageImage of companion plate (optional)No
weightVehicle weight (optional)No
speedVehicle speed (optional)No
triggerkeyKey identifying the trigger source (optional)No
vehicle_classVehicle class string (e.g., "car")No
vehicle_colorVehicle colour stringNo
vehicle_makerVehicle manufacturer stringNo
plate_bboxBounding box coordinates in format x;y;width;height (e.g., "0.3;0.4;0.2;0.1"). Used to position the metadata overlay. Defaults to center (0.5;0.5;0.2;0.1) if not provided.No
authMD5 hash calculated from a concatenation of several fields (optional – if omitted the script computes it)No
Note: The script will compute the auth hash automatically if it is not supplied. If plate_bbox is provided, the script parses the coordinates and uses them to position the license plate metadata overlay in the LuxRiot VCA system. The coordinates should be relative to the car image dimensions.

3. Authentication Process

  1. Retrieve the camera‑specific authkey from the MySQL table general_cameras using the supplied id.
  2. Build a concatenated string using the fields listed in the source code (see authString in the script) and the retrieved authkey.
  3. Compute md5($authString). The supplied auth field must match this hash; otherwise the request is rejected with Wrong authentication.

After the POST validation, the script performs a HTTP Digest authentication with the LuxRiot server. The steps are:

4. GET Parameters (required in the query string)

ParameterDescription
serverBase URL or IP of the LuxRiot server (e.g., http://10.0.0.5)
portPort on which the server listens (e.g., 80 or 443)
userUsername for Digest authentication
passPassword for Digest authentication
targetidVCA target identifier used in the endpoint URL
displaytimeliveOptional – display time (ms) for live view (used in plate metadata)
displaytimearchiveOptional – display time (ms) for archived view (used in plate metadata)
Note: If any of the mandatory parameters (server, port, user, pass) are missing the script returns HTTP 400.

5. Configuration Example

Below is an example configuration showing how to set up the Metrici LPR engine to send events to this script. For this you should navigate to the /home/metrici/metrici folder and open the corresponding .ini file. Then you can change the reporting_url key value, or better to add the address of this script to the reporting_duplicate_url key.

Metrici LPR Engine Configuration

6. Usage Example (cURL)

The following example shows how to call the script from the command line. Replace placeholder values with real data.

curl -X POST \
  -d "id=12" \
  -d "number=ABC1234" \
  -d "country_code=US" \
  -d "first_seen=2024-09-19T10:15:00Z" \
  -d "last_seen=2024-09-19T10:15:05Z" \
  -d "probability=0.96" \
  -d "direction=in" \
  -d "transactionkey=tx12345" \
  -d "plate_bbox=0.3;0.4;0.2;0.1" \
  "http://yourhost/luxriot_lpr.php?server=10.0.0.5&port=80&user=admin&pass=secret&targetid=7"

The script will respond with one of the following HTTP status codes:

7. Response Format

On success the script outputs a plain‑text message:

Metadata sent successfully

On error it prints a human‑readable message and sets the appropriate HTTP status code (see the list above).