Computer Vision with Python and K3s Clusters
local graph
Chapter 14 — Computer Vision with Python and K3s Clusters
Section titled “Chapter 14 — Computer Vision with Python and K3s Clusters”Artificial intelligence (AI) is commonly used to substitute activities that humans do every day. It can give systems the intelligence to operate autonomously without human intervention in most cases. Computer vision (CV) is a subcategory of AI that focuses on detecting objects in videos and images. CV is often used to detect traffic in a city. This chapter focuses on building a basic smart traffic system that consists of detecting objects such as cars, trucks, and pedestrians when a vehicle is moving. For this, the system uses the OpenCV, TensorFlow, and scikit-learn Python libraries and a camera to perform computer vision at the edge on a Raspberry Pi. This system also shows locally to drivers a map within the detected objects, and it also implements a public map for global detected object visualization. This public map can be used as a real-time traffic state map that municipalities can use.
In this chapter, we’re going to cover the following main topics:
- Computer vision and smart traffic systems
- Using Redis to store temporary object Global Positioning System (GPS) positions
- Deploying a computer vision service to detect car obstacles using OpenCV, TensorFlow Lite, and scikit-learn
- Deploying the edge application to visualize warnings based on computer vision
- Deploying a global visualizer for the smart traffic system
Technical requirements
Section titled “Technical requirements”To deploy our computer vision system in this chapter, you will need the following:
- A Kubernetes cluster hosted in your public cloud provider (Amazon Web Services (AWS), Azure, Google Cloud Platform (GCP)).
- A Raspberry Pi 4B with an 8-GB micro Secure Digital (SD) card with a small-monitor liquid-crystal display (LCD) screen to use in a car.
- A Logitech C922 PRO webcam, recommended because of its quality and support on Linux.
- Multiple VK-162 G-Mouse USB GPS Dongle Navigation modules, for your edge Raspberry devices.
- Basic knowledge of AI.
kubectlconfigured to be used in your local machine for your Kubernetes cloud cluster to avoid using the--kubeconfigparameter.- Clone the https://github.com/PacktPublishing/Edge-Computing-Systems-with-Kubernetes/tree/main/ch14 repository if you want to run the YAML Ain’t Markup Language (YAML) configuration by using
kubectl applyinstead of copying the code from the book. Take a look at thepythondirectory inside thecodedirectory and theyamldirectory for YAML configurations that are inside thech14directory.
With this, you can deploy Prometheus and Grafana to start experiment monitoring in edge environments.
Computer vision and smart traffic systems
Section titled “Computer vision and smart traffic systems”AI is an area of computer science that consists of simulating human intelligence using mathematics, statistics, linguistics, computer science, and other sciences. AI can also be defined as the study of rational agents, as depicted in the following diagram:

Figure 14.1 – Agents
Taking Figure 14.1 as a reference, an agent receives perceptions coming from the environment. These perceptions are captured by sensors, and this information is processed to perform an action using effectors. Actions are decided by internal rules installed inside the agent. These actions involve the use of effectors such as arms, legs, or wheels, for example.
These internal rules can be implemented using different machine learning (ML) paradigms such as supervised learning (SL), unsupervised learning (UL), and reinforcement learning (RL).
ML is a type of AI that uses historical data as input to do predictions. Computer vision is a subset of ML applied to image and video analysis using predictions. In our chapter, we are going to do predictions about what our agent is capturing using a camera and take decisions according to that information, but we are going to apply computer vision to create a smart traffic system. Let’s have a look at the following diagram, which shows how our system will be implemented to create a smart traffic system using computer vision at the edge:

Figure 14.2 – Smart traffic system using computer vision
Smart traffic systems are often used by municipalities to improve safety, and traffic flow on streets in a cost-effective way. Our system can be used in two modes. The static mode uses a camera in a static location point in the city, and the dynamic mode uses a car to scan traffic where the car is moving. We are going to use the dynamic mode. Now, let’s explain our system using the layers of the edge computing systems, as follows:
- Cloud layer: Here, we are going to use an application programming interface (API) called Traffic Manager that stores all detected objects at the edge in a Redis instance. The data stored will contain the type of object—car, truck, and person—which represents a level 1 warning on our system and the GPS coordinates. This means that a vehicle driver will be warned of previously detected objects by other drivers. Our API will store the GPS position of these objects, which potentially could be obstacles for a vehicle. This layer will also include a frontend application called Traffic Map Public that shows the objects detected on a map. This application could be used by the municipality to monitor all traffic across the city.
- Near edge: This layer has the fourth-generation (4G)/ fifth-generation (5G) Long-Term Evolution (LTE) mobile network used to send information to the internet. This layer will transport information collected at the edge to send it to the cloud layer.
- Far edge: Our far edge has a Raspberry Pi that will process the information captured by a camera. This device has installed K3s as a single node cluster to manage all services that the system uses. K3s can brings automation to the system. K3s can easily update and maintain the system and can extend the system to use more nodes. These additional nodes can be used to add multiple cameras for object detection at multiple angles. The computer vision application that runs in the cluster consists of two displays and two APIs. One display runs outside K3s but in the same device as a Python script, and it’s the service that captures the video. This service consists of a Python program that captures video and detects objects using OpenCV and a precompiled model for TensorFlow Lite for object detection. Here is where computer vision occurs. The system uses a small LCD touchscreen connected to the device. The other display is a frontend application that runs on a browser; it shows detected objects across a map, not only showing these locally but also showing all detected objects by all vehicles in a radius of 500 meters. Detected objects will be classified by the Inference API, which classifies objects according to their level of warning for a driver. These warnings are represented at three levels: levels 1 and 2 represent a warning, and level 3 could be ignored as an obstacle for a driver. The Inference API contains a precompiled decision tree to do classification. The GPS Queue API manages all GPS coordinates and periodically sends information about detected objects that represent a warning to the cloud to be shown to other drivers. The whole application uses the Display, Traffic Map, Inference, and GPS Queue components to process and visualize detected objects. The GPS Queue service is based on the GPS service created in Chapter 5, K3s Homelab for Edge Computing Experiments, with some modifications. Something important to consider is that you can accelerate your object detection by using an external device that accelerates neural network (NN) processing. Some devices that you can consider are the Coral USB Accelerator from Google, the Rock Pi neural compute stick Universal Serial Bus (USB), and the NVIDIA Jetson Nano. These devices accelerate the NN processing of OpenCV by delegating processing to a dedicated processing unit sometimes called a graphics processing unit (GPU) or a Tensor Processing Unit (TPU). The OpenCV library uses TensorFlow Lite models, so the use of these devices can increase the number of frames per second (FPS) analyzed that have some GPU that can be used by TensorFlow Lite, which is designed to run on edge devices to accelerate your video analysis. For more information, check the Further reading section.
- Tiny edge: Here, we can find an LCD screen to display all detected objects in real time and warnings for the driver. You can also find the VK-162 G-Mouse GPS module here.
To summarize this workflow, our vehicle first captures images with its camera; then, the video frames or images are captured using OpenCV and classified using TensorFlow Lite, then are classified according to their level of warning representation for the drivers by the Inference API. This information is shown locally in the LCD and browser. The GPS coordinate data sent to the cloud is shown in a public web frontend application in the cloud. So now, let’s get started in building a basic smart traffic system to alert drivers.
Using Redis to store temporary object GPS positions
Section titled “Using Redis to store temporary object GPS positions”We are going to use Redis to store our GPS coordinates for all detected objects using computer vision. This is a basic configuration to deploy Redis for this purpose. This Redis instance must be deployed in the cloud. As we explained in Chapter 13, Geolocalization Applications Using GPS, NoSQL, and K3s Clusters, we are going to use a geospatial index to represent our data. The difference will be that we are going to implement temporary storage of data using a time-to-live (TTL) feature that auto-expires keys in Redis. For this, we are going to continuously watch hash keys in Redis if they still exist. For each detected object, the type and level of warning are stored in a hash key, and a coordinate will be added in a geospatial sorted set. Then, a TTL is configured for the hash key. If this hash key expires, it will be removed from a geospatial set called traffic, which stores all traffic objects detected by other drivers. In this way, we implemented a kind of garbage functionality to remove old detected objects during traffic hours. The reason is that the detected objects are relevant just for a certain amount of time, then have to be deleted. So, let’s install our Redis deployment by following the next steps:
- Create a PersistentVolumeClaim for Redis to persist our data, like so:
$ cat <<EOF | kubectl apply -f -apiVersion: v1kind: PersistentVolumeClaimmetadata:name: db-pv-claimspec:accessModes:- ReadWriteOnceresources:requests:storage: 5GiEOF
- Now, create a ConfigMap to configure Redis to use an authentication password, as follows:
$ cat <<EOF | kubectl apply -f -apiVersion: v1kind: ConfigMapmetadata:name: redis-configmapdata:redis-config: |dir /datarequirepass YOUR_PASSWORDEOF
- Create a deployment for Redis using the previous
redis-configmapConfigMap and thedb-pv-claim-1PersistentVolumeClaim with some resource limits, using the following command:$ cat <<EOF | kubectl apply -f -apiVersion: apps/v1kind: Deploymentmetadata:creationTimestamp: nulllabels:app: redisname: redisspec:replicas: 1selector:matchLabels:app: redisstrategy: {}template:metadata:creationTimestamp: nulllabels:app: redisspec:containers:- name: redisimage: redis:6.2command:- redis-server- /redisconf/redis.confports:- containerPort: 6379resources:limits:cpu: "0.2"memory: "128Mi"volumeMounts:- mountPath: "/data"name: redis-storage- mountPath: /redisconfname: configvolumes:- name: configconfigMap:name: redis-configmapitems:- key: redis-configpath: redis.conf- name: redis-storagepersistentVolumeClaim:claimName: db-pv-claim-1status: {}EOF - Now, create a service for Redis opening port
6379, like so:$ cat <<EOF | kubectl apply -f -apiVersion: v1kind: Servicemetadata:labels:app: redisname: redisspec:ports:- port: 6379protocol: TCPtargetPort: 6379selector:app: redistype: ClusterIPEOF
We now have Redis installed. Let’s move on to deploying our computer vision service at the far edge, in the next section.
Deploying a computer vision service to detect car obstacles using OpenCV, TensorFlow Lite, and scikit-learn
Section titled “Deploying a computer vision service to detect car obstacles using OpenCV, TensorFlow Lite, and scikit-learn”In this section, we are going to explore how to configure the object detection system that runs at the edge with all its components. This section also shows how to configure the public web application running in the cloud that stores and shows information about all detected objects at the edge. Let’s start by first configuring our Raspberry Pi device in the next section.
Preparing your Raspberry Pi to run the computer vision application
Section titled “Preparing your Raspberry Pi to run the computer vision application”Before installing our software, we have to prepare our device to run it. For this, let’s start to configure our Raspberry Pi 4B following the next steps:
- Install Raspbian Pi OS (32 bit) using Debian Bullseye, released at least from 2022-04-04. The code to run the TensorFlow Lite model in this chapter has to run on an ARMv7 device to support the Coral USB Accelerator device and the LCD screen. ARM64 is not supported yet.
- Depending on your webcam, you have to install drivers. In this case, we are using the Logitech C922 PRO webcam, which is automatically detected by Raspbian.
- Connect and configure your GPS module. In this case, our VK-162 G-Mouse module is autodetected by Raspbian too.
- Configure the network to use a wireless connection, to install all the necessary packages to run the application. Later, you can reconfigure your wireless connection to connect to your access point in your smartphone, but you have to delete the previous connection in the
/etc/wpa_supplicant/wpa_supplicant.conffile. - Install the drivers of your LCD screen. In this case, we are using the Miuzei High-Definition Multimedia Interface (HDMI). This will flip the screen horizontally and activate the touch feature (this will be the last step once all the things are configured). You can check the repository at https://github.com/goodtft/LCD-show.git, and you can use any LCD screen.
- Before installing K3s, remember to activate the CGROUPS in the
/boot/cmdline.txtfile, then add the next flags at the end of the line:cgroup_memory=1 cgroup_enable=memory
Important Note
For more information about CGROUPS visit this link: https://man7.org/linux/man-pages/man7/cgroups.7.html
- Get your current Internet Protocol (IP) address by running
ifconfig, then take a look at thewlan0interface, as follows:$ ifconfig wlan0 - Install K3s by running the following command:
$ MASTER_IP=YOUR_PRIVATE_IP$ curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--write-kubeconfig-mode 644" sh -s -
- Now, you can test if everything is working by running the following command:
$ kubectl get nodes
This will return your unique node running.
Now, our edge device is ready to be used to run our service that performs computer vision at the edge. For this, let’s move on to the next section.
Deploying the inference service to detect objects
Section titled “Deploying the inference service to detect objects”The inference service is used in this scenario to do predictions and to classify if an object represents an obstacle for a driver. We use the next table for that:

For example, a car identified by the id 1 in the n field represents a level 1 of warning, so all the objects with warning_level equal to 1 or 2 will be recorded as potential objects that can obstruct traffic or represent danger for the driver. If an object is classified with the value 1000, the object doesn’t represent any danger, so it is not recorded.
The source code of this service consists of two files: index.py and create_model.py. The index.py file contains a basic API to return predictions by calling the model to predict using the /predict path. It has basic code to load the precompiled ML model. The create_model.py file contains code to train and generate a model that will be used for this API using index.py. The code looks like this:
import pandas as pdfrom sklearn import treefrom joblib import dumpdf = pd.read_csv("safety_rules.csv",sep=',', header='infer', encoding='latin-1')df = df.drop(['object'], axis=1)df.head()feature_cols = ["n"]X = df.loc[:, feature_cols]y = df.warning_levelclf = tree.DecisionTreeRegressor()model = clf.fit(X, y)dump(clf, 'safety_rules.model')Here, we read our safety_rules.csv comma-separated values (CSV) file with the rules inside. After, that the information in this file is converted into a DataFrame and the column object is removed from this DataFrame using drop. In AI, you have to represent texts as values. Our object column has a numeric representation in the n column, so the column object can be ignored. The data loaded from the CSV file is represented as a Pandas DataFrame that is used in scikit-learn as the source of data to generate a decision tree. A decision tree is an ML algorithm that can use classified data to do predictions using the data structure of trees for predictions. So, it is one of the simplest methods to do predictions using ML. After the DataFrame is loaded, scikit-learn does its training processes to generate a safety_rules.model model that could be used later in the API for predictions. Every time you build the container, the model is updated by calling the create_model.py file inside the Dockerfile of this API. Now, the serving code for the API will look like this:
<Import Flask and Scikit Learn libraries>def loadModel(): <Load the model safety_rules.model> <Assign the loaded model to the variable clf>@app.route('/predict', methods=["POST"])def predict(): <Use clf variable to call the prediction method> <Return the prediction using JSON format><Inference service initialization on port 3000 by default>By calling the /predict Uniform Resource Locator (URL), you can get predictions from the model based on the rules set in the safety_rules.csv file. You can add more values to classify your images by adding new values in the file and regenerating the container with the new model.
Important Note
To check the code and update the model, check the next link: https://github.com/sergioarmgpl/containers/tree/main/inference/src.
Now, let’s deploy our inference service in our Advanced RISC Machine (ARM) device by following the next steps:
- Create a deployment for the
inferenceAPI, as follows:$ cat <<EOF | kubectl apply -f -apiVersion: apps/v1kind: Deploymentmetadata:creationTimestamp: nulllabels:app: inferencename: inferencespec:replicas: 1selector:matchLabels:app: inferencestrategy: {}template:metadata:creationTimestamp: nulllabels:app: inferencespec:containers:- image: sergioarmgpl/inferencename: inferenceimagePullPolicy: Alwaysresources: {}status: {}EOF - Let’s port forward the service running, like so:
$ kubectl port-forward --address 0.0.0.0 deploy/inference 3000:3000
- Now, let’s call the
inferenceAPI to get some predictions. Let’s use an object detected and classified asotherwith the number 6; it will return a warning level of 3 based on the prediction table. The code is illustrated in the following snippet:$ curl --header "Content-Type: application/json" \--request POST --data '{"data":[6]}' \http://localhost:3000/predict
This will return the following output:
{ "prediction": 3.0}Our inference service is now running, ready to be called inside our device to classify the detected images. Let’s continue deploying the gps-queue service in the next section.
Deploying the gps-queue service to store GPS coordinates
Section titled “Deploying the gps-queue service to store GPS coordinates”The gps-queue service is composed of several containers dedicated to a specific task. First, initialize an init container called init-gps-queue that adds an initial value of -1 inside the /tmp/gps file. This file stores the last GPS coordinate generated. Then, the gps-queue container is in charge of reading the GPS coordinates from our GPS module, so it needs permission to access the /dev folder from the host. Once the GPS coordinate is read, it is stored in /tmp/gps. After this, the sync-traffic-events container calls the gps-api container every 30 seconds by default using the http://localhost:3000/traffic endpoint, which sends the detected objects with their warning classification and GPS coordinate to the http://<TRAFFIC_MANAGER_IP>:5000 public endpoint, which stores this information for some time to be shown in the traffic-map-public service that has public access to show the objects detected by other vehicles. Before deploying our service, let’s explore a little bit the code of the gps-queue container, as follows:
<Import necessary Python libraries to read the GPS module>
<cid variable to set a unique client id for these coordinates><device variable to set where the GPS module will be read in /dev><ser variable to configure the serial communication with the GPS module>
<Initializing the device to read information>
while True: <Read the Coordinate and store it into /tmp/gps>This code configures the GPS module and stores the coordinate in the /tmp/gps file, which is shared by the gps-queue and gps-api containers. It uses a cid variable to associate each GPS coordinate with a unique client identifier (ID) that could be used for customizations to create your own system. The information will be stored in the next format:
{'lat': <LATITUDE_VALUE>,'lng':<LONGITUDE_VALUE>,'cid':<CLIENT_ID>}Now, let’s explore the code inside the gps-api container, as follows:
<Import the necessary Python libraries to run this code><Set traffic_events variable to accumulate detected objects for a time period><Flask and CORS configuration>
@app.route("/gps", methods=["GET"])def getGPSCoordinate(): <Read coordinate form /tmp/gps> <Return the GPS coordinate as JSON as {'lat': <LATITUDE_VALUE>,'lng':<LONGITUDE_VALUE> ,'cid':<CLIENT_ID>} >
@app.route("/traffic/event", methods=["POST"])def registerTrafficEvent(): <Read last GPS coordinate from /tmp/gps> <Get object type and warning classification from the computer vision service> <Generate the Timestamp value for the new detected object> <Assign to a variable the warning, Latitude, Longitude and timestamp information for the object> <Add this information to the traffic_events array to store it temporary the value> <Return the object ide and that the request was processed>
@app.route("/traffic", methods=["GET"])def syncTrafficEvents(): <Filter similar objects stored in the traffic_events array> <Send the filtered array using JSON format to the endpoint http://<TRAFFIC_MANAGER:5000>/traffic/1 to store this information and get it locally and public by calling the endpoint http://<TRAFFIC_MANAGER:5000>/traffic> <Return that the information syncTrafficEvents was processed>
<GPS Queue service initialization on port 3000 by default>As an explanation, the /gps path of this API returns the value of the last GPS coordinate stored in /tmp/gps, and the /traffic/event path receives the object detected from the edge device running the detect.py program. This happens every second. Then, the information is stored temporarily in the traffic_events array. Inside the Pod, the sync-traffic-events container calls the /traffic endpoint of the API running inside the gps-api container, which filters the traffic_events array to have just unique objects detected because the edge program gets a maximum of eight detected objects per video-frame analysis. Once the array is filtered, it is sent to the Traffic Manager service that is running in the cloud by calling its endpoint at http://<TRAFFIC_MANAGER:5000>/traffic/1. This information is requested later by the Traffic Map Public web application using the http://<TRAFFIC_MANAGER:5000>/traffic URL, which shows the globally stored objects detected from all the devices in a map using the Leaflet library.
To deploy this service, execute the following steps:
- Create a deployment for the GPS queue, like so:
$ cat <<EOF | kubectl apply -f -apiVersion: apps/v1kind: Deploymentmetadata:labels:app: gps-queuename: gps-queuespec:replicas: 1selector:matchLabels:app: gps-queuetemplate:metadata:labels:app: gps-queuespec:initContainers:- image: busybox:1.34name: init-gps-queuecommand: ['sh', '-c', "echo '-1' >> /tmp/gps"]securityContext:runAsUser: 1volumeMounts:- name: tmpmountPath: /tmpcontainers:- image: sergioarmgpl/gps_queuename: gps-queueimagePullPolicy: Alwaysenv:- name: DEVICEvalue: "/dev/ttyACM0"securityContext:privileged: truecapabilities:add: ["SYS_ADMIN"]volumeMounts:- mountPath: /devname: dev-volume- name: tmpmountPath: /tmp- image: sergioarmgpl/gps_apiname: gps-apiports:- containerPort: 3000imagePullPolicy: Alwaysenv:- name: ENDPOINTvalue: "http://<TRAFFIC_MANAGER_IP>:5000"securityContext:runAsUser: 1volumeMounts:- name: tmpmountPath: /tmp- image: curlimages/curlname: sync-traffic-eventsenv:- name: URLvalue: "http://localhost:3000/traffic"- name: DELAYvalue: "30"command: [ "sh", "-c"]args:- while :; docurl ${URL};sleep ${DELAY};done;volumes:- name: dev-volumehostPath:path: /devtype: Directory- name: tmpemptyDir: {}status: {}
Important Note
To check the code and create your own containers, you can check the next links:
https://github.com/sergioarmgpl/containers/tree/main/gps-api/src and https://github.com/sergioarmgpl/containers/tree/main/gps-queue/src
Let’s pay attention to the variables that this deployment uses in its containers. These are explained in more detail here:
gps-queue:DEVICE: Configures the device where your GPS module is detected. For the VK-162 G-Mouse module, the default value used is/dev/ttyACM0.
gps-api:ENDPOINT: Configures the public endpoint where all detected objects with GPS coordinates and warnings are stored. This is the public service that stores the coordinates. By default, this ishttp://<TRAFFIC_MANAGER_IP>:5000.
sync-traffic-events:URL: Contains the local URL called periodically to send information about all detected objects. This will call the API configured in thegps-apicontainer. By default, this ishttp://localhost:3000/traffic.DELAY: Configures the amount of time to wait to send the last objects detected with their information. By default, this is 30, which represents the time in seconds.
These values could be used to customize the behavior of the service that processes the objects detected and its GPS coordinates.
- If you want to test the endpoints of this service, you can run inside your edge device
port-forwardto access the API using thecurlcommand, like so:$ kubectl port-forward --address 0.0.0.0 deploy/gps-queue 3001:3000
For example, you can execute the following command:
$ curl http://localhost:3001/gpsIt will return something like this:
{'lat': <LATITUDE_VALUE>,'lng':<LONGITUDE_VALUE> ,'cid':<CLIENT_ID>}We have now deployed the gps-queue service and it’s ready to be used. It’s time to deploy our local web application that will show detected objects at the edge using our edge device equipped with a camera. For this, we have to solve the Cross-Origin Resource Sharing (CORS) restriction call that happens when it calls the traffic-manager public API from the local traffic-map application. CORS is a mechanism that allows or restricts resources on a web page to be requested from a domain outside the current one. In this scenario, it’s called a public API from a local web application. So, let’s move on to the next section to create a simple proxy to resolve this issue.
Deploying traffic-manager to store GPS coordinates
Section titled “Deploying traffic-manager to store GPS coordinates”The traffic-manager service receives detected objects with their GPS coordinates and warning-level classification. This API runs in the cloud, and it’s called periodically by the edge device while it’s moving and detecting objects. This service consists of two containers: one that gives an API to recollect objects detected, and another that is in charge of auto-expiring detected objects and global traffic information. This is because traffic is constantly changing during the day. You can configure these values to fit your own scenario. Let’s explore first the code of the API in the traffic-manager container, as follows:
<Import the necessary Python libraries to run this code>
<Flask and CORS configuration>
<Set time to expire the traffic and objects by setting the values of the variables ttl_trf, ttl_obj>
def redisCon(): <Set and return the Redis connection>
@app.route("/traffic/1", methods=["POST"])def setBulkTrafficObjects(): <Get the Redis connection calling redisCon()> <Get detected objects from the POST request> <Omit to store similar detected objects in a 5 meters radius> <Set a hash value to store type and warning level for each object> <Set expiring time for each hash stored> <Return that the operation was successful {"setTrafficObject":"done"}>
@app.route("/traffic/unit/<unit>/r/<radius>"+"/lat/<lat>/lng/<lng>", methods=["GET"])def getTrafficObjects(unit,radius,lat,lng): <Get the Redis connection calling redisCon()> <Get the objects detected and its metadata from the previous stored hash in the radius configured in the request> <Return that the operation was successful and the objects found in the next format: {"getTrafficObjects":"done", "objects":data }>
<Service initialization on port 3000 by default>This container has two endpoints with the /traffic/1 path. This service stores detected objects at the edge by creating a hash key with the form object:<object-id>:data that stores the type and the warning level, and in the traffic geospatial set stores the GPS coordinate. An expiration time to the traffic key is set or renewed, and for the new object:<object-id>:data hash key, the expiration time is set too. After calling the /traffic/unit/<unit>/r/<radius>/lat/<lat>/lng/<lng> path, the call returns near detected objects in the radius defined in the request. This is a public service that all the edge devices will access periodically to send updates of objects detected while they are moving. Now, let’s explore the code of the autoexpire container, as follows:
<Import all the necessary libraries><Set Redis connection in an r variable>
while True: <Get all the objects inside the traffic sorted set> <Check if each member of the set has its hash value> <If not remove the member of the sorted set> <Wait until the configured delay ends to Update the set again>This container basically checks if each member of the traffic geospatial set has metadata available in the object:<object-id>:data hash key. If none exists, this means that the object passed the maximum amount of time to be relevant in the traffic, which means that it has expired too, and then this code removes the member from the sorted set. This process is called periodically after waiting for a certain number of seconds that are configured by the DELAY variable.
To deploy the traffic-manager service, proceed as follows:
- Create a deployment for the GPS server, like so:
$ cat <<EOF | kubectl apply -f -apiVersion: apps/v1kind: Deploymentmetadata:creationTimestamp: nulllabels:app: traffic-managername: traffic-managerspec:replicas: 1selector:matchLabels:app: traffic-managerstrategy: {}template:metadata:creationTimestamp: nulllabels:app: traffic-managerspec:containers:- image: sergioarmgpl/autoexpirename: autoexpireimagePullPolicy: Alwaysenv:- name: REDIS_HOSTvalue: "redis"- name: REDIS_AUTHvalue: "YOUR_PASSWORD"- name: DELAYvalue: "30"- image: sergioarmgpl/traffic_managername: traffic-managerimagePullPolicy: Alwaysenv:- name: REDIS_HOSTvalue: "redis"- name: REDIS_AUTHvalue: "YOUR_PASSWORD"- name: TTL_TRAFFICvalue: "900"- name: TTL_OBJECTvalue: "180"resources: {}status: {}EOF
This deployment uses the following variables:
REDIS_HOST: This is the name of the Redis service. This variable can be customized to fit your needs.REDIS_AUTH: This is the password to connect to the Redis service.TTL_TRAFFIC: This is the URL of thetracking-serverservice. In this case, the URL matches the internaltracking-serverservice on port3000.TTL_OBJECT: This is the URL of thetracking-serverservice. in this case, the URL matches the internaltracking-serverservice on port3000.DELAY: This is the time to wait to check if a member inside the traffic geospatial sorted set expired.
By configuring these variables, you can customize the behavior of this deployment.
Important Note
To check the code and create your own containers, you can check the next links:
https://github.com/sergioarmgpl/containers/tree/main/traffic-manager/src and https://github.com/sergioarmgpl/containers/tree/main/autoexpire/src
- Now, let’s create a service for this deployment as a LoadBalancer. This IP address will be used in our edge device to propagate this information in the cloud to be accessible to all drivers that use this smart traffic system. The code is illustrated in the following snippet:
$ cat <<EOF | kubectl apply -f -apiVersion: v1kind: Servicemetadata:labels:app: traffic-managername: traffic-manager-lbspec:ports:- port: 5000protocol: TCPtargetPort: 3000selector:app: traffic-managertype: LoadBalancerEOF
- Get the load balancer IP address for your
traffic-managerdeployment with the following command:$ TRAFFIC_MANAGER_IP="$(kubectl get svc traffic-manager-lb -o=jsonpath='{.status.loadBalancer.ingress[0].ip}')"
You can see the value of the TRAFFIC_MANAGER_IP environment variable by running the following command:
$ echo $TRAFFIC_MANAGER_IPNote that it takes some time after the IP address of the load balancer is provisioned. You can check the state of the services by running the following command:
$ kubectl get svc traffic-manager-lbWait until the EXTERNAL_IP environment variable is provisioned.
Also, take note that the $TRAFFIC_MANAGER_IP value will be used to configure the proxy service in the edge device.
- (Optional) If you want to test this API to insert an object manually, run the following command:
$ curl -X POST -H "Accept: application/json" \-H "Content-Type: application/json" \--data '{"object":"person","warning":1,"position":{"lat":1.633518,"lng": -90.591706}}' http://$TRAFFIC_MANAGER_IP:3000/traffic/1
This will return the following output:
{ "setTrafficObject": "done"}- (Optional) To get all detected objects in a radius of 0.1 kilometers, run the following command:
$ curl -X GET -H "Accept: application/json" \http://$TRAFFIC_MANAGER_IP:3000/traffic/objects/unit/km/r/0.1/lat/1.633518/lng/-90.5917
This will return the following output:
{ "getTrafficObjects": [ "person" ]}Now, our traffic-manager API is running in the cloud. Let’s move on to use this API in our edge device using a proxy to prevent CORS restrictions when calling the API, in the next section.
Deploying a simple proxy to bypass CORS
Section titled “Deploying a simple proxy to bypass CORS”The proxy service is used to bypass the CORS restriction that occurs when a local website running on a private network tries to call a public API using a public API address. Using a proxy to forward requests to this public site could be one possible and simple solution to solve this. Another one is to modify the request headers on the API call and add the necessary headers to bypass the CORS restriction. In this case, we are going to use a proxy build with Flask to forward all local GET requests to the traffic-manager API, which is a public API deployed in the cloud and is accessible over the internet. Let’s explore the code a little bit before deploying the proxy service, as follows:
from flask import Flask,request,redirect,Responseimport osimport requestsapp = Flask(__name__)url = os.environ['URL']
@app.route('/<path:path>',methods=['GET'])def proxy(path): global url r = requests.get(f'{url}/{path}') excluded_headers = ['content-encoding' , 'content-length', 'transfer-encoding' , 'connection'] headers = [(name, value) for (name, value) in r.raw.headers.items() if name.lower() not in excluded_headers] response = Response(r.content, r.status_code, headers) return response
if __name__ == '__main__': app.run(debug = False,port=5000)This code basically receives all GET requests on any path and forwards the requests with all the important headers to the URL defined in the environment variable. This API is accessible using port 5000. Now, let’s move on to deploy this simple proxy to forward all calls from our local Traffic Map web application to the public Traffic Manager service as though it is running locally in the same host where Traffic Map is running. To deploy the proxy service, execute the following steps:
- Create a deployment for the GPS server, like so:
$ cat <<EOF | kubectl apply -f -apiVersion: apps/v1kind: Deploymentmetadata:creationTimestamp: nulllabels:app: proxyname: proxyspec:replicas: 1selector:matchLabels:app: proxystrategy: {}template:metadata:creationTimestamp: nulllabels:app: proxyspec:containers:- image: sergioarmgpl/proxyname: proxyimagePullPolicy: Alwaysenv:- name: URLvalue: "http://<TRAFFIC_MANAGER_IP>:5000"resources: {}status: {}EOF
This deployment uses the following variables:
URL: This variable has the URL where the proxy is going to redirect allGETrequests received by the proxy in port5000. This URL will be thetraffic-managerpublic IP address using the formathttp://<TRAFFIC_MANAGER_IP>:5000.
Important Note
To check the code and create your own container, you can check the next link: https://github.com/sergioarmgpl/containers/tree/main/proxy/src. This small proxy is a custom implementation that you can implement using languages other than Python to have all the control in your implementation. You can also use solutions such as using NGINX with a proxy_pass configuration, and so on.
- You can test the proxy by running something like this:
$ curl http://localhost:5000/<REMOTE_PATH>
Here, the remote path could be /traffic, which is a URL where the Traffic Manager service returns all objects globally detected by drivers.
Now our proxy is running, let’s deploy our Traffic Map web application to show the detected objects that represent warnings for drivers in the next section.
Deploying the edge application to visualize warnings based on computer vision
Section titled “Deploying the edge application to visualize warnings based on computer vision”Our visual application consists of two parts: the first one is a web application that shows all data from all drivers using the smart traffic system, and the other one is a desktop application that shows the detected objects in real time. So, let’s start installing our web application to visualize objects detected by different drivers in the next section.
Installing the Traffic Map application to visualize objects detected by drivers
Section titled “Installing the Traffic Map application to visualize objects detected by drivers”We have now set up the necessary APIs to visualize what our device detected. We have to continue deploying our web application to visualize this object on a map. This is where our Traffic Map application comes in handy. But let’s explore the code first before deploying it, as follows:
<imported libraries><app_initialization><CORS configuration>@app.route("/")def map(): return render_template(<Render map.html Using environment variables GPS_QUEUE,TRAFFIC_MANAGER, LATITUDE and LONGITUDE>)<Starting the web application on port 3000>This is similar to the previous web application map used in Chapter 13, Geolocalization Applications using GPS, NoSQL, and K3s Clusters, but this one calls the GPS Queue service to get the current GPS coordinate that is running in the edge device and get data from the public endpoint of the Traffic Manager service that has to be accessed by using our custom proxy service to prevent CORS access restrictions. It also has the option to center the map at the beginning every time the page is loaded.
The web part uses the map.html file with the following code:
<!DOCTYPE html><html lang="en"><head><Load Javascript libraries><Load page styles><body> <div id='map'></div><script> <Load Map in an initial GPS position> var marker var markers = [] var osm = L.tileLayer( 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { <Set Open Street Map Initial Configuration using Leaflet> }); osm.addTo(map); setInterval(() => { $.getJSON("http://{{ GPS_QUEUE }}:3001/gps", function(gps) { <Delete current markers> <Get current position of your device and show it in the map> $.getJSON( "http://{{ TRAFFIC_MANAGER }}:5000"+ "/traffic/unit/km/r/0.5/lat/<LATITUDE>" "/lng/<LONGITUDE>", function(pos) { <This gets all the detected objects in a radius of 0.5 km> <For each object returned show it in the map using markPosition(object,lat,lng,o_type,warning) function> }); }); }, 5000);
<Configure the icons to visualize if an object is a person, car or a truck> function markPosition(object,lat,lng,o_type,warning) { <Create a maker with the appropriate Icon showing the object name, latitude, longitude, type of object and warning level> }</script></body></html>This code basically centers the map with initial latitude and longitude coordinates, shows the current position of the device in a blue globe, and shows the detected objects with icons, showing the object name, the GPS coordinates, the type of object, and the warning level. It should look something like this:

Figure 14.3 – Driver current position
This shows the driver’s current position in real time, while the vehicle is moving. The other possible visualization shows how detected objects appear across the map. This information is requested using the proxy service to visualize all detected objects by other drivers. This could represent a kind of augmented reality (AR), something similar to what Waze does with its application. The visualization looks like this:

Figure 14.4 – Detected object’s current position and warning message
If you click inside the detected object, it will show the current GPS coordinate, the type of object, and a warning message. There are several objects included in this default implementation. The implementation includes car, truck, and person detection as possible obstacles and potential warnings for a driver. You can see the following icons on the map:
![]()
Figure 14.5 – Car, truck, and person icons shown in Traffic Map
By default, our web application updates the objects every 5 seconds within a radius of 0.5 kilometers. Those values can be customized to satisfy your own solution. Now, let’s deploy our Traffic Map web application by executing the next commands:
- Create a
traffic-mapdeployment by running the following command:$ cat <<EOF | kubectl apply -f -apiVersion: apps/v1kind: Deploymentmetadata:creationTimestamp: nulllabels:app: traffic-mapname: traffic-mapspec:replicas: 1selector:matchLabels:app: traffic-mapstrategy: {}template:metadata:creationTimestamp: nulllabels:app: traffic-mapspec:containers:- image: sergioarmgpl/traffic_mapname: traffic-mapimagePullPolicy: Alwaysenv:- name: LATITUDEvalue: "<YOUR_LATITUDE_COORDINATE>"- name: LONGITUDEvalue: "<YOUR_LONGITUDE_COORDINATE>"- name: GPS_QUEUEvalue: "localhost" #<GPS_QUEUE_IP>- name: TRAFFIC_MANAGERvalue: "<TRAFFIC_MANAGER_IP>"resources: {}status: {}EOF
This deployment has the following environment variables:
LATITUDE: Initial GPS latitude coordinate to center your map.LONGITUDE: Initial GPS longitude coordinate to center your map.GPS_QUEUE: IP address endpoint of thegps-queueservice. In this case, because this runs locally, it is set by default aslocalhost.TRAFFIC_MANAGER: IP address endpoint of your Traffic Manager application. In this case, because of the use of theproxyservice, we can call it usinglocalhost, which prevents the CORS restriction.
Important Note
To check the code and create your own container of traffic_map, you can check the next link:
https://github.com/sergioarmgpl/containers/tree/main/traffic-map/src
We have now deployed the Traffic Map web application on our edge device. Let’s move on to run our object detection system at the edge to perform our computer vision, in the next section.
Detecting objects with computer vision using OpenCV, TensorFlow Lite, and scikit-learn
Section titled “Detecting objects with computer vision using OpenCV, TensorFlow Lite, and scikit-learn”The service that performs computer vision is contained in the detect.py file. This will run on our edge device. Let’s explore the code inside this file before preparing our device to run this program, as follows:
<Imported libraries to run OpenCV in TensorFlow Lite>
#Array to map detected objectsobj_values = {"car":1,"cat":2,"person":3,"dog":4,"semaphore":5,"truck":6,"other":1000}
def run(): <Initialize Video Capture for the camera> <Set screen size to capture> <Initialize the object detection model> #Array to store detected objects items = [] while Camera is Opened: detection_result = detector.detect(input_tensor) items.clear() <store detected objects in the items arrays> <Show the FPS evaluated> <Count objects detected per type of object> <Get the classification of each object calling /predict endpoint from the gps-api> if the warning count of the group <= 2: <A real warning is detected we push this information calling /traffic/event and warning is incremented> if warning: <show unique objects found warning is set to zero> else: <show No warnings>
if <ESC key is pressed>: <break the cycle> <Set cv2 window size to show the capture> <Close the Camera Capture> <Destroy all windows>
def main(): <Parse parameters to run the program> <Call run() function to start analyzing video capture>
if __name__ == '__main__': <call the main() function of the program>This code starts the video capture and then sends this image in a format that TensorFlow Lite can analyze. TensorFlow Lite detects coordinates where objects are detected and classifies the objects with a label that is their name. This program will use the efficientdet_lite0_edgetpu_metadata.tflite model. In this case, we are focusing on the car, person, dog, semaphore, and truck objects. These objects represent obstacles for drivers and represent a level of warning. If the detected object is different than these objects, it’s classified as other and it’s omitted as a warning. If you want to add more objects to the list, you just have to modify the obj_values array with new values, as in the following example:
obj_values = {"car":1,..,"other_object":7,..."other":1000}In each loop of this program, the detected objects are counted by groups and stored in the items array. Then, if one of these groups detects more than one object and the group is one of the identified objects in the obj_values array, the detected objects in the group are counted as potential object obstacles that represent warnings for drivers. To calculate the warning level, the script calls the inference API, and then, if a warning is detected, it calls the traffic-map service using the proxy service previously installed using the http://localhost:5000/traffic/event URL. Every time the proxy is called, the requests will be sent to the public endpoint of the traffic-manager service deployed in the cloud. Then, after the object analysis, the items array is cleared and the output summarizing the detected objects is shown in a blue box using OpenCV. It will look like this:

Figure 14.6 – Object detection screen
This output also shows the detected objects marked with a red rectangle with the name of the detected object. In the upper-left corner, you will see the number of FPS analyzed. Our warning box will show two types of messages: either the group of objects found (for example, person, car found) or that there are no detected objects—this will show the message No warnings. The service closes if you press the Esc key. To install the object detection service in your edge device, execute the following steps:
- Connect your edge device to a network that you can access.
- Log in to your edge device, like so:
$ ssh your_user@<EDGE_DEVICE_IP>
You can get the IP address of your device by running the following command:
$ ifconfig wlan0You can run it by connecting your device to an HDMI screen and connecting a keyboard and mouse to your device.
- Clone the repository by running the following code:
$ git clone https://github.com/PacktPublishing/Edge-Computing-Systems-with-Kubernetes$ cd Edge-Computing-Systems-with-Kubernetes/ch14/code/python/object_detection
- Install missing dependencies to run OpenCV and the camera, like so:
$ /bin/bash install_deps.sh
- Configure the device to run the object detection program, as follows:
$ /bin/bash setup.sh
- Run the script to install desktop shortcuts, like so:
$ /bin/bash install_shortcuts.sh
Important Note
Take a look at the files with a .desktop extension that call the run.sh script and the files with a .desktop extension that start the detection application and the local web Traffic Map application. These files are located in the ch14/code/python/object_detection directory.
- Test the installation by clicking on the new Detector desktop shortcut.
- Test the local Traffic Map application by clicking on the Traffic desktop shortcut. This will open Chromium at
http://localhost:5000. - Reconfigure your wireless network to use the access point connection of your smartphone and reset your
/etc/wpa_supplicant/wpa_supplicant.confconfiguration file by removing thenetwork {}entries to use your smartphone internet connection.
Important Note
For more information, you can check the next link:
https://wiki.archlinux.org/title/wpa_supplicant
- Now, you can configure your touchscreen. In this case, we are using the Miuzei LCD 4.0-inch HDMI display, which flips the screen. For this, execute the following commands:
$ sudo rm –rf LCD-show$ git clone https://github.com/goodtft/LCD-show.git$ chmod –R 755 LCD-show$ cd LCD-show$ sudo ./MPI4008-show
- Now, restart your device by running the following command:
$ sudo restart
- Now, access the Detect shortcut to start the service to detect objects.
Important Note
You can accelerate the video-frame analysis by uncommenting the --enableEdgeTPU flag in the ch14/code/python/object_detection/run.sh file. Our detection code is based on the official Tensor Flow example that uses the Coral USB Accelerator device. This device is a TPU, which is a dedicated unit to process information using NNs. The configuration of the Coral device is out of the scope of this book. For more information, check the Coral USB Accelerator link in the Further reading section.
- Start the Traffic Map application by clicking on the Traffic shortcut. If there are objects detected, they will appear 30 seconds later in the web application.
The last step is to deploy a public Traffic Map application to visualize all traffic in a radius area. For this, let’s deploy the last service— Traffic Map Public —in the next section.
Deploying a global visualizer for the smart traffic system
Section titled “Deploying a global visualizer for the smart traffic system”The Traffic Map Public service is the static version of Traffic Map that only shows detected objects within a radius of 5 kilometers. This service is deployed in the cloud, so you should expect the same visualization as with the Traffic Map service, but the only missing part is that it doesn’t show your real-time GPS position because it is static. The GPS position to take into consideration could be a GPS coordinate that is the center of the city that you want to monitor. In general, this web visualization could fit a static report for a municipality. The code is the same as for the Traffic Map web application, but the continuous update of the GPS position is omitted. To deploy this service, run the following commands:
- Create a
traffic-mapdeployment by running the following command:$ cat <<EOF | kubectl apply -f -apiVersion: apps/v1kind: Deploymentmetadata:creationTimestamp: nulllabels:app: traffic-map-publicname: traffic-map-publicspec:replicas: 1selector:matchLabels:app: traffic-map-publicstrategy: {}template:metadata:creationTimestamp: nulllabels:app: traffic-map-publicspec:containers:- image: sergioarmgpl/traffic_map_publicname: traffic-map-publicimagePullPolicy: Alwaysenv:- name: LATITUDEvalue: "<YOUR_LATITUDE_COORDINATE>"- name: LONGITUDEvalue: "<YOUR_LONGITUDE_COORDINATE>"- name: TRAFFIC_MANAGERvalue: "<TRAFFIC_MANAGER_IP>"resources: {}status: {}EOF
This deployment has the following environment variables:
LATITUDE: Initial GPS latitude coordinate to center your map.LONGITUDE: Initial GPS longitude coordinate to center your map.GPS_QUEUE: IP address endpoint of thegps-queueservice. In this case, because this runs locally, it is set by default aslocalhost.TRAFFIC_MANAGER: IP address endpoint of your Traffic Manager service. In this case, because of the use of the proxy, we can call it usinglocalhost, which prevents the CORS restriction.
Important Note
To check the code and create your own container of traffic-map-public, you can check the next link:
https://github.com/sergioarmgpl/containers/tree/main/traffic-map-public/src
- Now, let’s create a service for this deployment as a LoadBalancer. This IP address will be the endpoint to access the Traffic Map public web application. The code is illustrated in the following snippet:
$ cat <<EOF | kubectl apply -f -apiVersion: v1kind: Servicemetadata:creationTimestamp: nulllabels:app: traffic-map-publicname: traffic-map-public-lbspec:ports:- port: 3000protocol: TCPtargetPort: 3000selector:app: traffic-map-publictype: LoadBalancerstatus:loadBalancer: {}EOF
Important Note
To troubleshoot your deployments, you can use the $ kubectl logs pod/<POD> -f <CONTAINER_NAME> command. This will show you some useful outputs to troubleshoot services.
- Get the load balancer IP for your
traffic-map-publicdeployment with the following command:$ TRAFFIC_MAP_PUBLIC="$(kubectl get svc traffic-map-public -o=jsonpath='{.status.loadBalancer.ingress[0].ip}')"
You can see the value of the TRAFFIC_MAP_PUBLIC environment variable by running the following command:
$ echo $TRAFFIC_MAP_PUBLICNote that it takes some time after the IP address of the load balancer is provisioned. You can check the state of the services by running the following command:
$ kubectl get svc traffic-map-public-lbWait until the EXTERNAL_IP environment variable is provisioned.
- Access the Traffic Map public application at
http://<TRAFFIC_MAP_PUBLIC>:3000.
Now everything is running, try to fill the system with data and drive your car with your edge device to capture objects. You will then see the objects in the system in a few seconds. Take a look at the Further reading section, where there are a lot of materials that you can explore to create your system. But now, it’s time to summarize what we learned. Let’s move on to the Summary section.
Summary
Section titled “Summary”In this chapter, we learned how you can use AI to analyze video captured by cameras, to detect objects that potentially represent obstacles for drivers. This was implemented to run at the edge on a Raspberry Pi, using the power of Kubernetes with K3s. With this approach, we created a decoupled system that could be easier to upgrade using containers. We also learned how this kind of system can be used in real-world scenarios to monitor traffic behavior to improve driver safety. Across this implementation, we also learned how this kind of system is distributed across the edge and the cloud to process and show information locally to drivers to improve their driving experience. In the last chapter, we are going to give an easy method to organize and design fast your own edge computing system using a diagram called the edge computing design system canvas.
Questions
Section titled “Questions”Here are a few questions to validate your new knowledge:
- How are AI, ML, and computer vision related to each other to design smart traffic systems?
- How do TensorFlow Lite and scikit-learn work to detect objects and perform predictions?
- How does computer vision work running at the edge?
- How can you distribute data across the edge and the cloud?
- How can you use Python to build a computer vision system?
- How can you use K3s to design distributed systems that detect objects in real time?
Further reading
Section titled “Further reading”You can refer to the following references for more information on the topics covered in this chapter:
- What is artificial intelligence (AI)?: https://www.techtarget.com/searchenterpriseai/definition/AI-Artificial-Intelligence
- Agents in Artificial Intelligence: https://www.geeksforgeeks.org/agents-artificial-intelligence and https://www.educba.com/agents-in-artificial-intelligence
- Smart Traffic Management: Optimizing Your City’s Infrastructure Spend: https://www.digi.com/blog/post/smart-traffic-management-optimizing-spend
- Markers with Custom Icons: https://leafletjs.com/examples/custom-icons
- MLOps Using Argo and K3s: https://github.com/sergioarmgpl/mlops-argo-k3s
- YOLO and Tiny-YOLO object detection on the Raspberry Pi and Movidius NCS: https://pyimagesearch.com/2020/01/27/yolo-and-tiny-yolo-object-detection-on-the-raspberry-pi-and-movidius-ncs
- TensorFlow Lite example apps: https://www.tensorflow.org/lite/examples
- TensorFlow Hub: https://tfhub.dev
- Get models for TensorFlow Lite: https://www.tensorflow.org/lite/models
- Edge Analytics in Transportation and Logistics Space: A Case Study: https://www.skillsire.com/read-blog/174_edge-analytics-in-transportation-and-logistics-space-a-case-study.html
- Tutorial to set up TensorFlow Object Detection API on the Raspberry Pi: https://github.com/EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi
- TensorFlow-Lite-Object-Detection-on-Android-and-Raspberry-Pi: https://github.com/EdjeElectronics/TensorFlow-Lite-Object-Detection-on-Android-and-Raspberry-Pi
- TensorFlow Lite Python object detection example with Raspberry Pi: https://github.com/tensorflow/examples/tree/master/lite/examples/object_detection/raspberry_pi
- Python Project – Real-time Human Detection & Counting: https://data-flair.training/blogs/python-project-real-time-human-detection-counting
- Coral USB Accelerator: https://coral.ai/products/accelerator
- Edge TPU simple camera examples: https://github.com/google-coral/examples-camera
- Use NGINX as a Reverse Proxy: https://www.linode.com/docs/guides/use-nginx-reverse-proxy
- Movidius on Mac OS: https://github.com/acharroux/Movidius-On-MacOS
- NCS-Pi-Stream: https://github.com/HanYangZhao/NCS-Pi-Stream
- Intel® Neural Compute Stick 2 (Intel® NCS2): https://www.intel.com/content/www/us/en/developer/tools/neural-compute-stick/overview.html
- Deep Surveillance with Deep Learning – Intelligent Video Surveillance Project: https://data-flair.training/blogs/deep-surveillance-with-deep-learning-intelligent-video-surveillance-project
- Road Lane line detection – Computer Vision Project in Python: https://data-flair.training/blogs/road-lane-line-detection
- Raspberry Pi and Movidius NCS Face Recognition: https://pyimagesearch.com/2020/01/06/raspberry-pi-and-movidius-ncs-face-recognition
- OpenVINO, OpenCV, and Movidius NCS on the Raspberry Pi: https://pyimagesearch.com/2019/04/08/openvino-opencv-and-movidius-ncs-on-the-raspberry-pi
- Speed up predictions on low-power devices using Neural Compute Stick and OpenVINO: https://towardsdatascience.com/speed-up-predictions-on-low-power-devices-using-neural-compute-stick-and-openvino-98f3ae9dcf41
- Deep Learning with Movidius NCS (pt.4) Installing NCSDK on a Rock64: https://www.youtube.com/watch?v=AXzIYk7-lr8
- Glyph-based video visualization on Google Map for surveillance in smart cities: https://jivp-eurasipjournals.springeropen.com/articles/10.1186/s13640-017-0175-4
- Looking-In and Looking-Out of a Vehicle: Computer-Vision-Based Enhanced Vehicle Safety: https://escholarship.org/content/qt2g6313r2/qt2g6313r2_noSplash_81ae2290f201a6b25e8eecc8a1142845.pdf?t=lnpgaj
- Install Touch Screen and Touch Calibration Program for Raspberry Pi: https://www.gechic.com/en/raspberry-pi-install-touch-monitor-and-touch-calibrator-driver
- Rotating a Raspberry Pi 4 Touch Monitor: https://www.interelectronix.com/rotating-raspberry-pi-4-touch-monitor.html
- Calibrating Touchscreen: https://wiki.archlinux.org/title/Calibrating_Touchscreen