Fresh and Rotten Fruit Detection Using Raspberry Pi
Hand-sorting rotten fruits from fresh ones in a batch of mixed fruits is a tedious and tiring job. Despite being time-consuming, most food processing factories carry out this method for making jams and other fruit-based products.
So to provide a much less demanding solution, today’s project focuses on creating a smart AI camera that can detect the freshness of fruit and automatically sort it out.
Bill Of Materials
Note:- Servo Motor / actuator is optional if you want to do any action like sorting then you can that function in code.
Creating ML model
Before creating an ML model, different datasets need to be collected. You can do so by either capturing pictures of different rotten and fresh fruits or by downloading any online datasets having similar differentiating pictures.
Next, create an ML model using various available options. To demonstrate this, I am using Lobe and Google Teachable Machine. After creating a new project and uploading the datasets into the ML model with correct labels, train it. Now download the trained ML model of TensorFlow and create a Python code for deploying it.
Include OpenCV and other libraries in the code. Then capture a video with a webcam, cut the selected frame and save it. On passing the saved frame to the ML model for processing, the freshness/rottenness of the desired fruit will be detected and give the final result.
Connect the camera and run the code. Put fruit in front of the camera to estimate its freshness/rottenness percentage so that sorting occurs. You can also modify the code for adding a servo motor or an actuator to move and sort out the fruits.
Note you can also make ML mode using different Tool like Google Teachable the Code folder contains ML model and python code and is also attached with ML model made from Google Teachable.