Customized sorting and packaging machine

India is a country which has a cornerstone of agriculture. And as it comes to fruit/vegetable sorting and packaging in India, human labor has been a vital part. With manual hand picking, it is a very laborious task to classify the quality of fruits/vegetables and simultaneously pack them. One leading-edge technology for the fulfilment of this purpose is ‘Image Processing’ technology which is extremely fast and cost-efficient. Our whole idea revolves around the fact that each fruit will be inspected, sort and simultaneously packed. For the same, a low cost automated mechatronic system has designed consisting of a solitary mechanical arrangement, which is controlled and synchronized through electronic components. Fruits/vegetables are sorted as high-quality and low-quality on the basis of physical appearance and weight. For this, a suitable algorithm is designed using the Open CV library. And the sorting is done using Arduino Uno and Raspberry pi. Hence the aim is to develop a sorting and packaging facility that can be established at the very root level itself which will be economically compact and accurate and will give more justice to farmers.


INTRODUCTION
The agro-climatic and atmospheric conditions of our country are perfect for agriculture. Our country's economy is also a preponderantly agricultural-based economy. Most of all kinds and varieties of agriculture can be seen here. Agriculture promotes 65% of the workforce and earns 20% of our exports. India is the extensive producer of fruits in the world (45 million tonnes) with a global share of over 11% and the secondlargest producer of vegetables (81 million tonnes) with a worldwide share of over 16%. The automation of the fruit/vegetable sorting and packaging industry is one of the important milestones in this market. Farmers do traditional scrutiny of quality and handpicking to sort and grade fruits/vegetables. But these have many liabilities like sluggishness, time-consuming, and irreconcilable [1]- [3]. The increasing need for processed fruits/vegetables often acts by decreasing the processing and packaging time of these fruits/vegetables. By decreasing the processing cycle and utilizing automated machinery for fruit/vegetable sorting and packaging it can often be achieved [4]- [6]. So, the use of automated machinery has finally decreased the processing time and increased the quality of fruits/vegetables and products manufactured with this [3]- [5]. In spite of the fact that automatic machines are available to ease the issue, the problem is that they have a very extensive set up which raises the cost [7]- [10]. Hence my vision is to develop a system that is economical and efficient so that every single fruit/vegetable farmer can set up his own fruit/vegetable sorting and packaging facility and will TELKOMNIKA Telecommun Comput El Control  Customized sorting and packaging machine (Ashish Bhatnagar) 1327 avail himself of his own market, bringing self-reliability to farmers. Initially, the system is focused on the sorting and packaging [11]- [15] of apples on the basis of physical appearance and sizing (weight and diameter). But can also be used for other spherical fruits/vegetables such as pears, oranges, and tomatoes.

STRUCTURE DESCRIPTION
The whole design of the machine is based on a simple ideology "of making things cheaper and simple". The structure of the machine is divided into three sections which are dependent on the process, but structure wise it is independent of each other that makes the whole machine easy to relocate from one place to another. The frame of the machine is made up of Marandi wood (Melia azedarach) or white cedar timber due to ease on machining, also it is resistant to decay and termite properties, which not only have given a rigid structure but also have shown steadiness in drilling holes. While operation it didn't require high tolerance and can be worked on low tolerance to achieve goals.
The alignment section is the initial part of the assembly where fruits/vegetables are poured onto the conveyor belt and all apples start moving. But to go to another section it requires that fruits/vegetables should be aligned properly. Hence, two flanges of length 49.28 cm and angle 21.24˚ from the horizontal axis (when seen from top view) as shown in Figure 1, makes a nozzle like structure with converging section (inlet=36 cm and outlet=15 cm) [16], [17]. Rollers are made up of polypropylene rods which are very cheap and light in weight. Each roller has a 15 mm hole is drilled throughout the propylene rod. At the periphery of each roller, a boring is done on both sides, which is equal to the outer diameter of the bearing (6202) used. A rod is passed through rollers and pillar on which the rollers are mounted to fix the rod, this makes the driver roller of the conveyor. The driving roller is designed with a twist, where shaft which is to be passed from the roller is bisected into two equal parts. First part is centrally bored so that the motor can be directly fixed and a conveyer belt is placed over both the rollers.
The sorting section is one the main part of the assembly which acts as a decision-maker [18]- [22] for the next process. To transfer the apple after scanning, forward angular movement is required about an instantaneous center which sends the apple to the next station, for that motion, a CG rod is passed through the center, which performs two functions initially, it is balancing the structure and also connected with the motor which will attract it towards itself to perform clockwise instantaneous motion. The packaging section is similar to the alignment section, the only difference is that it has a path decider deflector of length 25.74 cm as shown in Figure 1 which is controlled upon the feedback of the sensing section. This deflector is connected with the servo motor and the servo motor moved as per the signal receives from Arduino UNO and accordingly, fruits are dropped in the packaging cartoons. Figure 2 shows the proposed design of the customized sorting and packaging machine which can sort and pack various spherical fruits/vegetables such as pears, oranges, and tomatoes. Figure 3 shows the sequence diagram of aliging section and Figure 4 shows the sequence diagram of inspection and packaging section which should be controlled through a synchronized arrangement of Arduino UNO and Raspberry Pi along with servo motors, IR sensors and DC motors with a motor driver module i.e. L293D which is based on H-Bridge circuit. Firstly in the conveyor and aligning section fruits/vegetables are put on the conveyor belt, it will move along with the conveyor and passes through the two flanges which align each fruit/vegetable in a single line and then the fruits/vegetables goes towards inspecting platform of the inspection section, consisting of a camera at the top, two rollers which rotate each fruit/vegetable at 360 0 , and IR sensor which detects the fruit/vegetable on the inspecting platform and servo motor connected to a CG rod which tilt the fruit/vegetable towards the conveyor of inspecting section and simultaneously pack them using a synchronous packaging arrangement consisting of a deflector which can be move using servo motor and pack each fruit in an ordered arrangement.  Figure 2 also shows the inspecting platform of the inspection section, we can also call it as black-box because inside, whole box is totally black and illuminated with lights with a focused beam. In this section, there are two rollers that rotate the fruit/vegetable in 360 0 such that the camera can take images of the whole fruit/vegetable. There is an IR sensor in the middle of the two rollers which detects the presence of fruit/vegetable on the inspecting platform [18]- [22]. Now, as soon as the presence of fruit/vegetable is detected the camera starts taking five images of the fruit/vegetable in such a way that the five images will cover the maximum area of the fruit/vegetable, as the camera and rollers are both synchronized by the raspberry pi and Arduino UNO. Now the images are processed by the raspberry pi using an algorithm that is designed in Open CV library of python. Now, a servo motor is attached in the inspecting platform which tilts the inspecting platform towards high and low-quality packing conveyors and the fruit/vegetable will packed [23]- [25].

PROPOSED IMAGE PROCESSING ALGORITHM
When an image is captured by the camera than every image will be simultaneously processed using the proposed algorithm and an output value is obtained. The proposed algorithm has been designed in python using open CV and numpy libraries [5], [6]. Here, the concept of changing color spaces and object tracking is used through which a range of colors other than the range of colors that we need to detect has been masked using Bitwise-AND operation. Figure 5 shows the flow chart of the proposed image processing algorithm in which − Using the function imread an image will be read which is stored in the working directory and store the image in a variable. − Now the image will be scaled and resized, so for this OpenCV comes with a function. Now for this, a scaling factor has to be specified. − Now the image will convert from BGR to HSV color-space because it is easier in HSV to represent any color than in BGR color-space [13]- [15]. RGB is an array matrix of color-space pixels, where each color pixel is a trio corresponding to the red, green, and blue components of an RGB image at a specific spacial location wheare as in HSV format it divides the color into 3 components hue, saturation, and value. (hue) differentiate among the perceived colors, such as red, yellow, green, and blue, (value) represents the brightness of a color and (saturation) refers to how much the amount of white light mixed with a hue [17]. − Now, with the use of Bitwise-AND operator and the upper and lower threshold value we will mask those values which we do not require [18]- [21]. And the discarded colors are the greenish, yellowish or some black spots, these kinds of colors are discarded or masked. − Now, after the Bitwise-AND operator is used the output image is a black and white image, which means the matrix of the image contains only zero and one as elements. The discarded portion is white and the rest are black. So, we can calculate how much white part is present in the image, then we can identify how much good an apple will be. So, by using a numpy array add the matrix of the output image, all the ones will be added [22]- [25]. And we get a value i.e. quality score at the output. Now as higher as this score is, the more bad quality fruit/vegetable it will be.

Materials and methods
Through this machine, we can sort and pack any kind of spherical fruit but initially, apples are used in this experiment which we bought directly from the market. The quality of the external appearance of apples is classified into two categories: high, A, where more than 60% of the surface is deep red and B, low, where less than 60% of the surface is red. Fruit sorting procedure is given below: At first according to the grading criteria the samples are sorted manually into two groups (A and B), and 30 typical samples are taken from each group which makes one complete set of 60 apples in which 30 are from both category. The experiment will be done into three sets, so total 180 apples. At a time one set will be passed, which has been shown in Tables 1  and 2. Now, secondly, start the fruit sorting system and the processing module begins to work. Set 1 will be put on the conveyor line, all 60 apples will be processed and sort. When one set is complete another set i.e. Set 2 will be put on the conveyor line and same as Set 3. The processing results will be shown in Table 1

Classification result of apple
The classification of apple results is shown in Table 2. The result shows that very small part of apple surface is ungoverned, so some part of the apple is invariant during processing due to lighting conditions. The result of the processing system is shown in the Figure 6.

Quality score analysis
When all 180 apples where processed so for each apple a quality score should be calculated based on the processing algorithm implemented in the processing section. Figure 7 shows the quality score graph of all 180 samples. It is clearly shown from graph that the points below 200000 are so close to each other, while the points above 200000 are least congested. Now on comparing the results with the manual sorting we can conclude that those apples who has a quality score of below 200000 will be high quality and those having quality score above 200000 will be of low quality. Hence, 200000 can be taken as quality threshold.

CONCLUSION
An automatic, synchronized and customized fruit/vegetable sorting and packaging system has introduced in this paper. It aligns each fruit in a single line; inspect them from 360 o view, according to the predefined standards. Sort high-quality and low-quality products based on the quality score and concurrently pack them separately without any human intervention.