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 sort 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 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.