diff --git a/daemon/Dockerfile b/daemon/Dockerfile index 41cfd16..9d1c742 100644 --- a/daemon/Dockerfile +++ b/daemon/Dockerfile @@ -1,12 +1,12 @@ -FROM ubuntu:18.04 -MAINTAINER Matt Hill +FROM ubuntu:22.04 +LABEL maintainer="Matt Hill " # Setup gpg key and deb repo -RUN apt-get update && apt-get install -y curl gnupg && \ - curl -sSL http://deb.openalpr.com/openalpr.gpg.key | apt-key add - && \ - echo "deb http://deb.openalpr.com/bionic/ bionic main" > /etc/apt/sources.list.d/openalpr.list && \ - apt-get update && apt-get install -y \ +RUN apt-get update && apt-get install -y --no-install-recommends curl gnupg && \ + curl -sSL https://deb.openalpr.com/openalpr.gpg.key | apt-key add - && \ + echo "deb https://deb.openalpr.com/jammy/ jammy main" > /etc/apt/sources.list.d/openalpr.list && \ + apt-get update && apt-get install -y --no-install-recommends \ libalprstream-dev \ openalpr \ openalpr-daemon \ diff --git a/daemon/Dockerfile.nvidia b/daemon/Dockerfile.nvidia index 9066c30..b7058fc 100644 --- a/daemon/Dockerfile.nvidia +++ b/daemon/Dockerfile.nvidia @@ -1,12 +1,12 @@ -FROM nvidia/cuda:8.0-cudnn6-runtime-ubuntu16.04 - -MAINTAINER Matt Hill +# JetPack 4.6 — CUDA 10.4, Ubuntu 18.04 (L4T base) +FROM nvidia/cuda:10.2-runtime-ubuntu18.04 +LABEL maintainer="Matt Hill " # Setup gpg key and deb repo -RUN apt-get update && apt-get install -y wget && \ - wget -qO - http://deb.openalpr.com/openalpr.gpg.key | apt-key add - && \ - echo "deb http://deb.openalpr.com/xenial-commercial/ xenial main" > /etc/apt/sources.list.d/openalpr.list && \ - apt-get update && apt-get install -y \ +RUN apt-get update && apt-get install -y --no-install-recommends wget gnupg && \ + wget -qO - https://deb.openalpr.com/openalpr.gpg.key | apt-key add - && \ + echo "deb https://deb.openalpr.com/bionic/ bionic main" > /etc/apt/sources.list.d/openalpr.list && \ + apt-get update && apt-get install -y --no-install-recommends \ openalpr \ openalprgpu \ openalpr-daemon \ @@ -40,4 +40,3 @@ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY alprd.conf /etc/openalpr/alprd.conf CMD ["/usr/bin/supervisord"] - diff --git a/daemon/Dockerfile.nvidia10 b/daemon/Dockerfile.nvidia10 index d76bc8c..7ce46fb 100644 --- a/daemon/Dockerfile.nvidia10 +++ b/daemon/Dockerfile.nvidia10 @@ -1,12 +1,12 @@ -FROM nvidia/cuda:10.0-runtime-ubuntu18.04 - -MAINTAINER Matt Hill +# JetPack 6.2.2 — CUDA 12.6, Ubuntu 22.04 (L4T base) +FROM nvidia/cuda:12.6.0-runtime-ubuntu22.04 +LABEL maintainer="Matt Hill " # Setup gpg key and deb repo -RUN apt-get update && apt-get install -y wget && \ - wget -qO - http://deb.openalpr.com/openalpr.gpg.key | apt-key add - && \ - echo "deb http://deb.openalpr.com/bionic/ bionic main" > /etc/apt/sources.list.d/openalpr.list && \ - apt-get update && apt-get install -y \ +RUN apt-get update && apt-get install -y --no-install-recommends wget gnupg && \ + wget -qO - https://deb.openalpr.com/openalpr.gpg.key | apt-key add - && \ + echo "deb https://deb.openalpr.com/jammy/ jammy main" > /etc/apt/sources.list.d/openalpr.list && \ + apt-get update && apt-get install -y --no-install-recommends \ openalpr \ openalprgpu \ openalpr-daemon \ @@ -40,4 +40,3 @@ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY alprd.conf /etc/openalpr/alprd.conf CMD ["/usr/bin/supervisord"] - diff --git a/webservice/Dockerfile b/webservice/Dockerfile index 0de4d4e..84cef64 100644 --- a/webservice/Dockerfile +++ b/webservice/Dockerfile @@ -1,18 +1,18 @@ FROM openalpr/commercial-agent -MAINTAINER Matt Hill +LABEL maintainer="Matt Hill " - -RUN apt-get update && apt-get install -y python-pip python-openalpr +RUN apt-get update && apt-get install -y --no-install-recommends python3-pip python3-openalpr && \ + apt-get clean && rm -rf /var/lib/apt/lists/* COPY src/requirements.txt /opt/openalprapi/ -RUN pip install -r /opt/openalprapi/requirements.txt +RUN pip3 install --no-cache-dir -r /opt/openalprapi/requirements.txt -# send over the license key +# send over the license key #COPY license.conf /etc/openalpr/license.conf COPY src/webservice.py /opt/openalprapi/ EXPOSE 8080 -CMD ["python", "/opt/openalprapi/webservice.py", "-p", "8080"] +CMD ["python3", "/opt/openalprapi/webservice.py", "-p", "8080"] diff --git a/webservice/src/requirements.txt b/webservice/src/requirements.txt index 1b6ca98..1794908 100644 --- a/webservice/src/requirements.txt +++ b/webservice/src/requirements.txt @@ -1,6 +1,2 @@ -argparse==1.2.1 -backports.ssl-match-hostname==3.4.0.2 -certifi==2015.04.28 -futures==3.0.3 -tornado==4.2.1 -wsgiref==0.1.2 +certifi>=2023.7.22 +tornado>=6.3.0 diff --git a/webservice/src/webservice.py b/webservice/src/webservice.py index 6c67f1a..fb9cd4a 100644 --- a/webservice/src/webservice.py +++ b/webservice/src/webservice.py @@ -36,7 +36,7 @@ debug = options.debug if options.threads > multiprocessing.cpu_count(): - print "Warning, attempting to use %d threads when your system only has %d cores" % (options.threads, multiprocessing.cpu_count()) + print("Warning, attempting to use %d threads when your system only has %d cores" % (options.threads, multiprocessing.cpu_count())) executor = ThreadPoolExecutor(options.threads) @@ -53,7 +53,7 @@ class AlprHandler(tornado.web.RequestHandler): def post(self): - start = time.clock() + start = time.perf_counter() response = { 'version': 1, } @@ -92,20 +92,20 @@ def post(self): alpr_results = yield self.alpr_processor(jpeg_bytes, topn, state) - end = time.clock() + end = time.perf_counter() if debug: - print "Total POST time: %.2f ms" % ((end - start) * 1000) + print("Total POST time: %.2f ms" % ((end - start) * 1000)) self.finish(json.dumps(alpr_results)) @run_on_executor(executor='executor') def alpr_processor(self, image, topn, state): - thread_id = threading.currentThread().ident + thread_id = threading.current_thread().ident if thread_id not in self.alpr_processes: if debug: - print "Kicking off new ALPR process" + print("Kicking off new ALPR process") self.alpr_processes[thread_id] = Alpr("us", "/etc/openalpr/openalpr.conf", "/usr/share/openalpr/runtime_data") self.alpr_processes[thread_id].set_detect_region(True) @@ -114,20 +114,21 @@ def alpr_processor(self, image, topn, state): self.alpr_processes[thread_id].set_default_region(state) if debug: - print "Starting alpr job" - print "back-queue size: %d" % executor._work_queue.qsize(), + print("Starting alpr job") + print("back-queue size: %d" % executor._work_queue.qsize()) - print "args: topn %d, state: %s" % (topn, state) - print "Thread ID: " + str (threading.currentThread().ident) + print("args: topn %d, state: %s" % (topn, state)) + print("Thread ID: " + str(threading.current_thread().ident)) try: - start = time.clock() + start = time.perf_counter() results = self.alpr_processes[thread_id].recognize_array(image) - end = time.clock() + end = time.perf_counter() if debug: - print "ALPR Processing time: %.2f ms" % ((end - start) * 1000) + print("ALPR Processing time: %.2f ms" % ((end - start) * 1000)) return results - except: + except Exception as e: + print("ALPR processing error: %s" % str(e)) return {'error': 'alpr_processing_error'} @@ -160,8 +161,8 @@ def get(self): if __name__ == "__main__": - print "OpenALPR Web server started on port %d" % (options.port) - print "Using %d parallel ALPR threads" % (options.threads) + print("OpenALPR Web server started on port %d" % (options.port)) + print("Using %d parallel ALPR threads" % (options.threads)) application.listen(options.port) tornado.ioloop.IOLoop.current().start()