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 using a Raspberry Pi Development Board for Fresh and Rotten Fruit Detection and automatically sorting it out.
Bill of Materials for Fresh and Rotten Fruit Detection
Note:- Servo Motor/actuator is optional if you want to do any action like sorting then you can that function in the 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.
Rotten Fruit Detection System – Code
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 the ML model and Python code and is also attached with the ML model made from Google Teachable.