2. Materials and Methods
The experimental automatic apple sorting machine was designed as a compact, modular system for real-time, non-destructive, continuous assessment of fruit quality indicators and their classification into product categories. The machine's design is targeted at small and medium-sized farms and educational and research laboratories, which determine the requirements for size, energy efficiency, and process simplicity while maintaining sufficient accuracy and sorting performance.
The machine's supporting structure is a welded spatial frame made of 50 x 25 x 2 mm steel profile. The overall dimensions of the unit are 2500 x 1350 x 1200 mm (length x width x height). The frame includes longitudinal and transverse stiffeners to ensure stability under dynamic loads and vibrations during operation. The fasteners are made of carbon steel, using 8 mm diameter bolts, and the rated load of the fastening points is up to 500 kg.
The developed machine is shown in
Figure 1. It includes the following functional units: an apple feeding and positioning module, a conveyor, a visual inspection zone, an image processing unit, and a sorting module. Apples are fed onto the conveyor individually and at a fixed interfruit interval, ensuring a one-to-one correspondence between the imaged object and the classification result. The design of the conveyor and guide elements ensures stable positioning of the fruits within the inspection zone and minimizes their mutual overlap.
The fruit is transported by a chain conveyor driven by a 6IK250RGU-CF induction motor. This 250-watt motor is manufactured by Ningbo Zhongda Leader Intelligent Transmission Co., Ltd., Ningbo, China. Speed control is provided by a ZD Motor Speed Control Unit manufactured by Ningbo ZD Leader Transmission Equipment Co., Ltd., Ningbo, China. The speed control system allows for variable linear speed of the conveyor, which was used in experimental studies to assess the impact of dynamic modes on sorting accuracy.
Torque transmission is achieved via a chain drive using 100.5 mm diameter steel sprockets with 12 teeth and hardened shafts with a diameter of 15-16 mm. The design ensures stable operation in continuous flow mode.
The key element of the machine is the visual inspection area (
Figure 2), where digital images of apples are captured. The inspection area is equipped with an industrial vision camera with fixed focus and exposure parameters, as well as an artificial lighting system using LED sources. The lighting system is designed to ensure uniform illumination of the fruit's surface and reduce glare, shadows, and variations in ambient light. The camera and light source geometry ensures stable image formation, regardless of slight fluctuations in the apple's position on the conveyor. To ensure correct fruit orientation in the measurement zone, a mechanism for rotating the apple around its own axis is implemented. The rotation unit uses a 5840-31ZY DC gear motor (industrial OEM production, China) with a 12-24 V power supply. Rotation speed is controlled by a DC9-60C Motor Controller 20A (voltage range 9-60 V, maximum current 20 A, made in China). Forced fruit rotation minimizes the impact of orientation on the accuracy of geometric parameter measurements..
Captured images are transmitted in real time to a computing unit that implements digital image processing and analysis algorithms. The computing unit is synchronized with the conveyor's movement, allowing each frame to be linked to a specific fruit and its current position in the machine's coordinate system. This is achieved using position sensor signals and timestamps, ensuring accurate object identification in the stream.
A Logitech C270 digital camera manufactured by Logitech International S.A., Lausanne, Switzerland (assembled in China) was used as a visual inspection tool. The camera features a CMOS sensor with a resolution of 1280x720 pixels and a shooting rate of up to 30 frames per second. The camera is connected to a Raspberry Pi 4 Model B microcomputer manufactured by the Raspberry Pi Foundation, Cambridge, UK. The Raspberry Pi 4 performs video stream capture, image preprocessing, and computer vision algorithm implementation. Image processing is performed using the OpenCV (cv2) library. The algorithm includes image conversion to grayscale, threshold segmentation using Otsu's method, morphological filtering, edge detection, and calculation of the fruit's geometric parameters. For each apple, the diameter D, projected area S, and color fraction are calculated.
The calculated parameters and classification results from the Raspberry Pi 4 to the industrial controller is carried out via the MODBUS RTU protocol, which ensures stable data exchange in real time and synchronization of the computing and executive parts of the system. Based on the image processing results, a set of quantitative visual features is generated for each apple, including geometric parameters (diameter, projected area, color percentage) and surface appearance characteristics. These parameters are then used to indirectly estimate the fruit's weight and classify it into product categories according to specified criteria. The fundamental difference of the developed machine is the absence of traditional mechanical weighing of each fruit: the decision on product category is made solely on the basis of visual information and mathematical models, which allows for increased sorting speed and simplified design of the unit.
The machine control system is based on the OWEN PLC200 programmable logic controller (OWEN LLC, Moscow, Russia). The controller synchronizes the transport system, reset actuators, and exchanges data with the computing module. The operator interface is implemented using the OWEN SP307-R touch panel (OWEN LLC, Moscow, Russia), designed for setting operating modes and monitoring sorting parameters.
The sorting actuator module (
Figure 3) is implemented as a set of controlled mechanisms located along the fruit's trajectory after the visual inspection zone. The fruit discharge system into the appropriate receiving containers is implemented using linear electromagnetic actuators (solenoid actuators, manufactured in China). Each discharge unit includes a rotating chute secured by a locking mechanism controlled by an electromagnet. When a control signal is sent from the controller, an electromagnet releases the latch, briefly lowering the discharge chute and redirecting the fruit to the appropriate tray. After the fruit has passed, the mechanism returns to its original position through mechanical interaction with the moving conveyor and re-engages the latch. The use of electromagnetic actuators ensures high response speed, repeatability, and positioning accuracy in flow sorting environments.
The automatic apple sorting machine operates as a continuous flow process, in which the mechanical feeding system, computer vision module, and sorting actuators function as a single technological unit. Apples are individually fed from a loading hopper onto a chain conveyor and sequentially moved along the line through a visual inspection zone. During the process, a digital image of each fruit is generated and processed by a computing unit, which extracts informative visual features (geometric parameters, projected area, and color). Based on the obtained data, a classification algorithm determines the fruit's product category and generates a control signal for the corresponding actuator. At a predetermined point along the trajectory, the apple is automatically redirected to the receiving tray for its category. All stages—from imaging to the release mechanism—are performed dynamically, without stopping the conveyor.
The fruit is transported by a chain conveyor driven by an asynchronous motor with a rated speed of 1350 rpm. The linear speed is regulated by a frequency converter and transmission kinematics (gear and chain drive), ensuring that the motor's rotational motion is matched to the required transport mode. The line is divided into functional sections, each 0.20 m long. The conveyor speed is smoothly adjusted from the control panel within the range of 0.12 to 0.20 m/s. Sorting performance depends on the fruit weight (size) and the conveyor speed. With an average fruit weight of 0.130 kilograms, the performance ranges from 270 kg/hour (at a speed of 0.12 m/s) to 470 kg/hour (at a conveyor speed of 0.20 m/s).
The visual inspection zone is working at multi-frame imaging mode: at least three consecutive images are recorded for each apple as it rotates, ensuring at least 360° surface coverage. Rotation is achieved by a geared motor, ensuring uniform angular rotation of the fruit during its linear movement. This approach minimizes the dependence of results on fetal orientation and improves the robustness of geometric characteristic calculations. The conveyor speed and frame rate are synchronized so that the exposure time is significantly shorter than the fetal transit time through the inspection zone, eliminating image blur and ensuring accurate contour segmentation.
Thus, the developed design of the automatic machine integrates a mechanical feeding and positioning subsystem, a computer vision module, and an intelligent classification algorithm into a single technological system. The adopted design and functional solutions enable continuous apple sorting without line interruption, ensuring stable operation in dynamic mode, sufficient classification accuracy, and technological simplicity. This creates the preconditions for the practical implementation of the system in small and medium-sized farms with limited resources and energy-efficient equipment requirements.
The computer vision system of the automatic apple sorting machine was developed taking into account the requirements for non-destructive testing of fruit in a continuous mode and is focused on obtaining stable, metrologically correct images suitable for quantitative analysis of geometric and visual parameters. The system's primary objectives are to generate images with minimal distortion, ensure repeatability of shooting conditions, and reduce the influence of external factors such as changes in illumination and fruit orientation.
An industrial digital vision camera with a fixed-resolution sensor, permanently mounted above the inspection zone, is used for visual inspection. The camera is equipped with a fixed-focal-length lens, eliminating image scaling during operation. Exposure, gain, and white balance parameters are fixed programmatically and remain unchanged during experiments, ensuring comparability of the resulting images for different batches of apples.
An artificial LED lighting system is used to illuminate the shooting area, providing uniform illumination of the fruit surface. The lighting elements are positioned to minimize the formation of harsh shadows and specular highlights on the apple skin, which can distort the segmentation and feature extraction results. The use of LED sources with a constant color temperature ensures stable spectral characteristics of the illumination and reduces the impact of color distortion on image analysis.
The visual inspection zone is shielded from external light, eliminating the influence of natural light and ensuring reproducible shooting conditions. This design solution is especially important when operating the machine in production areas with variable lighting conditions. The geometry of the camera and light sources are selected in such a way that the optical axis of the camera is perpendicular to the plane of the conveyor, which reduces perspective distortions and simplifies subsequent calibration.
To translate dimensional parameters from the image's pixel space into real-world linear quantities, geometric calibration of the computer vision system was performed. Calibration is performed using a reference object with known linear dimensions, placed in the shooting area. Based on the resulting images, horizontal and vertical scaling factors are calculated, allowing for the correspondence between the number of pixels and physical dimensions in millimeters. These coefficients are used in subsequent processing stages to determine the diameters, projected areas, and other geometric parameters of the apples.
The resulting images are transmitted to the computing unit in real time via a high-speed interface. They are then used in preprocessing, segmentation, and feature extraction algorithms described in the following subsections. The adopted computer vision system architecture ensures a balance between image quality and computational load, which is critical for implementing automated apple sorting in real time.
Thus, the developed computer vision system provides a robust and reproducible visual basis for non-destructive testing of apple quality indicators and their classification into product categories within an automatic sorting machine.
The operating algorithm of the machine is presented in
Figure 4. The proposed scheme reflects the sequence of key stages of fruit processing and the formation of informative features used for quality assessment and subsequent classification into apple categories. Implementation of this algorithm enables automated processing of apple images and real-time quality category decisions.
The first stage involves capturing a color RGB image of the apple, obtained by the computer vision system in the visual inspection zone. To reduce the impact of color noise and simplify subsequent processing, the original image is converted to a grayscale image by extracting the luminance component. This approach preserves the key structural information about the fruit's shape while reducing computational complexity.
The second stage involves binarization of the image using automatic thresholding. The Otsu method is used to determine the optimal threshold value based on a statistical analysis of pixel brightness distribution. This results in a binary image in which the fetus is separated from the background. This method ensures the algorithm's adaptability to minor changes in illumination and image contrast. An example of image processing for each fetus is shown in
Figure 5.
Next, morphological processing of the binary image is performed, aimed at removing small noise objects and filling the internal areas of the fruit. This is accomplished using closing operations, including dilation and erosion, as well as hole filling procedures. These operations smooth the contour boundaries and ensure a correct representation of the apple's shape without significantly distorting its geometric characteristics.
After morphological filtering, the fruit's contour is extracted and the connected components of the binary image are analyzed. It is assumed that only one object is present in the visual inspection zone at a time, allowing the apple's contour to be unambiguously identified as the primary connected component of the image. Based on the extracted contour, the main geometric parameters of the fruit are calculated.
The projection area and the surface color area were calculated using the multi-frame shooting mode described previously. The number of frames captured is designated as Nframes and is determined by the number of cycles activated in the camera initialization program.
To improve measurement stability, parameters were averaged across all recorded frames. The arithmetic mean of the fetal projection area was calculated using the formula:
where
Si - object area per i-th frame.
The arithmetic mean area of the painted surface was determined in a similar manner.:
where
Spaint,i - the area of the colored surface in the i-th frame.
The proportion of the fruit's surface color,
∆color, was determined by the expression:
The obtained values were used in subsequent variety-specific classification, for which color share thresholds were set individually for each variety based on preliminary calibration.
The basic geometric characteristics used in the study are the diameter D and height h of the apple, defined as the lengths of the principal axes of the approximating ellipse. These parameters allow for a quantitative description of the fruit's size and shape and also serve as the basis for calculating derived indicators. The fruit projection area S is defined as the number of pixels belonging to the apple's binary mask, then converted to real units using the computer vision system's calibration coefficients.
The resulting geometric features form a parameter vector that quantitatively describes each fruit. These parameters are used in subsequent stages to indirectly estimate the apples' weight and classify them into product categories. The advantages of the selected feature set include their physical interpretability, computational simplicity, and robustness to minor changes in the orientation of the fruit within the image field.
Thus, the proposed image processing algorithm ensures reliable extraction of apple geometric characteristics in real time and forms the basis for subsequent analysis and sorting steps in an automated machine.
In an automated apple sorting machine, fruit weight is considered a key quality indicator, traditionally used to determine commercial grades. However, direct mechanical weighing of each fruit in a streaming mode leads to design complexity, reduced reliability, and limited productivity of the sorting equipment. In this regard, this study implements an approach to indirectly determining apple weight based on visual parameters extracted from digital images.
As demonstrated in a number of recent studies and confirmed by the authors' previous results, the geometric characteristics of apples, in particular projected area, diameters, and derived shape coefficients, are highly correlated with actual fruit weight. In this study, a preliminary correlation analysis was conducted between the measured apple weight and a set of visual attributes, including the major diameter D, minor diameter d, projected area S, and shape index If, to select the most informative parameter. The results of control weighing on a laboratory scale were used as reference weight values.
The results of the analysis showed that the greatest correlation with apple weight is demonstrated by the fruit's projected area S, which is consistent with the findings of advanced publications on the topic and also previous studies conducted by the authors. Therefore, a regression model based on weight and projected area was chosen for indirect weight estimation in an automatic machine. [
21]
To indirectly determine the weight of fruits in an automatic sorting machine, a linear regression model was used for the dependence of weight on the projection area obtained as a result of digital image processing:
where
m – individual fruit weight, g;
S - the projected area of the fetus, cm²;
a and
b are the regression coefficients determined from the experimental data using the least squares method.
The model was constructed separately for each studied variety using a sample size of 250 fruits. For each apple, the actual weight was recorded using a strain gauge, and the projected area was determined using computer vision by segmenting the fruit's contour and calculating the area of the binary region. Before conducting the regression analysis, the data underwent preliminary statistical processing: the accuracy of the measurements was checked, incomplete records were excluded, and outliers were removed using the ±3σ criterion separately for the variables m and S. This approach eliminated the influence of isolated anomalous observations on the model parameters and increased the stability of the coefficient estimates.
The linear dependence coefficients were determined using the least-squares method by minimizing the sum of the squared deviations of the experimental mass values from the calculated ones:
where
mi - is the experimentally measured mass of the i-th fruit,
Si - corresponding projection area, and
n - sample volume. The analytical solution to the minimization problem leads to following expressions:
where
S and
m are mean values of the projected area and mass, respectively. Thus, coefficient
a is defined as the ratio of the covariance between variables to the variance of the projected area, and coefficient
b is the free term of the linear model, characterizing the systematic bias of the relationship.
The accuracy of the approximation was assessed using the coefficient of determination:
where
- actual value of mass,
- the calculated value of mass,
- the average value of mass.
The obtained values of the regression coefficients for different varieties were in the range of a = 2.84-3.02 g/cm² and b = −34.06…+34.12 g, with the determination coefficient R2=0.61-0.92. Differences in the coefficients are explained by varietal features of the geometry and density of the fruits; however, the structure of the dependence remains linear across the entire range of sizes studied.
This model provides sufficiently accurate weight estimation based on machine vision data and can be used in an automatic sorting algorithm. If accuracy needs to be increased in industrial settings, variety-specific calibration coefficients or adaptive adjustment of the model parameters depending on the fruit size group can be used.
Based on the estimated weight of apples and additional geometric characteristics, commodity classification criteria are developed. Commodity categories are defined as ranges of weight values and/or characteristic dimensions that comply with current regulations and accepted commercial grading practices. Threshold values for estimated weight (mmm) are defined for each category; if exceeded or not reached, the fruit is classified into the corresponding class.
When developing classification criteria, the inevitable error in indirect weight estimation is taken into account, due to biological variability in apple shape and the peculiarities of visual measurement. Therefore, category thresholds can be adjusted based on the statistical distribution of estimated and actual weight values, minimizing classification errors at the range boundaries. This approach ensures the stability of sorting and reduces the likelihood of systematic biases when assigning fruit to product categories.
The product category decision for each apple is made individually based on calculated visual parameters and a regression model for weight estimation. The resulting data is assigned to a specific fruit in the flow and transmitted to the sorting module, taking into account the time delay between the visual inspection zone and the mechanical impact point. This ensures proper synchronization of the computational and execution stages and enables continuous flow sorting without stopping the conveyor.
Thus, the proposed method for indirectly determining apple weight and forming product categories based on visual parameters eliminates the need for mechanical weighing, simplifies the design of the automated machine, and ensures sufficient classification accuracy in real time. Implementation of this approach provides the basis for improving sorting productivity and expanding the system's functionality through the integration of additional visual quality indicators.
Experimental studies of an automatic apple sorting machine were conducted to evaluate the accuracy of indirect weight determination, the correctness of product classification, and the system's robustness in flow mode. The experimental methodology was designed to replicate real-world operating conditions and ensure comparability of the results with data presented in contemporary scientific publications.
A sample of apples including various sizes and product categories, typical of both industrial and farm production is object of this study. Before the experiments, all apples were visually inspected to exclude any with significant mechanical damage not relevant to the objectives of this stage of the study. The actual weight of each apple was determined using a laboratory electronic scale and used as a reference value for assessing the accuracy of the indirect method.
The experiments were conducted in two stages. In the first stage, a training sample was formed, used to determine the coefficients of the regression model for indirect weight estimation. For each apple, the values of visual parameters extracted from images (diameter, height, projected area, color percentage) and the corresponding actual weight were calculated. Based on this data, a regression model was built and its statistical characteristics were assessed.
The second stage involved testing the automated machine in flow sorting mode. Apples were fed individually onto a conveyor and passed sequentially through a visual inspection zone without stopping. To assess the impact of dynamic factors, experiments were conducted at three different conveyor speeds: 0.12, 0.16, and 0.20 m/s. These specific speed numbers are corresponding to different sorting throughputs. For each mode, the estimated weight of the apples, the assigned product category, and the actual weight, measured separately, were recorded.
The accuracy of the indirect mass determination was assessed by comparing estimated and reference values using standard statistical metrics, including mean absolute error, root mean square error, and relative error. To analyze the robustness of the model, particular attention was paid to the distribution of errors near product category boundaries, as these are the areas where the likelihood of misclassification is highest.
The quality of sorting by product category was assessed by comparing the results of automatic classification with a control sort performed based on the actual weight of the apples. For this purpose, classification accuracy indicators were calculated, including the proportion of correctly classified fruits, as well as an error matrix reflecting the distribution of errors between adjacent categories. This approach allows for a quantitative assessment of not only the overall sorting accuracy but also the nature of errors occurring during machine operation.
Additionally, the repeatability of sorting results was analyzed across multiple runs of identical apple batches, allowing us to assess the influence of random factors and the stability of the computer vision system and image processing algorithms. All experiments were conducted under fixed shooting and lighting parameters, ensuring data comparability and eliminating the influence of external factors.
Thus, the proposed experimental research methodology allows for a comprehensive assessment of the accuracy, reliability, and practical applicability of an automatic apple sorting machine, as well as the formation of an objective basis for analyzing the results and discussing the data obtained in the next section of the article.