Single-line automated sorter using mechatronics and machine vision system for Philippine table eggs

An automated single-line table egg sorting machine that integrates machine vision and mechatronics principles was developed in this study. The machine was fabricated using low cost and locally available materials. The developed machine was composed of the feeding unit, computing unit and the sorting unit. The conveyor was powered by a 12V DC geared motor, and the sorting arm was actuated by a DC servo motor which positions the arm. A machine vision software, EGGSoTiC, was used in the sorting of the table eggs – moving through a conveyor at 13 cm-s -1 . Test for similarity of readings revealed that the developed machine is capable of yielding consistent results with low values of coefficient of variation ranging from 0.38 to 0.85 mm 2 and 0.42 to 0.94 g for the projected area and estimated weight, respectively. Results of dynamic test for 100 table egg samples indicated that the machine could sort table eggs with an accuracy of 91% at 2.52 seconds per sample, yielding a projected capacity of 1,426 eggs per hour. Results also indicated that there were no large errors in the estimation of weights yielding a root mean square error of 1.90 g which is not significantly higher than the bias of 0.93 g.


INTRODUCTION
Table eggs are one of the poultry products popularly consumed in the Philippines.In 2016, the production of table eggs reached 461,719 metric tons, 3.86% higher than the previous year.The farm gate price of table eggs was 4.31 pesos (PhP) per piece during this year.This production grossed 46,264.34 million pesos (PhP) at current price, posting an 8.36% increase versus the previous year, with the CALABARZON region contributing 30% of the country's total egg production (PSA, 2017).
Grading of table egg products are being done to avoid losses in the marketing of such products.In the Philippines, table egg products in public markets and supermarkets are usually sorted based on the quality and the size.Quality of the eggs includes parameters such as presence of dirt, cracks, as well as internal characteristics of the eggs.On the other hand, grading based on size  1).Most egg farmers in our country follow the prescribed standard of Bureau of Agriculture and Fisheries Products Standard (2005).And mostly, sorting is done through manual weighing of table eggs using a weighing scale.The manual means is still employed especially by small scale egg farm laborers.This method of sorting requires handling of eggs with care to avoid cracking or breaking of the eggs.In the absence of digital weighing scale, weighing becomes subjective as the weight readings will depend on the observer.Errors in readings related to operator fatigue and judgment increase when analog weighing scales are used.Moreover, the manual method becomes more costly and impractical especially when dealing with larger number of table egg products.
In addition, handling egg with bare hands introduces moisture to the egg's surface which may provide a suitable breeding ground for bacteria (USDA, 2000).Prolonged contact by humans to fresh eggs poses risk of possible contamination of Salmonella enteritidis which are mostly present on the egg's surface as these pass through the cloaca of chickens.Farm personnel especially those from backyard farms are often the victims of such contamination due to lack of proper hygienic procedures.
Increased contact with human hands exposes eggs to cumulative fatigue due to manual collection, sorting and packing which also raises the chance of acquiring cracks on the shell.Internal contamination after penetration of Salmonella from the surface may occur.Such occurrence poses risks to the consuming public (Murchie et al., 2008), especially with the increased desire of the consumers for raw and unprocessed eggs, potential risk of salmonellosis Quilloy et al. 919 (Whiley and Ross, 2015).In Australia, the impact of eggrelated salmonellosis was estimated to be 44 million dollars (Samiullah et al., 2013).Automation of collecting processes and mechanization of sorting in high-end egg farms are able to minimize contact with human hands.Commercial semi-automated egg graders integrate mechatronics in their system.Mechatronics, the integration of mechanics, control and electronics (Naidu, 1995), has been explored for automation of most processes.Its application with machine vision has improved the efficiency and productivity of agricultural machines (Billingsley and Bradbeer, 2008).
Through the use of microcontrollers and integrated circuits, the transfer of information to the computer and actuation of the mechanical parts became very efficient.
Assimilating mechatronics with the design of these commercial semi-automated egg graders, these machines are able to determine the weight of each egg by using load cells.Mechatronics is also incorporated to actuate grading arms for sorting.
Development of mechanized egg sorters provides a solution for these issues in the manual method of egg sorting.However, the price of each mechanized sorter is an impedance especially for small scale farmers.Likewise, mechanized graders which make use of strain gauges, like other digital scales, require frequent calibration to maintain accuracy in readings.Machine vision can address these issues faced both by manual method and that of existing mechanized graders.Aside from using computational techniques in determining weights, it can provide an accurate and efficient evaluation of the eggs.
Machine vision has been used for sorting agricultural products.There has been an increase in the use of visual inspection systems parallel to technological development over the last decades as a means of replacing human inspection (Gomes and Leta, 2014).In 2000, Bato et al. (2000) explored the use of machine vision to sort strawberries where they developed a software that uses machine vision for grading and a robotic arm picking sorted fruits.Li et al. (2012) conducted a study that uses machine vision for the identification of micro-cracks in egg shells, obtaining 100% accuracy.Moreover, a study conducted by Mohana and Prabhakar (2014) investigated a novel technique of sorting dates using shape and texture.Their experiment exhibited high accuracy in sorting.
In addition, Quilloy and Bato (2015) developed a machine vision software for static sorting of Philippine table eggs, with 92% accuracy in sorting.George (2015) also used machine vision in his study focusing on the development of a sorting system for multiple fruit and vegetable.Furthermore, a study conducted by Soltani et al. (2015) discussed the application of machine vision based on pappus theorem and artificial neural network on  Machine vision was also applied in a system for detecting fertile eggs in the incubation industry.In 2016, Arakeri and Lakshmana developed a computer vision-based fruit grading system for quality evaluation of tomato, which resulted to 96.47% accuracy.
In a study conducted by Hashemzadeh and Farajzadeh (2016), detection accuracy was noted to be high at various incubation stages.This implied that the proposed system was highly reliable and applicable.In a similar study conducted by Hashemzadeh (2017), machine vision hardware was developed which integrated the vision system with neural network and support vector machine as classifiers.
Results of their evaluation showed that support vector machine learning is better than the performance of neural networks as classifiers of the machine vision system.The use of machine vision has been employed too in grading grafting seedlings in a study carried out by Tian et al. (2017).A success rate of 98% was achieved exhibiting that their developed vision system was helpful in improving the grading accuracy and efficiency.Such studies yielded successful results in their sorting and grading capabilities.This study aims to develop a singleline automated egg sorting machine using machine vision and open source mechatronics.Specifically, it aims to evaluate the developed machine based on its dynamic performance.

Software for egg sorting machine
The machine vision software used on this study was the Automatic Egg Sorting Software 2.0 (EGGSoTic), developed by Quilloy and Bato in 2015 (Figure 1).The software made use of the adjusted weight classification (Table 2) which was also based on the standard provided by the BAFPS.The adjustment was made to eliminate the overlapping values in the existing standard.The software was also designed to accommodate the most common sizes of table eggs in the market which include: jumbo, extra-large, large and medium.The capability of the software to interface microcontrollers allowed the software to control and actuate the mechanical parts of the developed machine.The software communicated with the microcontroller through the serial port.

Machine vision setup
The typical machine vision setup generally consists of a camera, light source, and a computer equipped with frame grabber (Chen et al., 2002).A single-line automated table egg sorting machine was developed from low-cost and locally available materials.The machine was composed of the feeding unit, computing unit, and sorting unit.The component layout of the machine is shown in Figure 2.

Mechatronic components
For the automation of the feeding and sorting units of the developed machine, a Gizduino 168 microcontroller development board was used (Figure 3).It is a derivative of the open source Arduino board.The Gizduino 168 controls the conveyor motor of the feeding unit as well as the sorting arm motor of the sorting unit depending on the commands sent by the EGGSoTic software.A 12V brushed DC motor was used for the feeding unit.Using L293D motor driver IC, the rated speed of the conveyor assembly was set 13 cm-s -1 .For the sorting unit, a 180 degree metal gear servo was used.The Gizduino 168 actuates the servo to position the arm for sorting the eggs to four different size classes: medium, large, extra-large and jumbo.The sorted table eggs will then be relayed to the receiving tray.

Dynamic test for similarity of readings
Thirty table egg samples were used to test the consistency of the automated table egg sorter.Each table egg sample was fed into the machine through the conveyor running at 13 cm-s -1 .Ten trials for each sample were conducted.The mean and standard deviation  (SD) of the projected area were obtained and were used to compute for the coefficient of variation (CV) to measure the relative variability of the readings.A value near zero (0) will indicate low dispersal of values and will yield a more precise estimate.

Dynamic test for accuracy of the automated table egg sorter
One hundred (100) table egg samples were continuously fed into the machine through conveyor running at its rated operating speed of 13 cm-s -1 .The samples were automatically sorted by the machine through the EGGSoTic based on the weight of the samples.The weights of the samples were then obtained using OHAUS GT41000D digital weighing scale.The performance of the developed automated table egg sorter in terms of accuracy was evaluated based on the BAFPS standards for classifying table eggs.Sorting accuracy was determined as: (No. of correctly classified samples) Accuracy = × 100 Total no. of samples where accuracy is expressed in percentage.The numbers of incorrectly classified samples as well as the classification to which these samples were mistakenly identified were taken into account.The output of the machine's classification on each sample was determined and compared with the output of manual sorting of the same samples.The root mean square error (RMSE) of the readings as well as the bias was obtained to compare the predicted or estimated weight with the actual weights of the samples.

Sorting time and capacity
The time required to sort 100 table egg samples were obtained and compared with that of manual sorting.The actual capacity of the developed machine was determined by projecting the obtained total operating time per sample to the total number of table eggs that can be sorted in one hour.This was computed using the formula: total number of eggs Capacity = time where capacity is expressed in eggs per hour.The actual capacity of the machine included the time from loading up to sorting into the receiving tray.Likewise, the obtained capacity was compared with that of manual sorting of the 100 table eggs.

Feeding unit
The feeding unit was comprised of the feeder, main frame and conveyor.This unit composed the bulk of the machine, and was responsible for moving table egg samples into the vision chamber.The main frame which holds the components of the machine together (Figure 4a) was constructed from bent and ribbed aluminum sheets which were fastened using rivets and metal screws.During the actual run, the machine was noted to be stable, though due to its light structure, the main frame exhibited vibrations.Table egg samples are introduced into the machine through the feeder.The feeder was constructed from polyvinyl chloride (PVC) pipe which was trimmed and fastened onto the conveyor assembly (Figure 4b).The feeder was attached at an angle which allowed rolling of table egg samples into the conveyor by gravitational pull.It was observed that samples tend to be stuck on the feeder if the angle of inclination of the feeder is too small.A provision for adjusting the angle of the feeder was integrated in the mechanism to address the issue.
The single-line conveyor was constructed to move table egg samples from the feeder into the vision chamber (Figure 4c).The frame of the conveyor was constructed from ply board which was fastened together to form a Uframe structure.Sidings of the conveyor frame were drilled with holes for securing ball bearings and other shafts.Galvanized sheets were used to cover the sidings of the conveyor and to protect the conveyor or the operator.The narrow width of the conveyor frame restrains the egg samples from being dislocated along the belt.
The belt of the conveyor was painted with black color to produce a contrast between the colors of the sample and the background which was necessary to yield a successful segmentation.It was actuated by a gear motor assembly, which was connected to the Gizduino 168.The assembly was attached to a shaft which drives the belt to move samples.Spacers made from wood were installed to separate each sample and also reduced the chances of the eggs being displaced.Metal shafts fastened on the conveyor frame were used to support the belt.These act as rollers for the belt to glide over.However, it was noted that the belt tends to sag on the area between the shafts when loaded with the samples, thus, causing a slight vibration on belt when the conveyor is moving.This, in turn, causes small displacement of the table egg samples.Actuation of the conveyor motor was initiated by the Gizduino 168 platform which received commands from the computer.The Gizduino 168 toggles the state of the pin to which the conveyor motor was connected.The receiving algorithm of the microcontroller is outlined in Figure 5.

Computing unit
The computing unit contained the vision chamber of the machine, where extraction of projected area and estimated weight was done and where the imaging device and light source are held (Figure 6).The image processing done within the computing unit included the following: (1) Importing of images using camera (2) Analyzing and manipulating the image using a software (3) Reporting the output based on the analysis (Raj and Swaminarayan, 2015).
The camera holder was installed such that camera will be accessible for adjustment.In addition, light source is needed as the images are dependent on light (Kopparapu, 2006).It was composed of light-emitting diode (LED) installed inside the frame of chamber to provide lighting for the vision chamber.The chamber was constructed from galvanized sheet with a thickness of 0.4 mm.Furthermore, the camera stand which holds the camera was designed to allow adjustment of camera height to yield a viewing area enough to contain the table egg sample.The software, EGGSoTic, is the core of machine vision system, this is where decision making is situated.The software made use of the equation: est.wt = Area x 0.04 + (-7.68)where est.wt. is the software's estimated weight of the egg sample and Area is the projected area as computed by the software (Quilloy and Bato, 2015).This equation was used in the software for estimating the weights of the table egg samples.Enabling the dynamic or online mode on the software allowed it to take control of the actuation of the conveyor belt as well as image acquisition and positioning of the sorting arm.The software awaited the conveyor belt to position the table egg sample inside the vision chamber.Then, the image of the sample was automatically obtained and processed by the software.The processed image was then used as basis for the position of the sorting arm according to the equivalent weight classification.

Sorting unit
The sorting unit was comprised of the sorting arm and the receiving tray.The sorting arm (Figure 7a) was constructed from ribbed aluminum sheet for durability and lightness and was installed at the end of the conveyor belt after the vision chamber.A DC servo motor allows the sorting arm to be positioned at different angles accurately.Depending on the classification of the sample as yielded by the software, the Gizduino 168 accurately positions the arm.To reduce chances of breakage of samples, the surface of the sorting arm was provided with cushion pads.Moreover, the sorting arm was installed at an angle such that the table egg samples roll down to the receiving tray (Figure 7b).The receiving tray was constructed from a sturdy board and has a dimension of 585 x 610 mm.The tray was provided with four divisions for separation of table egg samples into four categories: medium, large, extra-large and jumbo.Each division had a width of 110 mm.The tray was constructed separately from the machine to facilitate easy transport of the sorter.The current design of the receiving tray, having a slight inclination at the receiving end, allows the table egg samples to continuously roll to the opposite end of the tray.

Test for similarity of readings
A test for similarity of readings was conducted to assess the capability of the developed automated table egg sorter in yielding consistent results on dynamic mode.Results of analysis showed that the minimum and maximum values of standard deviation (SD) for the projected area were 7.32 mm 2 and 17.09 mm 2 , respectively.For estimated weight, the minimum value of SD was 0.29 g while the maximum value was noted to be 0.68 g.Moreover, minimum and maximum values of the coefficient of variation (CV) for projected area were determined to be 0.38 and 0.85%, respectively.For the   estimated weight, a CV value of 0.42% was noted to be the minimum and 0.94% was the observed maximum value.Results indicated that for the 30 samples tested, there was a low dispersion of readings both on the projected area and the estimated weight.The low relative variability shows that the developed automated table egg sorter is capable of yielding precise readings.

Dynamic sorting accuracy
Results obtained from test for dynamic sorting accuracy (Table 3) using 100 samples showed that the developed machine had an overall sorting accuracy of 91%.It was noted that errors were more likely to occur on weights falling near the border line between two adjacent weight classifications.As shown in  significantly higher than the bias of 0.93 g.

Sorting time and actual capacity
The developed machine was able to sort 100

Comparison of machine performance with existing farm operations
In comparison with manual means of grading, eggs can be sorted by a skilled egg farm laborer at an average of two seconds per sample which includes weighing only.Additional time is required to put the eggs into their respective classification, thus having an average net sorting time of three seconds per egg.For an average or inexperienced egg farm laborers, the time to grade eggs is expected to be higher.Both the automated and manual methods of sorting were noted to require only one person.

Conclusion
Machine vision and mechatronics were used in the development of an automated single-line table egg sorting machine capable of estimating weights.The machine consisted of a feeding unit, computing unit and sorting unit.The feeding unit contained the main frame, feeder and conveyor.This unit comprised the bulk of the machine.The computing unit was composed by the vision chamber where image acquisition for processing takes place.The sorting unit was comprised by a sorting arm and receiving tray.EGGSoTic software designed for sorting table eggs was used in the study.The software was installed on the computer which was interfaced with the developed machine.The software was used to control the components of the machine.It was also used to send commands to the Gizduino 168 microcontroller development platform that actuates the machine's conveyor and sorting arm.
The developed prototype was subjected to a test for similarity of obtained readings, yielding low CV values both on projected area and estimated weight.The low relative variability implied that the developed automated table egg sorter is capable of yielding precise readings.Moreover, the machine as evaluated for dynamic performance by loading table egg samples, performing real time processing, and allowing the machine to sort the samples into the receiving tray.It was noted that the machine had a success rate of 91% in sorting 100 samples.Further analysis revealed that there were no large errors in the estimation of weights yielding a root mean square error (RMSE) of 1.90 g which is not significantly higher than the bias of 0.93.
The machine exhibited a sorting time of 2.52 seconds per sample, yielding a projected capacity of 1,429 samples per hour compared with manual sorting by a skilled laborer, where the average sorting time was about three seconds per egg sample or 1,200 eggs per hour projected capacity.Though the difference in the sorting time of the developed machine and manual sorting was observed to be small, the machine is considered to be more efficient as it is not subject to experiencing fatigues or stresses brought about by repetitive tasks.This suggests that the developed machine is more efficient than manual sorting.In terms of per hour capacity, the developed automated table egg sorter yielded higher than that of manual sorting.
In manual grading of eggs, the losses due to cracking of shells could be avoided by improving the handling of egg products during weighing and sorting, but at the expense of additional time to do the operation.In contrast, the developed table egg sorting machine was able to perform the sorting operation of 100 samples without cracking the eggs.
Manual weighing and sorting of table eggs exposes these products to increased contact with human hands, especially when the manual grading process is conducted more than once to verify if sorting was accurate.This could lead to increased of crosscontamination of eggs.Using the developed machine, the eggs are exposed to minimal contact with human hands.As soon as the eggs were placed into the feeder, the eggs were moved to the receiving tray ready for packaging.Thus, it could reduce the number of times these eggs come in contact with human hands.

Figure 2 .
Figure 2. Component layout for the automated table egg sorting machine.

Figure 8 .
Figure 8. Relationship between estimated weight and actual weight.

Table 1 .
Weight classification of table eggs in thePhilippines(BAFPS, 2005).to the weight of each egg.It is necessary to maintain uniformity in size of eggs since it contributes to the profits of the egg industry.According to the Bureau of Agriculture and Fisheries Products Standards (2005), table eggs can be classified into eight (8) categories.They have provided a standard for the weight classification indicating the weight range for each category (Table

Table 2 .
Adjusted weight classification of table eggs.

Table 3 .
Dynamic sorting performance of the automated table egg sorter.

Table 4 .
Accuracy in sorting.