0% found this document useful (0 votes)
6 views58 pages

Image Processing-Based Sorting System

The document outlines a capstone project titled 'Image Processing-Based Sorting System' undertaken by students at the American University of Kuwait, supervised by Dr. Seyed Esmaeili. The project aims to develop an automated sorting system utilizing image processing to classify objects by color and size, addressing the inefficiencies of manual sorting in manufacturing. The report includes a detailed analysis of the project's objectives, methodology, and potential impacts on various industries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views58 pages

Image Processing-Based Sorting System

The document outlines a capstone project titled 'Image Processing-Based Sorting System' undertaken by students at the American University of Kuwait, supervised by Dr. Seyed Esmaeili. The project aims to develop an automated sorting system utilizing image processing to classify objects by color and size, addressing the inefficiencies of manual sorting in manufacturing. The report includes a detailed analysis of the project's objectives, methodology, and potential impacts on various industries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

Image Processing-Based Sorting System

ELEG/CPEG 480- Capstone Design Project II

Project Members
Abdulwahab Abdal S00045643
Aseel Al-Daleh S00053254
Misk Al-Dukhi S00050310
Noura Al-Jassam S00050188
Nourah AlKandari S00038362

Project Supervisor
Dr. Seyed Esmaeili

Department of Electrical & Computer Engineering


AMERICAN UNIVERSITY of KUWAIT
January, 2024
Image Processing-Based Sorting System
Project Members
Abdulwahab Abdal 45643
Aseel Al-Daleh 53254
Misk Al-Dukhi 50310
Noura Al-Jassam 50188
Nourah AlKandari 38362

The capstone project report is being submitted in partial fulfillment of the


requirements for the degree of
Bachelor of Engineering in Electrical/ Computer Engineering

Project Supervisor(s):
Dr. Seyed Esmaeili

Supervisor’s Signature: ____________________________

Department of Electrical & Computer Engineering


AMERICAN UNIVERSITY of KUWAIT
January, 2024
Declaration

We certify that this project work titled “Image Processing-Based Sorting System” is our
own work. The work has not been presented elsewhere for assessment. The material that has been
used from other sources has been properly acknowledged / referred.

Project Members
Abdulwahab Abdal S00045643
Aseel Al-Daleh S00053254
Misk Al-Dukhi S00050310
Noura Al-Jassam S00050188
Nourah AlKandari S00038362

i
Plagiarism Certificate (Turnitin Report)

This thesis has been checked for Plagiarism. Turnitin report endorsed by the Supervisor(s)
is attached.

Project Members
Abdulwahab Abdal S00045643
Aseel Al-Daleh S00053254
Misk Al-Dukhi S00050310
Noura Al-Jassam S00050188
Nourah AlKandari S00038362

Signature of Supervisor

ii
Copyright Statement

 Copyright in text of this project report rests with the student authors. Copies (by any
process) either in full, or of extracts, may be made only in accordance with instructions
given by the authors and lodged in the Library of AUK. Details may be obtained by the
Librarian. This page must form part of any such copies made. Further copies (by any
process) may not be made without the permission (in writing) of the authors.
 The ownership of any intellectual property rights which may be described in this project
report is vested in AUK’s Department of Electrical & Computer Engineering, subject to
any prior agreement to the contrary, and may not be made available for use by third parties
without the written permission of the AUK’s Department of Electrical & Computer
Engineering, which will prescribe the terms and conditions of any such agreement.
 Further information on the conditions under which disclosures and exploitation may take
place is available from the Library of AUK, Kuwait.

iii
Acknowledgements

We sincerely thank the Almighty for all of the support, direction, and blessings that have
brightened our journey over the course of these four life-changing years. We extend our sincere
gratitude to our families, whose unfailing understanding and support have been the cornerstone of
our work. Your support and faith in our quest for knowledge have been a never-ending source of
motivation. Our academic experience has been greatly influenced by the lessons and direction of
our excellent instructors and mentors, to whom we are incredibly grateful. Your guidance and
inspiration have enabled us to push limits and discover new areas of knowledge.

As a team, we commemorate this achievement, understanding that it is the result of our


combined efforts, steadfast encouragement, and heavenly favour.

Abdulwahab Abdal S00045643


Aseel Al-Daleh S00053254
Misk Al-Dukhi S00050310
Noura Al-Jassam S00050188
Nourah AlKandari S00038362

iv
Abstract

In computer vision, recognizing things based on their forms is crucial, especially when interpreting
digital pictures. Shape recognition is used in a wide range of applications, including robotics,
healthcare, assistive technology for the disabled, etc. Robotic automation is recommended for
object sorting since human eyes cannot continually distinguish colors, which ultimately lowers the
job's quality. Robotic automation would reduce the need for the operator to be physically present
on the job site to carry out the tasks assigned to him. The purpose of this project was to create and
put into practice a robotic system for industrial applications that can recognize and classify objects
according to their color or size based on image processing. This system used advanced machine
training algorithms to analyze images and recognize the objects in them. The system can be used
in retail and logistics to quickly sort items into different categories. The designed system uses a
camera to capture images of the objects that move on a conveyor belt and feed them to a Raspberry
Pi to be sorted using image processing based on their color or size. The objects will then be moved
away from the conveyor belt using a sorter, which is connected to a servo motor and controlled by
the Raspberry Pi. IR obstacle detection sensors are used for detecting object presence on the
conveyor belt.

Key Words: Sorting Systems, Auto-objects sorting, image processing

v
Table of Contents

Declaration ................................................................................................................................ i
Plagiarism Certificate (Turnitin Report) ................................................................................ ii
Copyright Statement ............................................................................................................... iii
Acknowledgements .................................................................................................................. iv
Abstract .....................................................................................................................................v
Table of Contents .................................................................................................................... vi
List of Figures........................................................................................................................ viii
List of Tables ........................................................................................................................... ix
Chapter 1 : INTRODUCTION .................................................................................................1
1.1 Background ...........................................................................................................................1
1.2 Problem Statement ................................................................................................................2
1.3 Project Objectives and Goals .................................................................................................2
1.4 Significance, Scope and Definitions ......................................................................................2
1.5 BOCR Analysis .....................................................................................................................3
1.6 Report Outline .......................................................................................................................4
Chapter 2 : LITERATURE REVIEW .....................................................................................5
2.1 Background ...........................................................................................................................5
2.2 Surveyed Projects ..................................................................................................................6
2.2.1 Arduino Based Lemon Sorter Machine ...............................................................................6
2.2.2 Colour based sorting station with MATLAB simulation .....................................................7
2.2.3 Fruit Sorting Robotic Arm Based on Image Processing.......................................................7
2.2.4 Colour Sensor Based Object Sorting Robot ........................................................................8
2.2.5 Color Sorting Machine using MicroController ....................................................................9
2.2.6 Color Sorting Robotic Arm ............................................................................................... 10
2.2.7 Development of Smart Sorting Machine Using Artificial Intelligence for Chili Fertigation
Industries .................................................................................................................................. 11
2.3 Summary and Implications .................................................................................................. 13
Chapter 3 : METHODOLOGY, DESIGN AND ANALYSIS ............................................... 15
3.1 Methodology ....................................................................................................................... 15
3.2 Research Design .................................................................................................................. 15
3.3 Software and Hardware ....................................................................................................... 17
3.3.1 Hardware.......................................................................................................................... 17
3.3.2 Software ........................................................................................................................... 25
3.4 Project Cost ......................................................................................................................... 27
3.5 Ethical Considerations and Factors ...................................................................................... 27
Chapter 4 : IMPLEMENTATION ......................................................................................... 28

vi
4.1 Hardware Implementation ................................................................................................... 28
4.2 Software Implementation..................................................................................................... 31
Chapter 5 : EVALUATION .................................................................................................... 41
5.1 System Features .................................................................................................................. 41
5.2 Project Impacts .................................................................................................................... 42
5.2.1 Economic ......................................................................................................................... 42
5.2.2 Society ............................................................................................................................. 42
5.2.3 Environmental .................................................................................................................. 43
Chapter 6 : CONCLUSIONS AND FUTURE WORKS ........................................................ 44
6.1 Conclusion .......................................................................................................................... 44
6.2 Future Work ........................................................................................................................ 44
REFERENCES ........................................................................................................................ 45

vii
List of Figures

Figure 2.1: Lemon sorter system block diagram [5]. ....................................................................6


Figure 2.2: Basic schematic of the system [6] ..............................................................................7
Figure 2.3: Fruit Sorting Robotic Arm block diagram [7] ............................................................8
Figure 2.4: Robotic area and control room unit block diagram [8] ...............................................9
Figure 2.5: Overview of the project [9]...................................................................................... 10
Figure 2.6: Color sorting robotic arm block diagram [10] .......................................................... 11
Figure 2.7: Robot arm block diagram [11] ................................................................................. 12
Figure 3.1: Agile project methodology. ..................................................................................... 15
Figure 3.2: Designed system block diagram. ............................................................................. 16
Figure 3.3: Raspberry Pi 4 Model B. ......................................................................................... 18
Figure 3.4: Conveyor belt. ......................................................................................................... 19
Figure 3.5: L293D H-bridge module. ........................................................................................ 20
Figure 3.6: USB Webcam.......................................................................................................... 21
Figure 3.7: IR Infrared Obstacle Avoidance Sensor. .................................................................. 22
Figure 3.8: Servo motor............................................................................................................. 23
Figure 3.9: DC-DC Buck converter module. .............................................................................. 25
Figure 3.10: Thonny IDE. ......................................................................................................... 26
Figure 4.1: Power supply circuit schematic circuit. .................................................................... 28
Figure 4.2: Schematic circuit. .................................................................................................... 29
Figure 4.3: Hardware implementation. ...................................................................................... 30
Figure 4.4: Outer design of the hardware packaging. ................................................................. 30
Figure 4.5: Overall system design. ............................................................................................ 31
Figure 4.6: Thonny IDE window while system training for sorting a blue colored object. .......... 36
Figure 4.7: Thonny IDE window of different colored object. ..................................................... 37
Figure 4.8: The IR sensor detects the object at the sorting area. ................................................. 37
Figure 4.9: Sorting arm pushing the object. ............................................................................... 38
Figure 4.10: System flowchart. .................................................................................................. 40

viii
List of Tables

Table 1.1: Project BOCR Analysis ..............................................................................................3


Table 1.2: Team BOCR Analysis ................................................................................................4
Table 2.1: Comparison between surveyed projects and the proposed project.............................. 13
Table 3.1: Alternative to servo motor. ....................................................................................... 23
Table 3.2: project cost. .............................................................................................................. 27

ix
Chapter 1 : INTRODUCTION

1.1 Background
Objects sorting system is the process of organizing objects into different categories
according to their physical characteristics or other qualities. It is a common practice in many
industries, such as automotive, manufacturing, and logistics. Objects sorting systems can be
manual or automated and can be used for a variety of tasks, from simple sorting of items into
categories to more complex tasks such as classifying objects that are difficult to identify. Manual
sorting systems involve sorting objects manually, typically using sorting tables or dividers.
Automated sorting systems use a variety of automated techniques to sort objects quickly and
accurately. For example, a barcode scanner can be used to read barcodes on objects and sort them
into the appropriate categories. Automated sorting systems are often used in warehouses to ensure
that items are correctly sorted and sent to the correct destination. Additionally, automated sorting
systems can also be used for sorting items into categories for more efficient inventory
management. Objects sorting systems are also used in retail stores to quickly sort items into
categories for easy customer selection. Ultimately, objects sorting systems are essential in many
industries for efficient organization and management of items [1].

Automation has been accomplished using a variety of techniques, most frequently in


combination, including mechanical, hydraulic, pneumatic, electrical, electronic devices, and
computers. Labor savings, power cost reductions, material cost savings, and increases to quality,
accuracy, and precision are all advantages of automation. In some current systems, humans sort
the items primarily manually. Because of this, there is a greater chance that human mistake will
be taken into consideration and the work will be incorrect. Incorrect sorting of components or
things in an industry increases the risk of major disarray and subpar products [2].

Because sorting takes less time and happens more quickly, automated sorting systems have
become crucial in industrial industries. In order to make the best decision, it was employing sensors
that connected to a microcontroller or PLC for control. The sorting process is dependent on the
size, volume, type, color, and form of the detection products. An arm robot, a sorting gate, and a
hydraulic connection make up the actuator sorting. Mostly vision computers equipped with
artificial intelligence and statistical techniques are used in the sorting process.

1
1.2 Problem Statement
Manufacturing companies design their goods using a variety of geometrical and aesthetic
features, such as form, size, height, color, and edges. Because there was little demand, the
production rate was low, and manufacturing organizations had plenty of time to finish their duty,
sorting and differentiating items was a very achievable process in the past. However, the situation
now is different since there is a greater need for the product and it is getting more difficult for
manufacturing enterprises to meet demand within the allotted time frame. Additionally, given
today's high raw material costs, several businesses are unable to cover the labor costs associated
with such menial and unskilled tasks as sorting. The corporation cannot afford any tiny faults in
the sorting process performed by people since they would waste raw resources, and given the
current conditions, no organization can afford any wastage or errors. Companies must thus
implement a new system structure for product sorting in order to boost productivity and decrease
personnel costs. As a result, an automated system is required to solve these issues.

1.3 Project Objectives and Goals


We have proposed an automated sorting system which is based on image processing for
sorting them according to their color and size. The system has many objectives and goals such as:
1. To use image processing for creating an automated sorting system.
2. To use Raspberry pi as the system controller.
3. To design a small prototype of an industrial production line.
4. To use the system for sorting objects based on their color and size.
5. To implement a low cost system using less number of components.
6. To decrease the human efforts and faults in industrial processes.

1.4 Significance, Scope and Definitions


Automated objects sorting systems using image processing provide numerous benefits to a
variety of industries. In the manufacturing and supply chain industries, automated object sorting
systems can improve accuracy and efficiency of sorting tasks, allowing for faster production times,
fewer mistakes, and cost savings. Automated object sorting systems also allow for greater
flexibility in production processes. By being able to quickly sort and identify objects, machines
can be quickly reprogrammed to perform a different sort task, eliminating the need for manual

2
labor. Additionally, automated object sorting systems can be used to detect and identify objects
based on their color and size. This type of sorting system can be used in warehouse and logistics
operations to quickly sort and identify items, allowing for more efficient and timely deliveries.
Automated object sorting systems can also be used in safety and security applications to quickly
identify suspicious objects and objects that are not authorized in a designated area. Automated
object sorting systems can also be used to detect counterfeit products, allowing companies to
protect their products, brand, and customers. By having automated object sorting systems in place
that can quickly and accurately identify objects, companies can save time, money, and resources.

1.5 BOCR Analysis


The Benefits, Opportunities, Costs, and Risks (BOCR) Analysis is a powerful decision aid
and guide that provides a complete framework to help in looking at all aspects of a project or
decision. By considering the Benefits, Opportunities, Costs, and Risks associated with the project,
project’s team members can be able to gain a much better understanding of the implications of
their decisions. Through the analysis, the team can identify the strengths and weaknesses of the
project or decision, as well as uncover any potential risks associated with it. In Table 1.1, the
project BOCR analysis is shown in details.

Table 1.1: Project BOCR Analysis


Benefits Opportunities
1. Reduce the errors and faults due to human. 1. Safety and security applications.
2. Reduce the time and effort needed. 2. Healthcare.
3. Using the raspberry pi as a high-speed 3. Military by sorting separate dissimilar
processor. equipment based on their color.
4. Using image processing is a better choice 4. Agriculture
than using a color sensor.
5. Sorting objects based on color or size.
6. OpenCV has powerful image processing
functions which is suitable for real time.

Costs Risks
1. Low cost materials. 1. Components failure.
2. Low cost for maintenance. 2. Mechanical issues due to using motors for
moving the conveyor belt.
3. Captured imaged clearance may be affected
by the camera.

3
In Table 1.2, the team BOCR analysis is shown in details.

Table 1.2: Team BOCR Analysis


Benefits Opportunities
1. Distribution of tasks between members. 1. Working as a team.
2. Making researches and choose 2. Ability to apply the idea on reality.
components. 3. Gain a great knowledge in new technologies.
3. Ability to plan and design a
comprehensive system.

Costs Risks
1. The cost will be shared by all members. 1. Holding meetings periodically at a time
available to all members.
2. Lack of knowledge in dealing with some
components and algorithms.

1.6 Report Outline


Chapter two: introduces the literature review by introducing description for some projects
which are published. It also introduces a comparison between the projects and our proposed
system.

The third chapter: introduces a description of the designed system in details, the
components that would be the best to build the system, and the relatives of these components by
explaining the reasons of the components and algorithms.

The fourth chapter: introduces a description of the system implementation for both
hardware and software.

The fifth chapter: introduces the system’s features and impacts.

The sixth chapter: introduces the conclusions and future work.

4
Chapter 2 : LITERATURE REVIEW

2.1 Background
The process of sorting objects has undergone significant improvements throughout history,
driven by advancements in technology, methodology, and automation. In ancient times, sorting
objects was a manual process carried out by human labor. People would visually inspect items and
manually organize them based on certain criteria such as size, shape, or color. With the advent of
the Industrial Revolution, simple mechanical devices were introduced to assist in sorting tasks.
Conveyor belts and chutes were used to transport items, and basic sorting mechanisms were
employed to divert objects based on specific characteristics. The late 19th century saw the
introduction of punch card sorting systems. These systems used punched cards with holes
corresponding to specific attributes. The cards were fed through machines that sorted objects based
on the presence or absence of holes. Early to mid-20th century, electromechanical sorting
machines, such as the Hollerith tabulating machine, became widely used for tasks like census data
processing. These machines used electrical components for sorting and counting, improving the
speed and accuracy of the sorting process. Mid-20th century onward, the development of
computers in the mid-20th century brought about a significant leap in sorting capabilities. Early
computers were programmed to perform sorting algorithms, such as bubble sort or quicksort,
providing efficient and automated ways to organize data. Over time, sorting algorithms have been
refined and optimized to improve efficiency and reduce processing time. Algorithms like merge
sort, heap sort, and radix sort have become standard for various applications. Late 20th Century,
the introduction of barcode and radio-frequency identification (RFID) technology revolutionized
sorting in industries such as logistics and retail. Barcodes enabled automated scanning and sorting
of products, while RFID tags allowed for real-time tracking and sorting without direct line-of-sight
requirements. Contemporary, modern industries utilize advanced automated sorting systems, often
incorporating machine vision, sensors, and robotics. These systems can identify and sort objects
based on a wide range of criteria, including shape, size, color, weight, and more. Recent years,
machine learning and artificial intelligence have been increasingly applied to sorting processes.
Computer vision systems powered by AI can recognize and categorize objects with high accuracy,
enabling adaptive and dynamic sorting based on complex criteria [3].

5
The process of transferring an image to digital form and then manipulating it to improve
the image or extract valuable information is known as image processing. This uses a picture that
was taken by the camera as the input and some information that was taken out of the image as the
output. The use of image processing in several sectors has expanded greatly. Image processing has
been used in the automation and robotics studies to demonstrate its significance in business,
defense, surveillance, and security. One of the difficulties that the industries encounter is object
sorting [4].

2.2 Surveyed Projects


2.2.1 Arduino Based Lemon Sorter Machine

Chauhan, et al. [5] designed a color sorting system based on Arduino NANO and the color
sensor TCS3200. The system block diagram is shown in Figure 2.1. It consists of a hopper
machine, a color sensor module, servo motors, an Arduino NANO, and a color-sorted container.
When colored items are positioned on the slot of the top servo motor, the top servo motor rotates
in the direction of the TCS3200 color sensor. The color sensor, designated TCS3200, is what
measures the light reflected from an object and turns it into frequency. The bottom servo motors
are utilized to move a slider as needed to place the object in the appropriate container based on the
color of the object that was detected. An Arduino NANO microcontroller controls input and output
processes.

Figure 2.1: Lemon sorter system block diagram [5].

6
2.2.2 Colour based sorting station with MATLAB simulation

Victor, Dana, and Ciprian [6] designed a colour based sorting station system which
includes a gravitational store with color sensor as shown in Figure 2.2. Using a linear pneumatic
motor and a servo DC motor, a linear pneumatic motor pushes the items out of the gravitational
storage one at a time and onto a conveyor belt with a steady pace. The sorting station contains four
predetermined sorting points where the components are halted in accordance with their color,
which was previously determined in the gravitational storage. Two pneumatic motors, a servo dc
motor, and the conveyor itself (the conveyor end) are used to remove the pieces off the conveyor.
A graphical MATLAB interface that supports sorting algorithm optimization was used to carry out
system optimization.

Figure 2.2: Basic schematic of the system [6]

2.2.3 Fruit Sorting Robotic Arm Based on Image Processing

Anusha, Shweta, and Suraj [7] developed a smart system for classifying the fruit. This food
sorting system uses image processing to provide information on the fruit's color and size. As shown
in Figure 2.3 of the system block diagram, it mainly consists of USB digital camera, a computer,
a PIC microcontroller, and a DC motor. The samples of various fruits are placed in front of the
camera, calibrated offline, and kept in various storage facilities. It employs an above camera that
is installed on the computer and connected to the computer through USB as an input sensor. After
taking a picture, the camera feeds it to the computer for color processing. For color processing on

7
computers, MATLAB is utilized. The PIC16F877A microcontroller receives this signal and act
accordingly. The motor drivers are used by the microcontroller to operate the DC motor in turn.
By regulating their angular movement, these DC motors will regulate the robotic arm's movement.
As a result, the robotic arm will have complete DC motor control. The robotic arm's gripper will
choose and position the object based on its size.

Figure 2.3: Fruit Sorting Robotic Arm block diagram [7]

2.2.4 Colour Sensor Based Object Sorting Robot

Rudresh and Prof. Shubha [8] introduced a system that aimed to arrange the colored items
that are approaching on the conveyor by picking them up and setting them in their proper locations.
The system consists of color sensors, which detect the color of the object and transmit the signal
to the controller. Infrared sensor (IR) is used to detect the object arrival on the conveyor. The
robotic arm's various motors are driven by the microcontroller's signal guidance system so it can
pick up the thing and position it in the right spot. The robotic arm moves to the proper spot to
release the object and returns to the usual potion depending on the color. As shown in Figure 2.4,
there are two distinct work areas in the working process: one is for dealing with colored things
(robotic area) and the other for controlling the robotic area (control room). Using ZigBee
technology, the administrator may modify the Bin settings from a central PC. If the administrator

8
wants a material count, he can access the counts from the central system and manage system
operations from the central station.

Figure 2.4: Robotic area and control room unit block diagram [8]

2.2.5 Color Sorting Machine using MicroController

Soumy, Subrata, and Abhijnan [9] developed a prototype of a “Color Sorting Machine
using MicroController" that makes use of a position control mechanism and color sensor
technology. In order to demonstrate the concept, a prototype has been created which can be
described as shown in Figure 2.5. The color discs are moved from the holder to precisely the top
position of the color sensor TSC230 in this project thanks to a stepper motor. The color sensor
TSC230 recognizes the disc's color and transmits to the microcontroller the RGB value of that
color. After determining the color from the preset value, the microcontroller tells the servo motor
to rotate the sliding platform so that it faces the appropriate color pot. The disc falls to the specific
color pot during the stepper motor's sixth cycle.

9
Figure 2.5: Overview of the project [9]

2.2.6 Color Sorting Robotic Arm

Shweta, et al [10] introduces a Color Sorting Robotic Arm system. The system is a robotic
arm that sorts tiny spheres before selecting and placing them in various bins. The system block
diagram is shown in Figure 2.6. Color sensors employ a way of converting light intensity to
frequency to identify colors. The TCS34725 color sensor is connected to the Arduino board in our
setup. A microcontroller-based system that also controls DC servo motors through a motor driver
L293D is used to operate the robotic arm. The robotic arm has been designed to pick up the sphere
from one location and dump it into the appropriate colored box. Here, the color of the object to be
picked up and dropped is sensed using color sensors, and the voltage, or the intensity of the color
sensed, is translated into frequency and sent as an input to the microcontroller. The robotic arm's
motors hold the things and drop them in the designated area according to color thanks to the motor
driver circuit enabled by the microcontroller.

10
Figure 2.6: Color sorting robotic arm block diagram [10]

2.2.7 Development of Smart Sorting Machine Using Artificial Intelligence for Chili
Fertigation Industries

Abdul Aziz, et al [11] introduced a design of a portable sorting device that could use
artificial neural networks to separate chili into groups according on color which is shown in Figure
2.7. In this system, Arduino Uno is used as the system controller. For this procedure, the sensor is
a camera module. The image processing and categorization of the chili were developed using
MATLAB software, which also incorporated ARDUINO Toolboxes. Using the signal from the
ARDUINO, the stepper motor will move the chili sorting tray according to their color. A motor
driver ULN 2003, which is often used as a driver circuit for relays, LED lights, and stepper motors,
will be utilized to control a 12V stepper motor. The ARDUINO Uno microcontroller was intended
to operate the stepper motor and power windows. It will be supplied via a portable laptop that has
been configured to incorporate a MATLAB image processing application. The image of the chili
was taken with a Camera Module OV7670 VGA that connected to the ARDUINO. The picture
will then be obtained from the stored folder of the image taken using the VGA camera and
processed using a configuration for the MATLAB software.

11
Figure 2.7: Robot arm block diagram [11]

12
2.3 Summary and Implications
The comparison between the surveyed project and our proposed system is included in Table
2.1 below.

Table 2.1: Comparison between surveyed projects and the proposed project.

Feature Color Camera Controller Robotic MATLAB Image


sensor arm processing
type
using Python

Project

Arduino Based Lemon √ Arduino √


Sorter Machine
Nano
Colour based sorting √ Arduino √
station with MATLAB
simulation Leonardo

Fruit Sorting Robotic √ PIC √


Arm Based on Image
Processing
Colour Sensor Based √ √ √
Object Sorting Robot
(not
mentioned)
Color Sorting Machine √ ESP32
using MicroController
Color Sorting Robotic √ Arduino √
Arm
Development of Smart √ Arduino Uno √
Sorting Machine Using
Artificial Intelligence
for Chili Fertigation
Industries
Our system (Image √ Raspberry pi √
Processing-Based
Sorting System)

13
Here are some of the reasons why the proposed system is preferred over the surveyed projects:

1. Image processing is a vastly superior method of color detection and recognition


compared to relying on a color sensor; image processing can identify subtle color
changes that a color sensor would not be able to detect. On the other hand, color sensors
can be subject to ambient light interference which can reduce their accuracy. Color
sensors are often limited to detecting a specific range of colors, while cameras can be
more flexible since they capture full-color images.

2. Using a camera can accurately detect the presence of an object even if it's in a far
distance of the camera or when more than one object is present in the image.

3. Python is an open-source language with a large library of packages for image


processing. It is also easy to learn with lots of tutorials available online. On the other
hand, MATLAB is more complex than Python and requires a learning curve to become
proficient in using it.

4. Python is typically free to use, while MATLAB requires a license.

5. Python also has a larger selection of image processing libraries than MATLAB, which
can be useful for more specialized tasks.

6. Unlike Arduino and PIC microcontrollers, Raspberry Pi has a powerful, integrated


processor and operating system, allowing it to perform more complex tasks and run
more sophisticated software more efficiently.

7. One of the primary drawbacks of using robot arm in sorting objects is the cost of
purchasing and maintaining a robot arm.

8. Robot arms may take up a lot of space and increase the system’s size and cost.

14
Chapter 3 : METHODOLOGY, DESIGN AND ANALYSIS

3.1 Methodology
Agile methodology is an iterative approach to project management and software
development that helps teams deliver value to their customers faster. It emphasizes adaptability
and continuous improvement throughout the life of a project. The agile methodology is based on
five core phases: requirements, design, develop, test, and release. The design phase is all about
creating the project plan and requirements. During this phase, the team will evaluate customer
needs, set goals, create user stories, and map the project timeline. This phase is essential for
creating a successful project. The develop phase is where the development team will actually build
the software. This includes coding, unit testing, and integration of the various components. The
test phase is where the team will test the software for any bugs or errors. This is also where the
team will ensure that the software is meeting customer requirements. The Release phase is where
the software is released to the customer. During this phase, the team will deploy the software,
monitor user feedback, and take action to ensure customer satisfaction.

Figure 3.1: Agile project methodology.

3.2 Research Design


The block diagram of the designed system is shown in Figure 3.2. The system uses a camera
to capture images of the objects that is placed on the conveyor belt and feed them to a Raspberry
Pi. The camera is connected with the Raspberry Pi board to receive the images in real-time. The
Raspberry Pi then processes the images to detect the objects and provide feedback about their

15
color. Once the objects is identified, the Raspberry Pi board then uses a sorter to remove them
from the conveyor belt. The sorter is connected to a servo motor and controlled by the Raspberry
Pi in order to receive commands from it and execute the appropriate motions. A DC motor is used
to move the conveyer belt by connecting the motor to the Raspberry pi. The DC motor can’t be
driven form the Raspberry pi directly, then it needs an H-bridge to drive it. Two IR sensors are
used at two different locations to detect the object while it’s moving on the conveyor belt; to enable
the system to identify that an object is existed to make sorting the objects easily. The user can
move the conveyor belt in forward, backward, and stop it using the push buttons. The OK button
is used for system training purposes. The system is powered from the wall socket using an AC/DC
adapter (12volt). Then a buck converter is used to step the voltage down to the required voltage to
power the Raspberry pi and the system components (5volt DC). Another buck converter is used to
feed the servo motor with 5 volt to operate.

Figure 3.2: Designed system block diagram.

16
3.3 Software and Hardware
3.3.1 Hardware

 Raspberry Pi

The Raspberry Pi A is one-chip PC equivalent to a (less powerful) desktop computer. A


Broadcom-based ARM processor, graphics chip, RAM, GPIO, and additional ports for external
devices are all found on the Raspberry Pi board. The Raspberry Pi's working process is very similar
to that of a PC and requires extra hardware for functioning, such as a keyboard, mouse, display
unit, power supply, and SD card with an OS already installed. It has an HDMI port for the display,
and a USB port to attach a keyboard and mouse to it. Ethernet and USB connections are also
provided by the Raspberry Pi to enable network and peer-to-peer connectivity. Similar to how an
operating system is the foundation of any computer. Linux-based open source operating systems
are supported by Raspberry Pi [12].

This computer has already through several versions, each with a unique purpose and
performance level. Since the tiny CPU belongs to the ARM family, it is equivalent to a typical
smartphone. It is feasible to run other Linux distributions, Windows 10 or the Microsoft IoT Core
on a Raspberry Pi. In contrast to PC, Raspberry Pi may be used to construct the necessary
applications as well as operate a variety of devices through GPIO connections [13]. The Raspberry-
Pi is one of the most capable and popular electronic prototyping boards available today. In terms
of speed and effectiveness, it functions like a mini-computer. It may be used to a variety of fields
to create various real-time applications that are helpful to us in our everyday lives [14].

Raspberry Pi is a very popular and affordable minicomputer that is widely used in various
applications. One of the most important uses of Raspberry Pi is in image processing. Image
processing is the process of manipulating digital images to enhance their quality or extract useful
information from them. Raspberry Pi can be used for various image processing tasks such as object
detection, facial recognition, and image classification. The Raspberry Pi’s small size and low cost
make it an ideal platform for image processing applications. The Pi’s hardware specifications
allow it to process images quickly and accurately, making it an ideal choice for applications that
require real-time image processing. The Pi also has access to a wide range of open-source software
libraries, allowing developers to create powerful image processing applications [15].

17
As an alternative to Raspberry pi is the Arduino. The main difference between them that
the Arduino is microcontroller board, while Raspberry Pi is a microprocessor. The Raspberry Pi
is a powerful single-board computer that is capable of performing complex image processing
algorithms. It can be used to capture and analyze images, as well as process and store data. The
Raspberry Pi is powerful and versatile, but it is more expensive and requires more programming
knowledge. The Arduino controller is cheaper and easier to use, but it has limited processing power
and is not suitable for more advanced tasks [16].

Since our project application needs high processing power, then we will go with the
Raspberry pi. Specifically, we have choosen Raspberry pi 4 model B. Raspberry Pi 4 Model B is
the latest version of the Raspberry Pi series of single-board computers. It is a small, powerful, and
affordable computer that can be used for a wide range of applications. It has a quad-core 64-bit
ARM processor, up to 4GB of RAM, 4K video output, dual-band 802.11ac Wi-Fi, Bluetooth 5.0,
two USB 3.0 ports, two USB 2.0 ports, and Gigabit Ethernet. It also has a 40-pin GPIO header for
connecting to hardware and electronic components. The Raspberry Pi 4 Model B is an ideal choice
for a wide range of projects, including media centres, home automation, robotics, and more [17]

Figure 3.3: Raspberry Pi 4 Model B.

18
 Conveyor Belt and DC Motor

DC motors are a perfect choice for conveyor systems, which helps to move items from one
location to another, since they have consistent speed and high torque requirements. A key need for
conveying systems is that they be quiet and simple to manage. DC motors are used in a variety of
applications, including industrial, commercial, and consumer products. They are highly efficient,
reliable, and have a long life span. DC motors have a straightforward construction, making it
simple to repair or replace them. DC motors are also able to operate in a wide range of temperatures
and are able to withstand high levels of shock and vibration. They are also easy to install and
maintain, making them an ideal choice for many conveyor belt applications. Finally, the most
evident benefit of adopting DC motors is their affordability [18]. The choosed conveyor belt is
shown in Figure 3.4. Its length is 517mm, it works by 12V, and its DC motor requires 100mA to
operate.

Figure 3.4: Conveyor belt.

 Motor Driver (H-Bridge)

An electrical circuit known as H -bridge enables the application of a voltage across a load
in either direction. To enable DC motors to operate forward and backward, H-bridge circuits are
commonly employed in robotics and many other applications. The H-bridge motor driver circuit
is often used to stop and start a motor, as well as to reverse its direction. A typical motor driver
integrated circuit (IC) is the L293D, which enables the DC motor to run in either direction. A pair
of two DC motors may be instantly controlled in any direction using this IC's 16 pins. This means
that we can control two DC motors with one L293D IC. Additionally, this IC is capable of driving
small and large motors [19]. The L293D module is perfect for motor control needs. This twin H-
Bridge module, which is based on the L293D, enables to incorporate two controlled motors.
Numerous microcontrollers, such as the Arduino and Raspberry Pi, may be utilized with it. PWM

19
control of up to two DC motors or one four-line stepper is supported by the module. It may be
powered by 5V and a drive of 4.5V - 36V [20].

Figure 3.5: L293D H-bridge module.


 USB Cam

USB cameras are devices that allow users to capture digital images and videos. They are
small, portable, and easy to use, making them an ideal choice for those who want to capture images
and videos on the go. USB cameras have become increasingly popular due to their low cost, ease
of use, and portability. They are often used in the classroom, as well as by professionals in the
field. USB cameras use a variety of technologies to capture digital images and videos, including
CCD sensors, CMOS sensors, and even digital video cameras [21]. To use a USB camera, users
simply plug it into a computer or other device with a USB port, then connect the camera to the
computer via a USB cable. Once connected, the user can then access the camera's controls and
software to capture and store digital images and videos. USB cameras are available in a variety of
shapes and sizes, and come with a variety of features, such as zoom, color filters, and image
stabilization. They are also able to capture high-quality images and videos with minimal noise and
distortion. USB cameras are a great way to capture images and videos on the go, and are a great
choice for those looking for an affordable and easy-to-use camera [22]. The camera used in this
project is shown in Figure 3.6 which is Sync 1080p Full HD Wide-Angle USB Webcam w/Dual
Mic. It can operate immediately without the need to install any extra drivers once it’s inserted into
a PC's USB-A port. It can deliver Full HD films at 30 frames per second using a 2MP CMOS
image sensor [23].

20
Figure 3.6: USB Webcam.

As an alternative to USB webcam is the WiFi cam. Using a USB Web Cam with Raspberry
Pi instead of a WiFi Camera is a good choice for a variety of reasons. First, with a USB Web Cam,
we can get a much more reliable connection to the Raspberry Pi. This means fewer dropped frames
and higher quality images. Furthermore, USB Web Cams are typically less expensive than WiFi
Cameras, making them more cost effective. Additionally, USB Web Cams are more reliable in
terms of latency than WiFi Cameras, which can be prone to lag. This makes them a great choice
for applications that require a low latency connection. Finally, USB Web Cams are more secure
than WiFi Cameras, providing an additional layer of security against potential hackers. Overall,
the reliable connection, lower cost, low latency, and added security make them a great option.

 IR Infrared Obstacle Avoidance Sensor

The integrated infrared transmitter and receiver of the infrared obstacle sensor module
(shown in Figure 3.7) detects the existence of obstacles in front of it by emitting infrared light and
looking for reflected light. The detecting range of the module can be modified using the
potentiometer that is included into it. The sensor responds very well and steadily in both total
darkness and ambient light. The module has three pins; output, GND, and Vcc. Additionally, It
has two LEDs: one is for power, and when it is linked to electricity, it goes on. The other is used
to identify obstacles. The sensor is compatible with Raspberry Pi, has a wide detection range of 2
to 20cm, and has a detection angle of 35 º providing a wide field of view for accurate readings.

21
Furthermore, the sensor can be powered by 3-5V power supply modules, making it versatile and
convenient to use [24].

Figure 3.7: IR Infrared Obstacle Avoidance Sensor.

 Servo Motor

An electric servo motor is a self-contained electric device that spins machine parts precisely
and efficiently. This motor's output may be adjusted for angle, speed, and location. In order to
manage rotational or linear speed and position, an electric servo motor uses a closed-circuit
mechanism that combines position feedback. An electric servo motor has the benefit of being
controlled in an angular position since it will attempt to hold its position even if it runs into a
barrier that would otherwise modify the trajectory of the motor. The motor and its setting are
outfitted with a measurement system that ascertains the present position for exact position
modification [25].

Servo motors are commonly used in sorting systems to automate the process of sorting
items according to size, shape, or other characteristics. By using a servo motor, a sorting system
can accurately and precisely move items around a conveyor belt, allowing for efficient and
automated sorting. Servo motors are also used in positioning systems to accurately place items in
the correct location. This is done by using a servo motor to move a part or tool into the correct
position, and then stop in that precise position. This accuracy and precision allow for the exact
positioning of an item that is necessary for sorting systems. Lastly, servo motors are used to power

22
sorting systems, allowing them to run and sort items quickly and efficiently. By using a servo
motor in sorting systems, industries are able to reduce costs and increase productivity [25].

Figure 3.8: Servo motor


As an alternative to servo motor is the stepper motor. A comparison between the two types
of motors is shown in Table 3.1.

Table 3.1: Alternative to servo motor.


Feature Servo Motor Stepper Motor

Operation Continuous. Divided into discrete steps.

Control system Closed loop control system. Open loop control system
configuration

Feedback mechanism The feedback mechanism exists. No feedback mechanism.

Torque speed characteristics High torque at high speeds. High torque at low speeds.

Power consumption Less power. consume more power

Efficiency High. Less efficient.

Noise Low High

Cost High. Comparatively less.

Selected Yes No

23
As can be noticed from the previous table that servo motor operation is more effective than
stepper motor operation. This is so that the servo motor's positioning accuracy and angular
displacement may be improved by the closed loop control system setup. The maximal speed and
torque at speeds of a servo and a stepper motor are further differences. When a stepper motor is
stationary, or when it is in the holding torque state, it produces the highest torque. The torque is
significantly decreased when the output shaft speed rises. A servo motor may provide more torque
at speed and has a higher peak speed than a stepper motor [25].

 Power Supply (AC/DC Adapter)

An AC to DC adapter is a device used to convert alternating current to direct current. AC


power is the type of power that comes from the wall socket in homes, while DC power is the type
of power used by most electronics. An AC to DC adapter is used in situations where the used
device requires DC power, but only AC power is available. AC to DC adapters come in many
shapes and sizes, and are used to power everything from small electronics to large appliances.
Without the AC to DC adapter, many of the devices we rely on every day would not be able to
function [27].

 DC-DC Buck Converter

A DC-DC Buck Converter Module is a compact, efficient, and reliable device that can be
used to step down the voltage of an incoming signal. This device is often used in applications
where a higher voltage must be converted to a lower voltage, such as in powering low-power
devices from a higher voltage battery. The Buck Converter Module works by taking an input
voltage and converting it to a lower voltage via a series of switches and capacitors. This ensures
that the output voltage remains constant while the input voltage fluctuates. In addition, the Buck
Converter Module is designed to be very efficient, making it ideal for applications where power is
a concern. Additionally, the Buck Converter Module is designed to be compact and light, making
it easy to install in tight spaces [28].

The DC-DC Buck Converter Module LM2596 is a switching regulator with an adjustable
output voltage and is a great solution for applications where a small, compact, and efficient power
supply is required. It features an extremely efficient switching design that operates at up to 95%
efficiency, allowing to use it in high-power applications without having to worry about excessive

24
heat dissipation. Additionally, it features a wide input voltage range of 3.2V to 40V, allowing you
to use it with a variety of power sources, and an adjustable output voltage of 1.25V to 35V, giving
a great deal of flexibility with the power supply. The LM2596 DC-DC buck converter module has
a high-precision potentiometer and can efficiently drive loads up to 2A. It's also equipped with a
range of protection features such as over-current, short-circuit, and thermal protection, making it
both safe and reliable [29].

Figure 3.9: DC-DC Buck converter module.

3.3.2 Software

Linux, the operating system that powers the Raspberry Pi, primarily employs the Python
programming language for a variety of tasks. Because of its adaptability and simple syntax, Python
is also used by the Raspberry Pi Foundation as their primary programming language. A significant
number of tech enthusiasts utilize the language often in several Artificial Intelligence-related
projects across various industries. Python programming language would be a great choice for
learning and creating various web-based apps [30].

Python is an incredibly powerful and versatile programming language, making it an ideal


choice for programming the Raspberry Pi. Python is a high-level, interpreted language which is
simple to learn and use, and it features a large standard library which provides numerous useful
functions. It has an easy to use syntax which makes it perfect for beginners to programming, and
it is the most popular language for Raspberry Pi projects. Python is also able to interact with
hardware, allowing the Raspberry Pi to be used to control physical devices such as motors, lights,
and sensors. This makes it perfect for projects such as home automation, robotics, and physical
computing. In addition, Python is open source and free to use, making it the most cost-effective
language for Raspberry Pi projects. Finally, Python has a thriving community of developers and
many helpful libraries, making it easy to find support and resources. All of these features make

25
Python the ideal choice for programming the Raspberry Pi. Python's syntax is simple to write and
comprehend, but indentation is a crucial factor to take into account while using Python as a
programming language. All operating systems, including Windows, macOS, and Linux variants,
as well as the Raspberry Pi, support the Python language IDE (Integrated Development
Environment), Thonny [31].

Thonny is a Python IDE for learning and teaching programming that can naturally integrate
program visualization into the workflow of novice programmers. Different methods to move
through the code, step-by-step expression evaluation, understandable call stack representation, and
a mode for introducing the concepts of references and heap are a few of its standout features. By
recording user activities, it aids in educational research by repeating or dissecting the programming
process. Thonny IDE is a great choice for anyone who wants to learn and use Python. It is an
interactive development environment that is designed specifically for beginners and is easy to use.
Thonny IDE provides many features that make it a great choice for those who are new to coding.
Firstly, its user interface is simple and intuitive yet powerful, making it easy to navigate and use.
Secondly, it offers powerful debugging capabilities, allowing users to review and identify errors
quickly and easily. Thirdly, it has a wide range of built-in libraries and packages, allowing users
to access a wide range of functions and features. Finally, Thonny IDE is free to use and designed
to be extensible, meaning that additional features and tools can be added as needed [32].

Figure 3.10: Thonny IDE.

26
3.4 Project Cost
The project cost of the choosen components is cleared in Table 3.2.

Table 3.2: project cost.

Item Quantity Cost - USD

Raspberry Pi 1 163

Camera 1 81

Servo Motor 1 13

Conveyor belt 1 114

Motor Driver module 1 32

IR obstacle detector module 2 20

Adapter 1 16

Buck converter 2 6.5

Packaging box 1 20

Passive components - 32

Total cost 524

3.5 Ethical Considerations and Factors


We've assessed the requirements for the project and create a solution that satisfies them.
The implementation phase followed, during which we designed the system architecture, developed
the code, and tested the components individually. After that, we went to the integration phase,
where we’ve linked the elements together and tested the system to make sure every component is
operating as it should. Finally, we have completed the maintenance phase, during which we
monitored the system's functionality and addressed some problems. We ensured to offer thorough
documentation at every stage so that anybody can understand how the project functions and what
modifications were made.

27
Chapter 4 : IMPLEMENTATION

4.1 Hardware Implementation


The system power supply circuit is shown in Figure 4.1. An adapter is used to convert the
AC voltage from the main source (220V) to 12V DC. The 12V is necessary to power the conveyor
belt motor. Tow buck converters are used and their outputs were adjusted to 5v using a voltmeter
to read the voltage. One of them is used for powering the Raspberry Pi and the other components.
The other one is used for powering the servo motor; to prevent interference with the digital part of
the system. Then, the two buck converters’ input pins (IN+ and IN-) are connected with the
adapter’s terminals. The buck converters’ output pins (OUT+ and OUT-) provide 5V to the system.

Figure 4.1: Power supply circuit schematic circuit.

Figure 4.2 shows the system schematic circuit. Interfacing the servo motor with a
Raspberry Pi begins with the power supply. The servo motor requires a stable power supply to
operate correctly. Therefore, its power and ground wires are connected to the 5V and ground. Next,
the signal wire of the servo motor is connected to the Raspberry Pi's GPIO 21 pin. The Raspberry
Pi's GPIO pins can only supply a limited amount of current, which may not be enough to power
the conveyor belt DC motor. So, the L293D module is used to drive the conveyor belt motor due
to its ability to handle higher current and voltage requirements. The L293D module can handle up
to 1.2A of current per channel. The conveyor belt motor can be powered by 12 volt. Then, the
L293D module VIN pin is connected to the 12V, providing the necessary power for the module to
drive the motor. The GND pin of the L293D module is connected to the ground pin of the
Raspberry Pi. Then, the conveyor belt motor is connected to A+ and A- terminals on the L293D

28
module; these are the output pins that will supply power to the motor. The IN1 and IN2 pins on
the module are connected to the Raspberry Pi’s GPIO 17 and GPIO 27 pins respectively. The
L293D module offers bi-directional control of the motor, allowing it to rotate in both clockwise
and counter clockwise directions. It also offers movements control, allowing to stop it. Each of the
IR obstacle detector sensor modules has 3 pins; Vcc, GND and OUT. They are connected to +5v
and ground to operate. The output from the first IR sensor (in) which is located at the testing side
of the conveyor belt, is connected with the Raspberry Pi’s GPIO 20 while output pin of the second
IR sensor (out) which is located at the sorting side of the conveyor belt, is connected with
Raspberry Pi’s GPIO 16 pin. The user will be able to move and stop the conveyor belt manually
by using push buttons; they are used for moving the conveyor belt in forward direction and
backward direction, and stopping it. The OK button is used for system training purposes. Each
push button has 2 terminals, one is connected to the ground and the other is connected to the
Raspberry Pi’s (GPIO 3, GPIO 6, GPIO 13, and GPIO 19). The LED is used as an indication that
the system is working; it blinks once the system is switched on. Finally, the USB cam is connected
with the Raspberry Pi USB port.

Figure 4.2: Schematic circuit.

29
Figure 4.3 shows the hardware implementation of the Raspberry pi connections.

Figure 4.3: Hardware implementation.

Figure 4.4 shows the outer design of the hardware packaging.

Figure 4.4: Outer design of the hardware packaging.

30
The overall system design is shown in Figure 4.5

IR sensors

Servo motor

Sorter

Figure 4.5: Overall system design.

4.2 Software Implementation


This board is the heart of our programming project and allows us to run our code and
interact with it. In order to program the Raspberry Pi using the Thonny IDE, there are a few
essential things that we need to have; a computer, keyboard, and mouse. Secondly, we need to
have an operating system installed on the Raspberry Pi. The most common and widely used
operating system for Raspberry Pi is Raspbian, which is based on Linux. This operating system is
free, open-source, and specifically designed to run on the Raspberry Pi. We have downloaded
Raspbian image and flashed it onto a microSD card which is then inserted into the Raspberry Pi
board. Next, have installed the Thonny IDE on our computer. Thonny is a user-friendly integrated
development environment (IDE) that allows us to write, run, and debug our code. It supports
various programming languages, including Python. Then, we have connected the Raspberry Pi to
the computer remotely, making it easier to transfer our code and run it on the board. Then, we
wrote the code in the editor window which provides helpful features such as syntax highlighting,
auto-completion, and code navigation. Thonny also has a built-in debugger that allows us to step
through our code and find any errors or bugs. One of the key advantages of using Thonny IDE for

31
programming the Raspberry Pi is its ability to access and control the GPIO (General Purpose Input
Output) pins of the board.

Here is the Python code written in Thonny IDE and its explanation:

First part of code: this is for pins initializations; to determine which Raspberry pi GPIO pin
each component is connected to, and determine of it’s an input or output.

mfor=27
GPIO.setup(mfor, GPIO.OUT)
mrev=17
GPIO.setup(mrev, GPIO.OUT)
led=22
GPIO.setup(led, GPIO.OUT)
but1=5
GPIO.setup(but1, GPIO.IN,pull_up_down=GPIO.PUD_UP)
but2=6
GPIO.setup(but2, GPIO.IN,pull_up_down=GPIO.PUD_UP)
but3=13
GPIO.setup(but3, GPIO.IN,pull_up_down=GPIO.PUD_UP)
but4=19
GPIO.setup(but4, GPIO.IN,pull_up_down=GPIO.PUD_UP)
servo=21
GPIO.setup(servo,GPIO.OUT)
sensoro=20
GPIO.setup(sensoro, GPIO.IN)
sensori=16
GPIO.setup(sensori, GPIO.IN)

32
Second part of the code: this is for procedures definitions; such as moving the conveyor
belt motor forward, reverse, and stop. It also defines “checkforout” procedure; when the output IR
sensor detects an object, then the Raspberry Pi stops the conveyor belt motor, moves the servo
motor to push the object away to the sorting area, return the servo motor to its default location,
then moves the conveyor belt forward.

def forward():
GPIO.output(mfor, GPIO.HIGH)
GPIO.output(mrev, GPIO.LOW)
def reverse():
GPIO.output(mrev, GPIO.HIGH)
GPIO.output(mfor, GPIO.LOW)
def stop():
GPIO.output(mrev, GPIO.LOW)
GPIO.output(mfor, GPIO.LOW)
def setServoAngle(servo, angle):
pwm = GPIO.PWM(servo, angle)
def checkforout():
if outlist[-1]==1:
stop()
setServoAngle(servo,0)
setServoAngle(servo,140)
outlist.pop()
forward()

33
Third part of the code: this is a loop for training the system to sort the objects based on a
certain color and size.

cap = cv2.VideoCapture(0)
while True:
success, image = cap.read()
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
cv2.circle(image, (30, 180), 10, (hsv), 40)
cv2.imshow("color", image)
if GPIO.input(but4)== False:
forward()
if GPIO.input(sensori) == True:
stop()
if GPIO.input(but3)== False:
reverse()
if GPIO.input(but2)== False:
stop()
if GPIO.input(but1)== False:
stop()
reverse()
sleep(5)
stop()
GPIO.output(led, GPIO.HIGH)
forward()
break

34
Fourth part of the code: this is for sorting the object based on its color and size. The system will
determine the object contours to determine its area. If the object area is larger than 5000 pixel, it
will be accepted and sorted. Otherwise it’s considered as a small object.

while True:
success, image = cap.read()
mask = cv2.inRange(hsv, 0, 100)
result = cv2.bitwise_and(image, image, mask=mask)
countours, hierarchy = cv2.findContours(mask, cv2.RETR_LIST,
cv2.CHAIN_APPROX_SIMPLE)

for contour in countours:


x, y, wid, hit = cv2.boundingRect(contour)
if (wid * hit > 5000):
cv2.putText(image,"OBJECT ",(x,y),0,1,(b1,g1,r1),2)
obj="ok"
outlist.insert(0,1)
else:
obj="small"
outlist.insert(0,0)

Fifth part of the code: this part for system working when the user presses the forward or
reverse push buttons. Then, if the output sensor detects and object, it executes the procedure
“checkforout” defined before in the second part of the code.

if GPIO.input(but4)== False:
forward()
if GPIO.input(but2)== False:
stop()
if GPIO.input(sensoro)== False:
checkforout()

35
Sixth part of the code: this part for showing the image, the result, and the sensitivity
windows.

cv2.putText(image,obj,(50,50),0,1,(0,0,255),2)
cv2.imshow("image", image)
cv2.imshow("result1", result)
cv2.imshow("Sensitivity", hbl)
k = cv2.waitKey(100)

When we run the code, we had to train the system of the object’s color needed to be sorted.
Thonny IDE window will show three small windows; system sensivity of detecting the object color
adjustment, a video of the cam view, and the result after filtering the object image. In order to train
the system we should first place the object on the conveyor belt, then press “OK”. In a result, the
conveyor belt will be moved. Once the object reaches the camera view area (image window), we
should press stop. After that, we can adjust the object size and system sensitivity by the sliders
until the system accepts the object-detected color, and the filtering result shows the object as seen
in Figure 4.6. Then, we should press “forward” button to move the conveyor belt again. Once the
object reaches the sorting area, detected by the IR sensor, the Raspberry Pi will stop the conveyor
belt, send a command to the servo motor to move to push the object away by the sorter.

Figure 4.6: Thonny IDE window while system training for sorting a blue colored object.

36
If any object with different color is placed on the conveyor belt (its color doesn’t match the
trained one), Thonny window will display the result as can be seen in Figure 4.7; we can notice
that “none” appears in the image window. In this case, the object will not be sorted and the
conveyor belt will continue moving and the object will be moved away.

Figure 4.7: Thonny IDE window of object with different color and size.
When an object reaches the testing side on the conveyor belt, the IR sensor detects the
object if it matches the needed color or the size. When it reaches the sorting area, the IR sensor
detects it as shown in Figure 4.8. We can see that both the power and obstacle detection LEDs are
on.

Figure 4.8: The IR sensor detects the object at the sorting area.

37
If the object’s color matches the needed color or its size matches the adjusted size, the
Raspberry Pi stops the conveyor belt and sends a command to the servo motor to rotate. As a result,
the sorting arm will push the object away as shown in Figure 4.9. If the color doesn’t match the
needed color, or its size doesn’t match the adjusted size, the conveyor belt keeps moving.
Similarly, the system checks the object size, if it’s less than the adjusted area value, then it is
considered as a small object and wouldn’t be sorted and the conveyor belt keeps moving.

Figure 4.9: Sorting arm pushing the object.

38
The system working described above is presented in the flowchart shown in Figure 4.10.

39
Figure 4.10: system flowchart.

40
Chapter 5 : EVALUATION

5.1 System Features


1. The feature of Raspberry Pi that makes it ideal for objects sorting systems is its ability to
process large amounts of data in real-time. This is made possible by its powerful processor
and high-speed connectivity. The Raspberry Pi can handle complex algorithms and make
decisions quickly, making it perfect for sorting objects based on various criteria.

2. The compact size of Raspberry Pi makes it easy to integrate into existing sorting systems
without taking up much space. It can be connected to sensors and cameras, allowing it to
collect data and analyze it in real-time. This enables the system to make precise decisions
regarding the sorting of objects, reducing the chances of errors.

3. One of the key features of Raspberry Pi is its open-source software. This means that the
code used to run the system is freely available, allowing developers to modify and improve
it. As a result, the objects sorting system can be constantly updated and enhanced, ensuring
optimal performance.

4. The L293D module is a cost-effective option. It is relatively inexpensive and readily


available, making it a budget-friendly choice for projects that require motor control. This
also means that if the module gets damaged or burnt out, it can be easily replaced.

5. One of the most significant advantages of IR obstacle sensors is their ability to detect a
wide range of objects, regardless of their color or material. This makes them ideal for use
in object sorting systems, where different types of objects need to be sorted accurately and
efficiently. The sensor's ability to detect objects without physical contact also makes it
suitable for use in delicate manufacturing processes, where objects can be easily damaged.

6. Another crucial feature of IR obstacle sensors is their high speed and accuracy. These
sensors can detect objects at a distance of up to several meters in a matter of milliseconds.
Additionally, these sensors can function in harsh conditions, such as extreme temperatures,
humidity, and dust, making them reliable for use in challenging manufacturing
environments.

7. One of the key features of servo motors is their high precision and accuracy, which is
crucial in sorting systems as even a slight deviation can result in errors. These motors use

41
feedback control to constantly monitor and adjust the position of the moving parts, ensuring
precise and repeatable motion.

8. We have tested the system 100 times, the system accuracy resulted is 89%. Errors are
resulted in some tests due to the difference in light brightness.

5.2 Project Impacts


5.2.1 Economic

An automated sorting system can have a tremendous effect on the economic system.
Automation can significantly reduce the amount of labor required to complete a sorting task, which
can in turn reduce the cost of labor for the particular task. Automation can also increase the
accuracy and speed of sorting tasks, which can lead to a decrease in the amount of time and energy
required to complete the tasks. Additionally, automation can reduce inventory costs through a
decrease in the amount of time and energy required to track and maintain inventory. Finally,
automation can reduce the amount of waste created by manual sorting processes, resulting in a
decrease in the amount of waste materials that must be disposed of. All of these benefits can lead
to increased efficiency and cost savings for businesses, ultimately resulting in a positive impact on
the economic system.

5.2.2 Society

An automatic sorting system instead of manual sorting by humans would have a major
impact on society. On the one hand, it will significantly improve the efficiency of many processes.
For instance, in the logistics industry, the implementation of automated sorting systems has led to
faster delivery times and reduced labor costs. This, in turn, has resulted in a greater number of
products being available for purchase, allowing consumers to enjoy more variety and convenience.
On the other hand, the introduction of these systems has also had some negative effects. In
particular, it has resulted in job losses for those involved in manual sorting. Moreover, there is a
risk that automation can lead to greater inequality, as people in lower-paid roles are more likely to
be replaced by machines. Despite these potential drawbacks, automated sorting systems still offer
many advantages, as they are able to process large amounts of data more quickly and accurately
than human workers. Ultimately, they represent an important step forward in terms of improving
efficiency and reducing labor costs.

42
5.2.3 Environmental

Automated sorting systems can also reduce labor costs, which in turn reduces the amount
of resources used for employee wages. Additionally, automated sorting systems can help reduce
the amount of waste produced from packaging, as sorting machines are able to separate recyclable
material from non-recyclable material more efficiently than humans. Finally, the system’s
components have been chosen taking into consideration that they would have no bad effect on the
environment, will not endanger the environment, and don't release any negative or hazardous
pollutants.

43
Chapter 6 : CONCLUSIONS AND FUTURE WORKS

6.1 Conclusion
The image processing-based sorting system is designed to automatically sort objects based
on their color or size using a camera and image processing software running on a Raspberry Pi.
This system has the potential to greatly improve the efficiency and accuracy of sorting processes
in industries such as manufacturing and agriculture. We have tested the system using objects of
different colors multiple times to ensure consistent results. The system is able to accurately identify
and sort each object based on its color, without any errors or misclassifications. The system is able
to sort objects at a fast pace. The interface and controls of the system are user-friendly and intuitive,
allowing us to easily set up and operate the system.

6.2 Future Work


1. The system can be improved to be used for sorting objects based on different colors; then
the number of sorting arms should be also increased.
2. Enable the system to count the number of sorted objects.
3. Enable the system to sort the objects based on other features; such as shape.
4. A robotic arm can be used for placing objects on the conveyor belt instead of placing them
manually.

44
REFERENCES

[1] Patil, V.W. et al. (2017) Automatic Sorting Machine. IJARIIE, Volume 03, Issue 3, pp. 2254-
2262.
Available at: https://ijariie.com/AdminUploadPdf/Automatic_Sorting_Machine_ijariie5465.pdf.
[2] Shashikala.J. (2020). Automation of Object Sorting Based on Colour. Journal of University of
Shanghai for Science and Technology, Volume 22, Issue 10, pp. 17–19. Available at:
https://jusst.org/wp-content/uploads/2020/10/Automation-of-Object-Sorting-Based-on-
Colour.pdf
[3] Sifat. (2023, October 21). DEV Community. https://dev.to/shhossain/the-evolution-of-sorting-
algorithms-over-the-years-bubble-sort-to-ai-driven-sort-31pg
[4] Soans, Rahul & Fukumizu, Yohei & G R, Pradyumna. (2018). Object Sorting using Image
Processing. 10.1109/RTEICT42901.2018.9012110.
[5] Chauhan, A. H., Ukani, N., Yennewar, P. V., Sonaskar, S., Hiwanj, N., & Chakole, S. (2021).
Arduino Based Lemon Sorter Machine. International Journal of Research in Engineering and
Science (IJRES), Volume 9 Issue 7, 2021, PP. 01-05.
[6] Constantin, V., Dana, R., & Rizescu, C. (2017). Colour based sorting station with MATLAB
simulation. In MATEC Web of Conferences (Vol. 121, p. 08004). EDP Sciences.
Available at: https://www.matec-
conferences.org/articles/matecconf/pdf/2017/35/matecconf_mse2017_08004.pdf
[7] Sanga, A., Shinde, S. and Shaha, S. (2017) Fruit sorting robotic arm based on image
processing. International Journal of Recent Technology and Engineering (IJRTE), Volume 6
Issue 4, PP. 07-10. Available at: https://www.ijrte.org/wp-
content/uploads/papers/v6i4/D1701096417.pdf
[8] Rudresh.H.G, Prof. S. (2017). Colour sensor based object sorting robot – IRJET, Volume 4
Issue 8, PP. 504-507. Available at: https://www.irjet.net/archives/V4/i8/IRJET-V4I891.pdf
[9] BARMAN, S. A., MONDAL, S., SARKAR, A. (2022). Color Sorting Machine using
Microcontroller. https://rcciit.org/students_projects/projects/ee/2022/GR15.pdf
[10] Suryawanshi, S., Sonone, S., Patil, P., & Parbhane, P. (2017). Color Sorting Robotic Arm.
International Research Journal of Engineering and Technology (IRJET) Volume, 4.

45
[11] Abdul Aziz, M. F., Bukhari, W. M., Sukhaimie, M. N., Izzuddin, T. A., Norasikin, M. A.,
Rasid, A. F. A., & Bazilah, N. F. (2021). Development of smart sorting machine using artificial
intelligence for chili fertigation industries. Journal of Automation Mobile Robotics and
Intelligent Systems, 15(4), 44-52.
[12] Nayyar, Anand & Puri, Vikram. (2015). Raspberry Pi-A Small, Powerful, Cost Effective
and Efficient Form Factor Computer: A Review. International Journal of Advanced Research
in Computer Science and Software Engineering (IJARCSSE). 5. 720-737.
[13] Balogh, Z., Magdin, M., & Molnár, G. (2019). Motion detection and face recognition
using raspberry pi, as a part of, the internet of things. Acta Polytechnica Hungarica, 16(3),
167-185.
[14] H. K. Kondaveeti, D. Bandi, S. E. Mathe, S. Vappangi and M. Subramanian, "A Review
of Image Processing Applications based on Raspberry-Pi," 2022 8th International Conference
on Advanced Computing and Communication Systems (ICACCS), Coimbatore, India, 2022,
pp. 22-28, doi: 10.1109/ICACCS54159.2022.9784958.
[15] Shilpashree, K. S., Lokesha, H., & Shivkumar, H. (2015). Implementation of image
processing on Raspberry Pi. International journal of advanced research in computer and
communication engineering, 4(5), 199-202.
[16] Teja, R. (2021) What are the differences between Raspberry Pi and Arduino?,
ElectronicsHub. Available at: https://www.electronicshub.org/raspberry-pi-vs-arduino/.
[17] Raspberry Pi. Available at: https://static.raspberrypi.org/files/product-
briefs/200521%20Raspberry%20Pi%204%20Product%20Brief.pdf
[18] Industrial Quick Search, DC Motor: What Is It? How Does It Work? Types, Uses.
Available at: https://www.iqsdirectory.com/articles/electric-motor/dc-motors.html.
[19] Agarwal, T. (2019) H Bridge Motor Control Circuit using L293D IC, ElProCus.
Available at: https://www.elprocus.com/h-bridge-motor-control-circuit-using-l293d-ic/.
[20] LC technology L293D Dual H-Bridge Module 1A opto-coupled arduino (no date) Flux
Workshop. Available at: https://fluxworkshop.com/products/bmaa100008-l293d-inc-opto-lc-
blue?variant=32458609852476.
[21] Industrial cameras, USB Camera | Industrial cameras - Basics and tips. Available at:
https://www.industrial-camera.com/usb-camera.htm.

46
[22] Davis, N. (2017) The advantages of using a USB webcam, Small Business - Chron.com.
Available at: https://smallbusiness.chron.com/advantages-using-usb-webcam-68652.html
[23] Monster, C. (2020, July 9). Creative Live! Cam Sync 1080p available now for less than
S$70. HardwareZone.com.sg. https://www.hardwarezone.com.sg/tech-news-creative-live-
cam-sync-1080p-available-now-less-s70
[24] Kekre, A. (2021, December 14). IR Infrared Obstacle Avoidance Sensor with Arduino -
Aditya Kekre - Medium. Medium. https://medium.com/@kekreaditya/ir-infrared-obstacle-
avoidance-sensor-with-arduino-714837ad9ef5
[25] Servomotors, Servo motor with high efficiency for industrial use - OME Motors. Available
at: https://www.omemotors.com/electric-motors/servomotors
[26] What is a servo motor? Lin Engineering. Available at:
https://www.linengineering.com/what-is-a-servo
[27] What is an AC DC power adaptor and how does power adapters work ? (2022) BEI Power.
Available at: https://www.beipower.com/what-is-an-ac-dc-power-adaptor/.
[28] DC/DC converters: Devices for converting to a lower voltage - technical articles (no
date) EEPower. Available at: https://eepower.com/technical-articles/dc-dc-converters-
devices-for-converting-to-a-lower-voltage/#.
[29] DC-DC Buck Converter Step Down Module LM2596. Available at:
https://techmaze.romman.store/product/99187534.
[30] Khan, A. (2022) What programming language does Raspberry Pi use? Available at:
https://linuxhint.com/what-programming-language-raspberry-pi-use/.
[31] Zahid, H. (2022) How to program the Raspberry Pi using the python. Available at:
https://linuxhint.com/program-raspberry-pi-4-using-python/.
[32] Annamaa, Aivar. (2015). Introducing Thonny, a Python IDE for learning programming.
117-121. 10.1145/2828959.2828969.

47

You might also like