Raspberry Pi Traffic Light Using TensorFlow & Python
Raspberry Pi Traffic Light Uses TensorFlow & Python to check how many people are waiting and how long they are waiting at zebra crossing.
- Suitable forB.Tech Embedded students
- Build time3-4 weeks
- LevelBeginner
- Available atAjvika Labs, Kakinada
About this project
In metropolitan cities traffic jams are one of the major problems and for the common man and he who use to travel on their legs is one of the major problems. Many time it is seen the people are waiting at crossing to get the traffic clear and the people have to wait and keep standing for an hours to cross the road it become more complicated when any child and old women have to wait for long time to cross the road so today we are going to Raspberry Pi TrafficLight Using TensorFlow & Python that checks how many people are waiting at zebra crossing and from how long they are waiting at zebra crossing and give priority to people rather than vehicles accordingly.
First a camera streams the live video at zebra crossing
Then that video is cut in certain frames and a tensorflow with computer vision modules checks the number of people and time from which they are waiting to cross the
If the system get that the number of people is greater than the 3(can be changed ) waiting at zebra crossing then it give priority to them. If the number of people at zebra crossing is below 3 but waiting for more than 60 seconds (can be changed) then it give priority to them in crossing.
So let’s start our project with some of required components
Assuming that you have already Raspbian os installed and with Python3 environment on raspberry pi and also have access to its desktop.
Then change the line CONF_SWAPSIZE = 100 to CONF_SWAPSIZE = 1024
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start
wget https://bootstrap.pypa.io/get-pip.py
After the installation you can now proceed with the cloning of TF modules, examples, and files using the following command:
git clone https://github.com/tensorflow/tensorflow.git
After successfully cloning, go to the directory → research folder → and paste the code attached with the article. Now open the python3 IDE.Now let’s understand and change the code. First we have import the required modules in code and these modules are:
Next we will set the path for tensor flow detection modules and the we will set the name and path for labels here we have using the “trafficlight.pbtxt”. Next part of code will check the camera video and cut it in various frames and after that we have code that will try to detect the objects in each frame and then map with the labels that is assigned in traffic.pbtxt . here in traffic.pbtxt have only two labels that is “person” and “bicycle”( you can exclude the bicycle )
Now in next part of the code we check the label of object detected and here we have set a substring ie “person” we use this substring to count the number of people in image.
Now we have created several if() conditional statement that checks weather number of people detected is greater than 0 . Next if () statement will check count number is greater than 3 if yes then it turns the redlight on to stop vehicles and let the people pass . if number of people waiting at crossing is less than 3 then it start counting the time and if the time exceeds the 60 min then it give priority to people and let them pass.
Now connect the RPI camera to RPI Camera port using ribbon cable and then connect the components as in diagram(Refer fig 8).
Now save the code and run the code in python3 IDE and wait for few minutes to load the TF modules and let the camera video window to appear and then bring the camera in front of many people if it detects the number of people detected is greater than 3 then it turn on red LED for stop sign. If people detected is less than 3 than wait for 60 second if the same people is wait for more than 60 seconds then it will let them pass and stop the vehicles by turning the red light on.
Congrats, Raspberry Pi TrafficLight Using TensorFlow is ready!!
Shahid Hasri October 29, 2020 At 4:56 am “After successfully cloning, go to the directory → research folder → and paste the code attached with the article”.. Hellow :), what is mean by this? i cannot understand clearly.. Really hope you can help me. Log in to leave a comment Ashwini Sinha October 29, 2020 At 10:53 am You have to clone the TensorFlow GitHub respiratory using git clone followed by a link so that the pre-trained models and essential files copied to your raspberry pi automatically. After performing this process you can see a Tensorflow folder in raspberry pi. Now open that and then follow the steps as described in the article Log in to leave a comment MUHAMMAD ABDUL SHAHID BIN HASRI . November 9, 2020 At 9:15 pm Can i have your telegram number? maybe we can setup a google meet or any medium to teach me about above project. Log in to leave a comment
“After successfully cloning, go to the directory → research folder → and paste the code attached with the article”..
Hellow :), what is mean by this? i cannot understand clearly.. Really hope you can help me.
Ashwini Sinha October 29, 2020 At 10:53 am You have to clone the TensorFlow GitHub respiratory using git clone followed by a link so that the pre-trained models and essential files copied to your raspberry pi automatically. After performing this process you can see a Tensorflow folder in raspberry pi. Now open that and then follow the steps as described in the article Log in to leave a comment MUHAMMAD ABDUL SHAHID BIN HASRI . November 9, 2020 At 9:15 pm Can i have your telegram number? maybe we can setup a google meet or any medium to teach me about above project. Log in to leave a comment
You have to clone the TensorFlow GitHub respiratory using git clone followed by a link so that the pre-trained models and essential files copied to your raspberry pi automatically. After performing this process you can see a Tensorflow folder in raspberry pi. Now open that and then follow the steps as described in the article
MUHAMMAD ABDUL SHAHID BIN HASRI . November 9, 2020 At 9:15 pm Can i have your telegram number? maybe we can setup a google meet or any medium to teach me about above project. Log in to leave a comment
Can i have your telegram number? maybe we can setup a google meet or any medium to teach me about above project.
Samuel Vieira November 8, 2020 At 6:31 pm Hello, i’ve been trying to “sudo pip3 install opencv” but I’m not able to because of this error Looking in indexes: https://pypi.org/simple , https://www.piwheels.org/simple Collecting opencv Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/opencv/ Can you help me? Log in to leave a comment
Hello, i’ve been trying to “sudo pip3 install opencv” but I’m not able to because of this error
Looking in indexes: https://pypi.org/simple , https://www.piwheels.org/simple Collecting opencv Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/opencv/
Samuel Vieira November 8, 2020 At 6:44 pm Hello, I have been some trouble going through with this project. When I try “sudo pip3 install opencv” I get the next error. Looking in indexes: https://pypi.org/simple , https://www.piwheels.org/simple Collecting opencv Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/opencv/ I hope you can help me. Log in to leave a comment Ashwini Sinha November 9, 2020 At 11:19 am Have you connected the RPI to the internet, then check the python3 IDLE environment installed then try to install it.if still got any error try this sudo apt-get install python3-opencv Log in to leave a comment Ashwini Sinha November 11, 2020 At 10:10 am you can ask doubts here in the comments. For more help needed you can whats me at 7061350809 Log in to leave a comment
Hello, I have been some trouble going through with this project. When I try “sudo pip3 install opencv” I get the next error. Looking in indexes: https://pypi.org/simple , https://www.piwheels.org/simple Collecting opencv Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/opencv/ I hope you can help me.
Ashwini Sinha November 9, 2020 At 11:19 am Have you connected the RPI to the internet, then check the python3 IDLE environment installed then try to install it.if still got any error try this sudo apt-get install python3-opencv Log in to leave a comment Ashwini Sinha November 11, 2020 At 10:10 am you can ask doubts here in the comments. For more help needed you can whats me at 7061350809 Log in to leave a comment
Have you connected the RPI to the internet, then check the python3 IDLE environment installed then try to install it.if still got any error try this sudo apt-get install python3-opencv
Ashwini Sinha November 11, 2020 At 10:10 am you can ask doubts here in the comments. For more help needed you can whats me at 7061350809 Log in to leave a comment
you can ask doubts here in the comments. For more help needed you can whats me at 7061350809
Abdul December 11, 2020 At 5:56 am Hello good morning, may i know the link where you download your pi os? Log in to leave a comment Ashwini Sinha December 11, 2020 At 10:24 am I have attached Voice bonnet on Rpi so installed it with AIY Voice Raspbian os for pi. You can download the official latest OS for raspberry pi from the raspberry pi official website, you can find the os image in the download section Log in to leave a comment
Hello good morning, may i know the link where you download your pi os?
Ashwini Sinha December 11, 2020 At 10:24 am I have attached Voice bonnet on Rpi so installed it with AIY Voice Raspbian os for pi. You can download the official latest OS for raspberry pi from the raspberry pi official website, you can find the os image in the download section Log in to leave a comment
I have attached Voice bonnet on Rpi so installed it with AIY Voice Raspbian os for pi. You can download the official latest OS for raspberry pi from the raspberry pi official website, you can find the os image in the download section
Muhammad December 26, 2020 At 8:19 am Hello sir, can I get your email or any medium that I can contact you? almost 6 times I try to run the following code, but still got some errors.. really hope that you can help me.. Btw really nice project sir?. Log in to leave a comment
Hello sir, can I get your email or any medium that I can contact you? almost 6 times I try to run the following code, but still got some errors.. really hope that you can help me.. Btw really nice project sir?.
Muhammad December 26, 2020 At 8:25 am Hello sir, can I get your email or any medium to contact you sir? About 6 times I try to run the given code and follow all the step given, but still got some errors.. I really hope that you can help me sir.. Btw really nice project sir ? Log in to leave a comment Ashwini Sinha December 28, 2020 At 10:53 am what error are you facing? copy error and send me on comments section I will try to guide you Log in to leave a comment Ashwini Sinha December 28, 2020 At 6:20 pm Please send me details of error or contact me on what’s app 7061350809 Log in to leave a comment
Hello sir, can I get your email or any medium to contact you sir? About 6 times I try to run the given code and follow all the step given, but still got some errors.. I really hope that you can help me sir.. Btw really nice project sir ?
Ashwini Sinha December 28, 2020 At 10:53 am what error are you facing? copy error and send me on comments section I will try to guide you Log in to leave a comment
what error are you facing? copy error and send me on comments section I will try to guide you
Ashwini Sinha December 28, 2020 At 6:20 pm Please send me details of error or contact me on what’s app 7061350809 Log in to leave a comment
Please send me details of error or contact me on what’s app 7061350809
SHARE YOUR THOUGHTS & COMMENTS Register or Login to leave a comment.
Smart Speed Monitoring System For Road Safety
Real-Time Face Tracking Using Raspberry Pi 4 Versus Raspberry Pi 5 With Hailo-8L
High-Voltage Capacitor Discharger
Real-time Web-based Home Automation
World’s Smallest Open-Source LoRa + GPS Module for Wearables and IoT (Only 3cm!)
Smallest Spy Video Streaming Camera
Wirelessly Control Multiple AC Appliances with Web Interface
Ultra-Low-Loss Isolated Current Sensor
STMicroelectronics has Introduced First Automotive Microcontroller With built-in AI Acceleration
Samsung Launched 200MP Image Sensor Called ISOCELL HP5
Aeva Introduced 4D LiDAR Sensor for Physical AI Systems
First a camera streams the live video at zebra crossing
Then that video is cut in certain frames and a tensorflow with computer vision modules checks the number of people and time from which they are waiting to cross the
If the system get that the number of people is greater than the 3(can be changed ) waiting at zebra crossing then it give priority to them. If the number of people at zebra crossing is below 3 but waiting for more than 60 seconds (can be changed) then it give priority to them in crossing.
So let’s start our project with some of required components
Assuming that you have already Raspbian os installed and with Python3 environment on raspberry pi and also have access to its desktop.
Then change the line CONF_SWAPSIZE = 100 to CONF_SWAPSIZE = 1024
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start
wget https://bootstrap.pypa.io/get-pip.py
After the installation you can now proceed with the cloning of TF modules, examples, and files using the following command:
git clone https://github.com/tensorflow/tensorflow.git
After successfully cloning, go to the directory → research folder → and paste the code attached with the article. Now open the python3 IDE.Now let’s understand and change the code. First we have import the required modules in code and these modules are:
Next we will set the path for tensor flow detection modules and the we will set the name and path for labels here we have using the “trafficlight.pbtxt”. Next part of code will check the camera video and cut it in various frames and after that we have code that will try to detect the objects in each frame and then map with the labels that is assigned in traffic.pbtxt . here in traffic.pbtxt have only two labels that is “person” and “bicycle”( you can exclude the bicycle )
Now in next part of the code we check the label of object detected and here we have set a substring ie “person” we use this substring to count the number of people in image.
Now we have created several if() conditional statement that checks weather number of people detected is greater than 0 . Next if () statement will check count number is greater than 3 if yes then it turns the redlight on to stop vehicles and let the people pass . if number of people waiting at crossing is less than 3 then it start counting the time and if the time exceeds the 60 min then it give priority to people and let them pass.
Now connect the RPI camera to RPI Camera port using ribbon cable and then connect the components as in diagram(Refer fig 8).
Now save the code and run the code in python3 IDE and wait for few minutes to load the TF modules and let the camera video window to appear and then bring the camera in front of many people if it detects the number of people detected is greater than 3 then it turn on red LED for stop sign. If people detected is less than 3 than wait for 60 second if the same people is wait for more than 60 seconds then it will let them pass and stop the vehicles by turning the red light on.
Congrats, Raspberry Pi TrafficLight Using TensorFlow is ready!!
Shahid Hasri October 29, 2020 At 4:56 am “After successfully cloning, go to the directory → research folder → and paste the code attached with the article”.. Hellow :), what is mean by this? i cannot understand clearly.. Really hope you can help me. Log in to leave a comment Ashwini Sinha October 29, 2020 At 10:53 am You have to clone the TensorFlow GitHub respiratory using git clone followed by a link so that the pre-trained models and essential files copied to your raspberry pi automatically. After performing this process you can see a Tensorflow folder in raspberry pi. Now open that and then follow the steps as described in the article Log in to leave a comment MUHAMMAD ABDUL SHAHID BIN HASRI . November 9, 2020 At 9:15 pm Can i have your telegram number? maybe we can setup a google meet or any medium to teach me about above project. Log in to leave a comment
“After successfully cloning, go to the directory → research folder → and paste the code attached with the article”..
Hellow :), what is mean by this? i cannot understand clearly.. Really hope you can help me.
Ashwini Sinha October 29, 2020 At 10:53 am You have to clone the TensorFlow GitHub respiratory using git clone followed by a link so that the pre-trained models and essential files copied to your raspberry pi automatically. After performing this process you can see a Tensorflow folder in raspberry pi. Now open that and then follow the steps as described in the article Log in to leave a comment MUHAMMAD ABDUL SHAHID BIN HASRI . November 9, 2020 At 9:15 pm Can i have your telegram number? maybe we can setup a google meet or any medium to teach me about above project. Log in to leave a comment
You have to clone the TensorFlow GitHub respiratory using git clone followed by a link so that the pre-trained models and essential files copied to your raspberry pi automatically. After performing this process you can see a Tensorflow folder in raspberry pi. Now open that and then follow the steps as described in the article
MUHAMMAD ABDUL SHAHID BIN HASRI . November 9, 2020 At 9:15 pm Can i have your telegram number? maybe we can setup a google meet or any medium to teach me about above project. Log in to leave a comment
Can i have your telegram number? maybe we can setup a google meet or any medium to teach me about above project.
Samuel Vieira November 8, 2020 At 6:31 pm Hello, i’ve been trying to “sudo pip3 install opencv” but I’m not able to because of this error Looking in indexes: https://pypi.org/simple , https://www.piwheels.org/simple Collecting opencv Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/opencv/ Can you help me? Log in to leave a comment
Hello, i’ve been trying to “sudo pip3 install opencv” but I’m not able to because of this error
Looking in indexes: https://pypi.org/simple , https://www.piwheels.org/simple Collecting opencv Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/opencv/
Samuel Vieira November 8, 2020 At 6:44 pm Hello, I have been some trouble going through with this project. When I try “sudo pip3 install opencv” I get the next error. Looking in indexes: https://pypi.org/simple , https://www.piwheels.org/simple Collecting opencv Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/opencv/ I hope you can help me. Log in to leave a comment Ashwini Sinha November 9, 2020 At 11:19 am Have you connected the RPI to the internet, then check the python3 IDLE environment installed then try to install it.if still got any error try this sudo apt-get install python3-opencv Log in to leave a comment Ashwini Sinha November 11, 2020 At 10:10 am you can ask doubts here in the comments. For more help needed you can whats me at 7061350809 Log in to leave a comment
Hello, I have been some trouble going through with this project. When I try “sudo pip3 install opencv” I get the next error. Looking in indexes: https://pypi.org/simple , https://www.piwheels.org/simple Collecting opencv Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/opencv/ I hope you can help me.
Ashwini Sinha November 9, 2020 At 11:19 am Have you connected the RPI to the internet, then check the python3 IDLE environment installed then try to install it.if still got any error try this sudo apt-get install python3-opencv Log in to leave a comment Ashwini Sinha November 11, 2020 At 10:10 am you can ask doubts here in the comments. For more help needed you can whats me at 7061350809 Log in to leave a comment
Have you connected the RPI to the internet, then check the python3 IDLE environment installed then try to install it.if still got any error try this sudo apt-get install python3-opencv
Ashwini Sinha November 11, 2020 At 10:10 am you can ask doubts here in the comments. For more help needed you can whats me at 7061350809 Log in to leave a comment
you can ask doubts here in the comments. For more help needed you can whats me at 7061350809
Abdul December 11, 2020 At 5:56 am Hello good morning, may i know the link where you download your pi os? Log in to leave a comment Ashwini Sinha December 11, 2020 At 10:24 am I have attached Voice bonnet on Rpi so installed it with AIY Voice Raspbian os for pi. You can download the official latest OS for raspberry pi from the raspberry pi official website, you can find the os image in the download section Log in to leave a comment
Hello good morning, may i know the link where you download your pi os?
Ashwini Sinha December 11, 2020 At 10:24 am I have attached Voice bonnet on Rpi so installed it with AIY Voice Raspbian os for pi. You can download the official latest OS for raspberry pi from the raspberry pi official website, you can find the os image in the download section Log in to leave a comment
I have attached Voice bonnet on Rpi so installed it with AIY Voice Raspbian os for pi. You can download the official latest OS for raspberry pi from the raspberry pi official website, you can find the os image in the download section
Muhammad December 26, 2020 At 8:19 am Hello sir, can I get your email or any medium that I can contact you? almost 6 times I try to run the following code, but still got some errors.. really hope that you can help me.. Btw really nice project sir?. Log in to leave a comment
Hello sir, can I get your email or any medium that I can contact you? almost 6 times I try to run the following code, but still got some errors.. really hope that you can help me.. Btw really nice project sir?.
Muhammad December 26, 2020 At 8:25 am Hello sir, can I get your email or any medium to contact you sir? About 6 times I try to run the given code and follow all the step given, but still got some errors.. I really hope that you can help me sir.. Btw really nice project sir ? Log in to leave a comment Ashwini Sinha December 28, 2020 At 10:53 am what error are you facing? copy error and send me on comments section I will try to guide you Log in to leave a comment Ashwini Sinha December 28, 2020 At 6:20 pm Please send me details of error or contact me on what’s app 7061350809 Log in to leave a comment
Hello sir, can I get your email or any medium to contact you sir? About 6 times I try to run the given code and follow all the step given, but still got some errors.. I really hope that you can help me sir.. Btw really nice project sir ?
Ashwini Sinha December 28, 2020 At 10:53 am what error are you facing? copy error and send me on comments section I will try to guide you Log in to leave a comment
what error are you facing? copy error and send me on comments section I will try to guide you
Ashwini Sinha December 28, 2020 At 6:20 pm Please send me details of error or contact me on what’s app 7061350809 Log in to leave a comment
Please send me details of error or contact me on what’s app 7061350809
SHARE YOUR THOUGHTS & COMMENTS Register or Login to leave a comment.
Smart Speed Monitoring System For Road Safety
Real-Time Face Tracking Using Raspberry Pi 4 Versus Raspberry Pi 5 With Hailo-8L
High-Voltage Capacitor Discharger
Real-time Web-based Home Automation
World’s Smallest Open-Source LoRa + GPS Module for Wearables and IoT (Only 3cm!)
Smallest Spy Video Streaming Camera
Wirelessly Control Multiple AC Appliances with Web Interface
Ultra-Low-Loss Isolated Current Sensor
STMicroelectronics has Introduced First Automotive Microcontroller With built-in AI Acceleration
Samsung Launched 200MP Image Sensor Called ISOCELL HP5
Aeva Introduced 4D LiDAR Sensor for Physical AI Systems
Technologies used
Hardware components
- Raspberry Pi
- MPU
- LED
- Sensor
- Module
- Capacitor
- Camera
- GPS
- LoRa
- RF
Software & tools
- TensorFlow
- Git
- GitHub
What you get
- Working project / hardware kit, tested before delivery
- Complete source code with explanation
- Project demo and guidance for your viva
- Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed.
Payment is in two parts:
• 50% advance to start the project
• Remaining 50% before delivery
Note:
• Documentation and PPT are not included by default
• If you need documentation/PPT, it can be arranged for extra time and cost
We'll confirm the exact timeline and cost with you after reviewing your requirements.