object detection using Raspberrypi

 

Object Detection:

Object detection is a computer vision technique that allow to identify and locate  an object in a image or video..

Object detection is a computer technology related to computer vision and image processing that detects and defines objects such as persons, vehicles and animals from digital images and videos. This technology has the power to classify just one or several objects within a digital image or video at once. Object detection has been around for years, but is becoming more apparent across a range of industries now more than ever before. To build object detection system we have many methods but Object detection using deep learning Technic (If we combine both the Mobile Net architecture and the Single Shot Detector framework, we arrive at a fast, efficient deep learning-based method to object detection) gives more accuracy for variety of object classes

Introduction :

Object detection using deep learning and computer vision to work with video streams and video files is provide features to identify the different kinds of objects. Object recognition is an important task in image processing and computer vision. It is concerned with determining the identity of an object being observed in an image. Humans can recognize any object in the real world easily without any efforts, on contrary machines by itself cannot recognize objects. Object Detection is a basic visual perception task and one of the key areas of applications of Computer Vision. It essentially deals with finding and locating specific objects within an image. Object recognition is one of the fundamental tasks in computer vision. It is the process of finding or identifying instances of object


APPLICATIONS 

 Object detection is breaking into a wide range of industries, with use cases ranging from personal security to productivity in the workplace. Object detection and recognition is applied in many areas of computer vision, including image retrieval, security, surveillance, automated vehicle systems and machine inspection. Significant challenges stay on the field of object recognition. The possibilities are endless when it comes to future use cases for object detection. Here we can discuss some current and future applications in detail. 

To run object detection using Raspberrypi follow the steps 

1-   Install raspbian as operating system link is given there 

                    https://www.raspberrypi.com/software/operating-systems/

2- Download balena echer    and bootload this raspbian os in the memory card 16GB or 32Gb i recommend 32gb    link is given 

https://www.balena.io/etcher/

3- I recommend  Raspberry pi 4b with 4gb or above for good results 

4- Insert memory card to Raspberry pi 4b slot. then after that attach vga to micro-hdmi with Raspberry        pi 4b   and connect it with lcd for display .Remember use 5v and 3 Ampere power adopter  for supply      of   Raspberrypi

5-    Now display will appear set time and data and activate wifi and run these commands for object                 detection .Now open terminal and run these commands


    sudo apt-get update

  sudo apt-get dist-upgrade

   Now enable camera

 While we're at it, let's make sure the camera interface is enabled in the Raspberry Pi Configuration menu. Click the Pi icon in the top left corner of the screen, select Preferences -> Raspberry Pi Configuration, and go to the Interfaces tab and verify Camera is set to Enabled. If it isn't, enable it now, and reboot the Raspberry Pi.




Download this repository and create virtual environment

git clone https://github.com/EdjeElectronics/TensorFlow-Lite-Object-Detection-on-Android-and-Raspberry-Pi.git
mv TensorFlow-Lite-Object-Detection-on-Android-and-Raspberry-Pi tflite1
cd tflite1

I'm using a virtual environment for this guide because it prevents any conflicts between versions of package libraries that may already be installed on your Pi. Keeping TensorFlow installed in its own environment allows us to avoid version conflicts. For example, if you've already installed TensorFlow v1.8 on the Pi using my other guide, you can leave that installation as-is without having to worry about overriding it.

Install virtualenv by issuing:

sudo pip3 install virtualenv

Then, create the "tflite1-env" virtual environment by issuing:

python3 -m venv tflite1-env
source tflite1-env/bin/activate

Step 1c. Install TensorFlow Lite dependencies and OpenCV

Next, we'll install TensorFlow, OpenCV, and all the dependencies needed for both packages. OpenCV is not needed to run TensorFlow Lite, but the object detection scripts in this repository use it to grab images and draw detection results on them.

To make things easier, I wrote a shell script that will automatically download and install all the packages and dependencies. Run it by issuing:

bash get_pi_requirements.sh

Using Google's sample TFLite model

Google provides a sample quantized SSDLite-MobileNet-v2 object detection model which is trained off the MSCOCO dataset and converted to run on TensorFlow Lite. It can detect and identify 80 different common objects, such as people, cars, cups, etc.

wget https://storage.googleapis.com/download.tensorflow.org/models/tflite/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29.zip
unzip coco_ssd_mobilenet_v1_1.0_quant_2018_06_29.zip -d Sample_TFLite_model
Now to Run TensorFlow model on Raspberry pi

It's time to see the TFLite object detection model in action! First, free up memory and processing power by closing any applications you aren't using. Also, make sure you have your webcam or Picamera plugged in.

Run the real-time webcam detection script by issuing the following command from inside the /home/pi/tflite1 directory. (Before running the command, make sure the tflite1-env environment is active by checking that (tflite1-env) appears in front of the command prompt.) 

python3 TFLite_detection_webcam.py --modeldir=Sample_TFLite_model
Now you can detect the object using Raspberrypi 
For demo video you can follow this link 
https://www.youtube.com/watch?v=T_GYB2tmUeg




Comments