{"id":60788,"date":"2019-01-26T11:02:09","date_gmt":"2019-01-26T11:02:09","guid":{"rendered":"http:\/\/randomnerdtutorials.com\/?p=60788"},"modified":"2019-04-02T10:23:16","modified_gmt":"2019-04-02T10:23:16","slug":"car-plate-recognition-system-with-raspberry-pi-and-node-red","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/car-plate-recognition-system-with-raspberry-pi-and-node-red\/","title":{"rendered":"Car Plate Recognition System with Raspberry Pi and Node-RED"},"content":{"rendered":"<p>In this project you&#8217;re going to learn how to build a car recognition system using a Raspberry Pi and Node-RED. For this project we&#8217;ll be using a software called OpenALPR (Automatic License Place Recognition) that has an API you can use to identify car plates and car models based on an image.<!--more--><\/p>\n<p><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-60919\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/identify-car-thumbnail.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"1200\" height=\"675\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/identify-car-thumbnail.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/identify-car-thumbnail.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/identify-car-thumbnail.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/identify-car-thumbnail.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<h2>Overview<\/h2>\n<p>This project is divided into two parts.<\/p>\n<ol>\n<li>First, we&#8217;ll identify a car using OpenALPR and Node-RED;<\/li>\n<li>Then, we&#8217;ll trigger an event based on the detected car (for example, open the garage when it detects that your car arrived home);<\/li>\n<\/ol>\n<p>The following image shows how the detection process will work:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter size-full wp-image-60920\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/project-overview-1.jpg?resize=1057%2C197&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"1057\" height=\"197\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/project-overview-1.jpg?w=1057&amp;quality=100&amp;strip=all&amp;ssl=1 1057w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/project-overview-1.jpg?resize=300%2C56&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/project-overview-1.jpg?resize=768%2C143&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/project-overview-1.jpg?resize=1024%2C191&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1057px) 100vw, 1057px\" \/><\/p>\n<p>In this example, we use a PIR motion sensor to detect that the car arrives home. There are other sensors that may be more suitable to detect a car, for example:<\/p>\n<ul>\n<li><strong>Hall effect sensor<\/strong>: senses changes in magnetic field when the car is near;<\/li>\n<li><strong>Ultrasonic sensor<\/strong>: detects distance to an object;<\/li>\n<li><strong>Active infrared detectors<\/strong>: detects the presence of an object by detecting the reflection of infrared light.<\/li>\n<\/ul>\n<p>When the sensor detects motion, the Raspberry Pi camera takes a photo. After that, the Pi sends a request to OpenALPR with the car photo to be identified. Then, the OpenALPR API returns the car details like: plate number, model, color, and the confidence of the results.<\/p>\n<p>After identifying a car, we&#8217;ll do some verifications, and if we found an authorized car, we&#8217;ll trigger an event (that can be open the garage, for example). The following image contains a flowchart showing the process.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter size-full wp-image-60921\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/project-overview-2.png?resize=854%2C558&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"854\" height=\"558\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/project-overview-2.png?w=854&amp;quality=100&amp;strip=all&amp;ssl=1 854w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/project-overview-2.png?resize=300%2C196&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/project-overview-2.png?resize=768%2C502&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 854px) 100vw, 854px\" \/><\/p>\n<p>Here&#8217;s what happens: after the car has been identified by OpenALPR, we&#8217;ll check if the license plate and the car model match. If they match, we&#8217;ll check if the car is in the list of authorized vehicles. If it is, we&#8217;ll trigger an event. For example: open the garage. After that, we wait a determined period of time until the car enters the garage. Then, you need to add several verifications to check if the car has already entered the garage. If yes, you can close the garage.<\/p>\n<h2>Prerequisites:<\/h2>\n<ul>\n<li>You should be familiar with the Raspberry Pi \u2013\u00a0<a href=\"https:\/\/randomnerdtutorials.com\/getting-started-with-raspberry-pi\/\" target=\"_blank\" rel=\"noopener noreferrer\">read Getting Started with Raspberry Pi<\/a>.<\/li>\n<li>You should have the Raspbian or Raspbian Lite operating system installed in your Raspberry Pi \u2013\u00a0<a href=\"https:\/\/randomnerdtutorials.com\/installing-raspbian-lite-enabling-and-connecting-with-ssh\/\">read Installing Raspbian Lite, Enabling and Connecting with SSH<\/a>.<\/li>\n<li>We&#8217;ll be using the Raspberry Pi Camera V2 Module, we recommend reading:\u00a0<a href=\"https:\/\/randomnerdtutorials.com\/guide-to-raspberry-pi-camera-v2-module\/\" target=\"_blank\" rel=\"noopener noreferrer\">Guide to Raspberry Pi Camera V2 Module<\/a>.<\/li>\n<li>You need\u00a0<a href=\"https:\/\/randomnerdtutorials.com\/getting-started-with-node-red-on-raspberry-pi\/\">Node-RED installed on your Pi<\/a> and <a href=\"https:\/\/randomnerdtutorials.com\/node-red-with-raspberry-pi-camera-take-photos\/\" target=\"_blank\" rel=\"noopener noreferrer\">Node-RED prepared to take photos with the Pi Camera<\/a><\/li>\n<\/ul>\n<p>If you like home automation and you want to learn more about Node-RED, Raspberry Pi, ESP8266 and Arduino, we recommend that you download our course:\u00a0<a href=\"https:\/\/randomnerdtutorials.com\/build-a-home-automation-system-for-100\/\" target=\"_blank\" rel=\"noopener noreferrer\">Build a Home Automation System for $100<\/a>.<\/p>\n<h2>Parts Required<\/h2>\n<p>For this project you need the following parts (click the links below to find the best price at\u00a0<a href=\"https:\/\/makeradvisor.com\/tools\/\" target=\"_blank\" rel=\"noopener noreferrer\">Maker Advisor<\/a>):<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60898\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/parts-required.jpg?resize=750%2C476&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"750\" height=\"476\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/parts-required.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/parts-required.jpg?resize=300%2C190&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/p>\n<ul>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/raspberry-pi-board\/\" target=\"_blank\" rel=\"noopener noreferrer\">Raspberry Pi Board<\/a>\u00a0\u00a0\u2013 read\u00a0<a href=\"https:\/\/makeradvisor.com\/best-raspberry-pi-3-starter-kits\/\" target=\"_blank\" rel=\"noopener noreferrer\">Best Raspberry Pi Starter Kits<\/a><\/li>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/raspberry-pi-camera-v2-module\/\" target=\"_blank\" rel=\"noopener noreferrer\">Raspberry Pi Camera V2 Module<\/a><\/li>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/microsd-card-raspberry-pi-16gb-class-10\/\" target=\"_blank\" rel=\"noopener noreferrer\">MicroSD Card \u2013 16GB Class10<\/a><\/li>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/raspberry-pi-power-supply\/\" target=\"_blank\" rel=\"noopener noreferrer\">Raspberry Pi Power Supply (5V 2.5A)<\/a><\/li>\n<li><a href=\"https:\/\/makeradvisor.com\/mini-hc-sr505-pir-motion-sensor\/\" target=\"_blank\" rel=\"noopener noreferrer\">Mini PIR Motion Sensor<\/a> or <a href=\"https:\/\/makeradvisor.com\/tools\/pir-motion-sensor-hc-sr501\/\" target=\"_blank\" rel=\"noopener noreferrer\">PIR Motion Sensor<\/a><\/li>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/3mm-5mm-leds-kit-storage-box\/\" target=\"_blank\" rel=\"noopener noreferrer\">LED<\/a><\/li>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/resistors-kits\/\" target=\"_blank\" rel=\"noopener noreferrer\">Resistor<\/a>\u00a0(220 or 330 ohms should work)<\/li>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/mb-102-solderless-breadboard-830-points\/\" target=\"_blank\" rel=\"noopener noreferrer\">Breadboard<\/a><\/li>\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/jumper-wires-kit-120-pieces\/\" target=\"_blank\" rel=\"noopener noreferrer\">Jumper wires<\/a><\/li>\n<\/ul>\n<p><strong>Note<\/strong>: at the moment, we don&#8217;t have an automatic garage, so we&#8217;ll use an LED to mimic the event triggering (we know it is not the same thing, but you get the idea).<\/p>\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n<h2>Connect the Raspberry Pi Camera Module<\/h2>\n<p>With the Pi shutdown, connect the camera to the Pi CSI port as shown in the following figure. Make sure the camera is connected in the right orientation with the ribbon blue letters facing up (you need to <a href=\"https:\/\/randomnerdtutorials.com\/guide-to-raspberry-pi-camera-v2-module\/\">enable the camera in your Raspbian OS<\/a>).<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-41868\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/08\/connectcamera-1.jpg?resize=516%2C406&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"516\" height=\"406\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/08\/connectcamera-1.jpg?w=516&amp;quality=100&amp;strip=all&amp;ssl=1 516w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/08\/connectcamera-1.jpg?resize=300%2C236&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 516px) 100vw, 516px\" \/><\/p>\n<p>You should also have <a href=\"https:\/\/randomnerdtutorials.com\/getting-started-with-node-red-on-raspberry-pi\/\">Node-RED installed in your Pi<\/a> and the <a href=\"https:\/\/randomnerdtutorials.com\/node-red-with-raspberry-pi-camera-take-photos\/\">node-red-contrib-camerapi node Installed<\/a>:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60904\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/camera-pi-take-photo-node.png?resize=163%2C106&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"163\" height=\"106\" \/><\/p>\n<h2>Schematics<\/h2>\n<p>Assemble the circuit to test this project. Follow these next schematic diagram:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60927\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/identify-car-schematics.png?resize=636%2C706&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"636\" height=\"706\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/identify-car-schematics.png?w=636&amp;quality=100&amp;strip=all&amp;ssl=1 636w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/identify-car-schematics.png?resize=270%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 270w\" sizes=\"(max-width: 636px) 100vw, 636px\" \/><\/p>\n<p>After having your Raspberry Pi prepared and Node-RED software configured, you can continue with this project.<\/p>\n<h2>OpenALPR<\/h2>\n<p><a href=\"https:\/\/github.com\/openalpr\/openalpr\" target=\"_blank\" rel=\"noopener noreferrer\">OpenALPR<\/a>\u00a0is an open source Automatic License Plate Recognition library written in C++ with bindings in C#, Java, Node.js, Go, and Python. They also have the\u00a0<a href=\"https:\/\/www.openalpr.com\/cloud-api.html\" target=\"_blank\" rel=\"noopener noreferrer\">OpenALPR Cloud API<\/a> which is a web service running in the cloud that analyzes images of vehicles and responds with license plate, model, color and much more. OpenALPR Cloud API has a free service that allows up to 2000 free recognitions per month.<\/p>\n<p><strong>Note:<\/strong> instead of using their Cloud API that is limited to only 2000 recognitions per month, you can install their Open Source software and use their\u00a0<a href=\"https:\/\/github.com\/openalpr\/openalpr\/wiki\/Integrating-OpenALPR#python\" target=\"_blank\" rel=\"noopener noreferrer\">Python integration<\/a>\u00a0to write Python scripts to analyse unlimited images. That way you don&#8217;t need to use their cloud service and you aren&#8217;t restricted to 2000 requests per month.<\/p>\n<h3>Supported countries<\/h3>\n<p>OpenALPR contains specialized training data for many plate styles. Currently, OpenALPR supports the following countries:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60844\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/countries-supported-openaplr.png?resize=925%2C181&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"925\" height=\"181\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/countries-supported-openaplr.png?w=925&amp;quality=100&amp;strip=all&amp;ssl=1 925w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/countries-supported-openaplr.png?resize=300%2C59&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/countries-supported-openaplr.png?resize=768%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 925px) 100vw, 925px\" \/><\/p>\n<p><span style=\"color: #ff0000;\"><strong>Note:<\/strong> <\/span>Europe is not a country, but we assume that they support all countries in Europe. If\u00a0your country is not listed, you may still experience high accuracy rates by using training data for a country that has plates that look similar to yours.<\/p>\n<h3>Creating a free account<\/h3>\n<p>To get started with OpenALPR Cloud API, you can<a href=\"https:\/\/cloud.openalpr.com\/account\/register\"> create a free account<\/a>. After completing your account creation, you should have access to the following page:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60902\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/openaplr-main-page.png?resize=1076%2C611&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"1076\" height=\"611\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/openaplr-main-page.png?w=1076&amp;quality=100&amp;strip=all&amp;ssl=1 1076w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/openaplr-main-page.png?resize=300%2C170&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/openaplr-main-page.png?resize=768%2C436&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/openaplr-main-page.png?resize=1024%2C581&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1076px) 100vw, 1076px\" \/><\/p>\n<p>Open the<strong> Cloud API<\/strong> tab to access your <strong>Secret Key<\/strong>. You need it to make requests to the API.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60842\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/openaplr-sk-key.png?resize=1069%2C519&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"1069\" height=\"519\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/openaplr-sk-key.png?w=1069&amp;quality=100&amp;strip=all&amp;ssl=1 1069w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/openaplr-sk-key.png?resize=300%2C146&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/openaplr-sk-key.png?resize=768%2C373&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/openaplr-sk-key.png?resize=1024%2C497&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1069px) 100vw, 1069px\" \/><\/p>\n<p>In my case, the secret key is: <strong>sk_8081041caedd50a&#8212;&#8212;&#8212;<\/strong><\/p>\n<p>Save your secret key in a safe place, because you&#8217;ll need it in just a moment.<\/p>\n<h2>Testing the Camera and OpenALPR Service<\/h2>\n<p>First, you should start by identifying your car using the Pi Camera and the OpenALPR service. So, start with the provided sample flow that takes a photo and makes a request to the OpeALPR Cloud API to identify your car. To import the Node-RED flow provided, go to the <a href=\"https:\/\/raw.githubusercontent.com\/RuiSantosdotme\/Car-Plate-Recognition-System-with-Raspberry-Pi-and-Node-RED\/master\/node_red_identify_car_plate_and_model.txt\" target=\"_blank\" rel=\"noopener noreferrer\">GitHub repository<\/a> or click the figure below to see the raw file, and copy the code provided.<\/p>\n<p><a href=\"https:\/\/raw.githubusercontent.com\/RuiSantosdotme\/Car-Plate-Recognition-System-with-Raspberry-Pi-and-Node-RED\/master\/node_red_identify_car_plate_and_model.txt\" target=\"_blank\" rel=\"noopener noreferrer\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60857\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-simple.png?resize=990%2C90&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"990\" height=\"90\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-simple.png?w=990&amp;quality=100&amp;strip=all&amp;ssl=1 990w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-simple.png?resize=300%2C27&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-simple.png?resize=768%2C70&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-simple.png?resize=975%2C90&amp;quality=100&amp;strip=all&amp;ssl=1 975w\" sizes=\"(max-width: 990px) 100vw, 990px\" \/><\/a><\/p>\n<p>Next, in the Node-RED window, at the top right corner, select the menu, and go to <strong>Import<\/strong> &gt; <strong>Clipboard<\/strong>.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-45987\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/11\/import-nodes.png?resize=523%2C291&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"523\" height=\"291\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/11\/import-nodes.png?w=523&amp;quality=100&amp;strip=all&amp;ssl=1 523w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/11\/import-nodes.png?resize=300%2C167&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 523px) 100vw, 523px\" \/><\/p>\n<p>Then, paste the code provided and click <strong>Import<\/strong>. The next nodes should show up in your flow:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60849\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2.png?resize=815%2C61&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"815\" height=\"61\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2.png?w=815&amp;quality=100&amp;strip=all&amp;ssl=1 815w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2.png?resize=300%2C22&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2.png?resize=768%2C57&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 815px) 100vw, 815px\" \/><\/p>\n<h3>Configuring the test flow<\/h3>\n<p>After importing the flow, you need to make some changes to make it work for you. Open the <strong>Take Photo<\/strong> node:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60850\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2_1.png?resize=815%2C66&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"815\" height=\"66\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2_1.png?w=815&amp;quality=100&amp;strip=all&amp;ssl=1 815w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2_1.png?resize=300%2C24&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2_1.png?resize=768%2C62&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 815px) 100vw, 815px\" \/><\/p>\n<p>Edit the node to have the same settings as shown in the next figure:<\/p>\n<ul>\n<li><strong>File Name<\/strong>: car-photo.jpeg<\/li>\n<li><strong>File default path<\/strong>: No<\/li>\n<li><strong>File Path<\/strong>: \/home\/pi\/Pictures\/<\/li>\n<\/ul>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-60843 aligncenter\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/camera-node.png?resize=489%2C741&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"489\" height=\"741\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/camera-node.png?w=489&amp;quality=100&amp;strip=all&amp;ssl=1 489w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/camera-node.png?resize=198%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 198w\" sizes=\"(max-width: 489px) 100vw, 489px\" \/><\/p>\n<p><span style=\"color: #ff0000;\"><strong>Important:<\/strong><\/span>\u00a0sometimes the previous node might overwrite the default setting. Make sure you double-check that it has the right settings. Then, click the deploy button.<\/p>\n<h3>Preparing your OpenALPR Cloud API request<\/h3>\n<p>Double-click the <strong>cURL POST<\/strong> node:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60851\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2_2.png?resize=815%2C65&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"815\" height=\"65\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2_2.png?w=815&amp;quality=100&amp;strip=all&amp;ssl=1 815w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2_2.png?resize=300%2C24&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2_2.png?resize=768%2C61&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 815px) 100vw, 815px\" \/><\/p>\n<p>Then, change the <strong>Command<\/strong> field to include your Secret Key and country code:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60841\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-post.png?resize=657%2C432&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"657\" height=\"432\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-post.png?w=657&amp;quality=100&amp;strip=all&amp;ssl=1 657w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-post.png?resize=300%2C197&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 657px) 100vw, 657px\" \/><\/p>\n<p>By default, it should have this command:<\/p>\n<pre>sudo curl -X POST \"https:\/\/api.openalpr.com\/v2\/recognize?secret_key=<span style=\"color: #ff0000;\"><strong>YOUR_SECRET_KEY<\/strong><\/span>&amp;recognize_vehicle=1&amp;country=<strong><span style=\"color: #ff0000;\">YOUR_COUNTRY_CODE<\/span><\/strong>&amp;return_image=0&amp;topn=10\" -F image=@\/home\/pi\/Pictures\/car-photo.jpeg<\/pre>\n<p>Add your secret key that you&#8217;ve retrieved earlier and your country code:<\/p>\n<pre>sudo curl -X POST \"https:\/\/api.openalpr.com\/v2\/recognize?secret_key=<span style=\"color: #ff0000;\"><strong>sk_8081041caedd50a---------<\/strong><\/span>&amp;recognize_vehicle=1&amp;country=<strong><span style=\"color: #ff0000;\">eu<\/span><\/strong>&amp;return_image=0&amp;topn=10\" -F image=@\/home\/pi\/Pictures\/car-photo.jpeg<\/pre>\n<p><strong><span style=\"color: #ff0000;\">Note:<\/span> <\/strong>EU is not a country, but if you live in any country in Europe, you use the EU country code.<\/p>\n<p>Copy and paste your exact command in the in the <strong>Command<\/strong> field of the cURL POST node and press the <strong>Deploy<\/strong> button in your Node-RED software for all the changes to take effect:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-40013\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/06\/11_deploy_button.png?resize=138%2C40&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"138\" height=\"40\" \/><\/p>\n<h3>Testing the flow<\/h3>\n<p>After deploying the flow, let&#8217;s test the car identification process. Move your car to a place that you can take a photo with your Raspberry Pi:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60907\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/car-photo-f.jpg?resize=800%2C331&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"800\" height=\"331\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/car-photo-f.jpg?w=800&amp;quality=100&amp;strip=all&amp;ssl=1 800w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/car-photo-f.jpg?resize=300%2C124&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/car-photo-f.jpg?resize=768%2C318&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>Point the camera to the car and tap the square next to the timestamp node to trigger the flow.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60852\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2_3.png?resize=841%2C55&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"841\" height=\"55\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2_3.png?w=841&amp;quality=100&amp;strip=all&amp;ssl=1 841w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2_3.png?resize=300%2C20&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow2_3.png?resize=768%2C50&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 841px) 100vw, 841px\" \/><\/p>\n<p>That should take a photo with your Pi Camera, save it at\u00a0<em>\/home\/pi\/Pictures\/car-photo.jpeg<\/em> and make a request to the cloud API to identify your car plate and model. It should print the JSON response in the <strong>Debug<\/strong> window.<\/p>\n<h3>Understanding the response<\/h3>\n<p>Open the <strong>debug<\/strong> window, and you should see an object with all the details about the JSON response. The results array should have at least one result (<strong>array[1]<\/strong>), otherwise it might be analyzing a photo without a car or it couldn&#8217;t identify the car (make sure the Pi Camera is pointed to the car while you take the photo).<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60908\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/debug.png?resize=351%2C419&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"351\" height=\"419\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/debug.png?w=351&amp;quality=100&amp;strip=all&amp;ssl=1 351w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/debug.png?resize=251%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 251w\" sizes=\"(max-width: 351px) 100vw, 351px\" \/><\/p>\n<p>Click the arrow next to the <strong>results: array[1]<\/strong> to expand the object. You should see a plate object with your car plate. Save the car plate in the format retrieved by the API. In my case it&#8217;s &#8220;61CP&#8211;&#8220;. You&#8217;ll need it later to identify your car:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60909\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/debug2.png?resize=352%2C701&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"352\" height=\"701\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/debug2.png?w=352&amp;quality=100&amp;strip=all&amp;ssl=1 352w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/debug2.png?resize=151%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 151w\" sizes=\"(max-width: 352px) 100vw, 352px\" \/><\/p>\n<p>Expand the <strong>vehicle<\/strong> object &gt; <strong>make_model<\/strong> &gt;<strong> 0: object<\/strong> and you should see the name of your car and how the API identified the car model. In our case it identified the car as a Toyota Yaris with 77,2% confidence. We should save the exact string &#8220;toyota_yaris&#8221; retrieved by the API, because we need it for the next flow. Save your car model in the format retrieved by the API.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60910\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/debug3.png?resize=316%2C614&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"316\" height=\"614\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/debug3.png?w=316&amp;quality=100&amp;strip=all&amp;ssl=1 316w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/debug3.png?resize=154%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 154w\" sizes=\"(max-width: 316px) 100vw, 316px\" \/><\/p>\n<h3>Troubleshooting tips<\/h3>\n<p>In case your response returned invalid results, make sure you double check the following details:<\/p>\n<ul>\n<li>The<strong> Take Photo<\/strong> node is storing the photo in the right file path:\u00a0<em>\/home\/pi\/Pictures\/<\/em><\/li>\n<li>Make sure the camera is taking good photos (access the Raspberry Pi Pictures folder at <em>\/home\/pi\/Pictures\/car-photo.jpeg<\/em> to see if the photo taken looks good)<\/li>\n<li>See if the photo has the car visible and the car plate, otherwise the API might not be able to identify the car properly<\/li>\n<li>Make sure you&#8217;ve entered the right command with your own API key and country code in the <strong>cURL POST<\/strong> command<\/li>\n<\/ul>\n<h2>Car Plate Recognition System Flow<\/h2>\n<p>In this part, we&#8217;ll add the car detection and event triggering to our flow. When motion is detected, the Pi camera takes a photo\u00a0with the Pi Camera and makes a request to OpenALPR. Then, based on the response, it will trigger an event (in this case we&#8217;ll set an output on to light up an LED).<\/p>\n<p>To import the Node-RED flow provided, go to the <a href=\"https:\/\/raw.githubusercontent.com\/RuiSantosdotme\/Car-Plate-Recognition-System-with-Raspberry-Pi-and-Node-RED\/master\/node_red_identify_car_plate_and_trigger_event.txt\" target=\"_blank\" rel=\"noopener noreferrer\">GitHub repository<\/a> or click the figure below to see the raw file, and copy the code provided.<\/p>\n<p><a href=\"https:\/\/raw.githubusercontent.com\/RuiSantosdotme\/Car-Plate-Recognition-System-with-Raspberry-Pi-and-Node-RED\/master\/node_red_identify_car_plate_and_trigger_event.txt\" target=\"_blank\" rel=\"noopener noreferrer\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60856\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-final.png?resize=990%2C89&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"990\" height=\"89\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-final.png?w=990&amp;quality=100&amp;strip=all&amp;ssl=1 990w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-final.png?resize=300%2C27&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-final.png?resize=768%2C69&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-final.png?resize=975%2C89&amp;quality=100&amp;strip=all&amp;ssl=1 975w\" sizes=\"(max-width: 990px) 100vw, 990px\" \/><\/a><\/p>\n<p>Next, in the Node-RED window, at the top right corner, select the menu, and go to <strong>Import<\/strong> &gt; <strong>Clipboard<\/strong>.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-45987\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/11\/import-nodes.png?resize=523%2C291&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"523\" height=\"291\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/11\/import-nodes.png?w=523&amp;quality=100&amp;strip=all&amp;ssl=1 523w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/11\/import-nodes.png?resize=300%2C167&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 523px) 100vw, 523px\" \/><\/p>\n<p>Then, paste the code provided and click <strong>Import<\/strong>. The next nodes should load in your flow:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-60845 size-full\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow.png?resize=1072%2C327&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"1072\" height=\"327\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow.png?w=1072&amp;quality=100&amp;strip=all&amp;ssl=1 1072w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow.png?resize=300%2C92&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow.png?resize=768%2C234&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow.png?resize=1024%2C312&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1072px) 100vw, 1072px\" \/><\/a><\/p>\n<h3>Configuring the flow<\/h3>\n<p>After importing the flow, you need to make some changes to make it work for you. Open the <strong>Take Photo<\/strong> node:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_2.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-60846 size-full\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_2.png?resize=1072%2C327&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"1072\" height=\"327\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_2.png?w=1072&amp;quality=100&amp;strip=all&amp;ssl=1 1072w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_2.png?resize=300%2C92&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_2.png?resize=768%2C234&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_2.png?resize=1024%2C312&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1072px) 100vw, 1072px\" \/><\/a><\/p>\n<p>Edit the node to have the same settings as shown in the next figure:<\/p>\n<ul>\n<li><strong>File Name<\/strong>: car-photo.jpeg<\/li>\n<li><strong>File default path<\/strong>: No<\/li>\n<li><strong>File Path<\/strong>: \/home\/pi\/Pictures\/<\/li>\n<\/ul>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60843\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/camera-node.png?resize=489%2C741&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"489\" height=\"741\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/camera-node.png?w=489&amp;quality=100&amp;strip=all&amp;ssl=1 489w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/camera-node.png?resize=198%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 198w\" sizes=\"(max-width: 489px) 100vw, 489px\" \/><\/p>\n<h3>Preparing your OpenALPR Cloud API request<\/h3>\n<p>Double-click the <strong>cURL POST<\/strong> node:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_3.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-60847 size-full\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_3.png?resize=1072%2C327&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"1072\" height=\"327\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_3.png?w=1072&amp;quality=100&amp;strip=all&amp;ssl=1 1072w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_3.png?resize=300%2C92&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_3.png?resize=768%2C234&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_3.png?resize=1024%2C312&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1072px) 100vw, 1072px\" \/><\/a><\/p>\n<p>Then, change the <strong>Command<\/strong> field to include your Secret Key and country code:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60841\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-post.png?resize=657%2C432&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"657\" height=\"432\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-post.png?w=657&amp;quality=100&amp;strip=all&amp;ssl=1 657w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/node-red-post.png?resize=300%2C197&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 657px) 100vw, 657px\" \/><\/p>\n<p>By default, it should have this command:<\/p>\n<pre>sudo curl -X POST \"https:\/\/api.openalpr.com\/v2\/recognize?secret_key=<span style=\"color: #ff0000;\"><strong>YOUR_SECRET_KEY<\/strong><\/span>&amp;recognize_vehicle=1&amp;country=<strong><span style=\"color: #ff0000;\">YOUR_COUNTRY_CODE<\/span><\/strong>&amp;return_image=0&amp;topn=10\" -F image=@\/home\/pi\/Pictures\/car-photo.jpeg<\/pre>\n<p>Add your secret key that you&#8217;ve retrieved earlier and your country code:<\/p>\n<pre>sudo curl -X POST \"https:\/\/api.openalpr.com\/v2\/recognize?secret_key=<span style=\"color: #ff0000;\"><strong>sk_8081041caedd50a---------<\/strong><\/span>&amp;recognize_vehicle=1&amp;country=<strong><span style=\"color: #ff0000;\">eu<\/span><\/strong>&amp;return_image=0&amp;topn=10\" -F image=@\/home\/pi\/Pic<\/pre>\n<h3>Add your car details to the flow<\/h3>\n<p>Open the function node <strong>Identify Car<\/strong> to add your car&#8217;s license plate and model.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_4.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-60848 size-full\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_4.png?resize=1072%2C327&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"1072\" height=\"327\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_4.png?w=1072&amp;quality=100&amp;strip=all&amp;ssl=1 1072w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_4.png?resize=300%2C92&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_4.png?resize=768%2C234&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/flow_4.png?resize=1024%2C312&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1072px) 100vw, 1072px\" \/><\/a><\/p>\n<p>You need to replace the <strong>carPlate<\/strong> and <strong>carModel<\/strong> variables with your own car plate and model name (in the exact same format as retrieved earlier). In our case, we get:<\/p>\n<pre>var carPlate = \"<strong>61CP--<\/strong>\";\nvar carModel = \"<strong>toyota_yaris<\/strong>\";<\/pre>\n<p>The following figure shows the place where you should add your car plate and model on the function node:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60840\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/function-node.png?resize=487%2C552&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"487\" height=\"552\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/function-node.png?w=487&amp;quality=100&amp;strip=all&amp;ssl=1 487w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/function-node.png?resize=265%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 265w\" sizes=\"(max-width: 487px) 100vw, 487px\" \/><\/p>\n<p><strong>Note:<\/strong> if you want to add another car plate, you need to edit the &#8220;Identify Car&#8221; function. Declare another <em>carPlate2<\/em> and <em>carModel2<\/em>:<\/p>\n<pre>var carPlate2 = \" \";\nvar carModel2= \" \";<\/pre>\n<p>Then, after the else if statement, add the following:<\/p>\n<pre>else if(msg.payload.results[0].plate==carPlate2 &amp;&amp; msg.payload.results[0].vehicle.make_model[0].name==carModel2){\n  msg.payload=1;\n  global.set(\"garageOpen\",\"1\");\n}<\/pre>\n<p>That should allow you to verify two cars (you can add more).<\/p>\n<p>Once you&#8217;ve added your car details, press <strong>Done<\/strong> and click the\u00a0<strong>Deploy<\/strong> button:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-40013\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/06\/11_deploy_button.png?resize=138%2C40&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"138\" height=\"40\" \/><\/p>\n<h2>Demonstration<\/h2>\n<p>Now, when the car arrives, the PIR sensor detects motion, the Pi Camera takes a photo, and the car is identified using the OpenALPR API.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter size-full wp-image-60920\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/project-overview-1.jpg?resize=1057%2C197&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"1057\" height=\"197\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/project-overview-1.jpg?w=1057&amp;quality=100&amp;strip=all&amp;ssl=1 1057w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/project-overview-1.jpg?resize=300%2C56&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/project-overview-1.jpg?resize=768%2C143&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/project-overview-1.jpg?resize=1024%2C191&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1057px) 100vw, 1057px\" \/><\/p>\n<p>Your Node-RED should identify your car plate and car model. Then, it will trigger an event: it turns GPIO 17 on for a few seconds and then it turns off. This simulates the open\/close garage door command.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-60917\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/car-photo-demo.jpg?resize=955%2C720&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"955\" height=\"720\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/car-photo-demo.jpg?w=955&amp;quality=100&amp;strip=all&amp;ssl=1 955w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/car-photo-demo.jpg?resize=300%2C226&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/car-photo-demo.jpg?resize=768%2C579&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 955px) 100vw, 955px\" \/><\/p>\n<h2>Wrapping Up<\/h2>\n<p>In this project we&#8217;ve shown you how to identify car plates using OpenALPR. We also show you how you can trigger an event based on a specific car plate. This way, you can automatically open your garage when you arrive with your car. You can modify this project to make it work for you and use it in your own home automation system.<\/p>\n<p>In the example we&#8217;ve shown, we&#8217;ve used a PIR motion sensor to detect the car arriving. There are other sensors that might be better for this case like: ultrasonic sensor, active infrared sensor, or hall effect sensor, for example.<\/p>\n<p>When we trigger the event, we wait 10 seconds until &#8220;closing the garage&#8221;. You need to add several verification processes (that we did not include in the flow) to check if the car has entered the garage or not.<\/p>\n<p>We hope you&#8217;ve found this project interesting. If you like this project, you may also like:<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/randomnerdtutorials.com\/20-easy-raspberry-pi-projects-book\/\">20 Easy Raspberry Pi Projects Book<\/a><\/strong><\/li>\n<li><a href=\"https:\/\/randomnerdtutorials.com\/getting-started-with-node-red-dashboard\/\" target=\"_blank\" rel=\"noopener noreferrer\">Getting Started with Node-RED Dashboard on Raspberry Pi<\/a><\/li>\n<li><a href=\"https:\/\/randomnerdtutorials.com\/build-a-home-automation-system-for-100\/\" target=\"_blank\" rel=\"noopener noreferrer\">Build a Home Automation System with Node-RED, RPi, and ESP8266<\/a><\/li>\n<\/ul>\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this project you&#8217;re going to learn how to build a car recognition system using a Raspberry Pi and Node-RED. For this project we&#8217;ll be using a software called OpenALPR &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Car Plate Recognition System with Raspberry Pi and Node-RED\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/car-plate-recognition-system-with-raspberry-pi-and-node-red\/#more-60788\" aria-label=\"Read more about Car Plate Recognition System with Raspberry Pi and Node-RED\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":60919,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[301,273,264,268,190,192],"tags":[],"class_list":["post-60788","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-0-raspberrypi","category-node-red","category-project","category-raspberry-pi-project","category-raspberry-pi","category-r-tutorials"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/identify-car-thumbnail.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/60788","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=60788"}],"version-history":[{"count":0,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/60788\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/60919"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=60788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=60788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=60788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}