Pulling from the Queue

Rekor maintains a local Beanstalkd queue. All JSON results are placed in this queue. Your application can grab and process the latest plate results from this queue.

Beanstalkd maintains client libraries in many popular programming languages. For a complete list, visit: https://github.com/kr/beanstalkd/wiki/Client-Libraries

To configure Rekor Scout® to make the results available via the local queue, set the following parameters in /etc/openalpr/alprd.conf:

upload_data = 0
websockets_enabled = 0
web_server_enabled = 1
use_beanstalkd = 1

In addition, you must add a valid on-premise license to /etc/openalpr/license.conf

Once updated, restart the Scout Agent service to allow the settings to take effect.

Below is a sample Python script that pulls results from the local Beanstalkd queue:


import beanstalkc
import json
from pprint import pprint

beanstalk = beanstalkc.Connection(host='localhost', port=11300)


# For diagnostics, print out a list of all the tubes available in Beanstalk.
print beanstalk.tubes()

# For diagnostics, print the number of items on the current alprd queue.
except beanstalkc.CommandFailed:
    print "Tube doesn't exist"

# Watch the "alprd" tube; this is where the plate data is.

# Loop forever
while True:

    # Wait for a second to get a job. If there is a job, process it and delete it from the queue.
    # If not, return to sleep.
    job = beanstalk.reserve(timeout=1.0)

    if job is None:
        print "No plates available right now, waiting..."

        print "Found a plate!"
        plates_info = json.loads(job.body)

        # Print all the info about this plate to the console.

        # Do something with this data (e.g., match a list, open a gate, etc.).
        if 'data_type' not in plates_info:
            print "This shouldn't be here... all OpenALPR data should have a data_type"
        elif plates_info['data_type'] == 'alpr_results':
            print "This is a plate result"
        elif plates_info['data_type'] == 'alpr_group':
            print "This is a group result"
        elif plates_info['data_type'] == 'heartbeat':
            print "This is a heartbeat"

        # Delete the job from the queue when it is processed.

Last updated