Design and Experimentation of a Residual-Input Tube-End Cutting System for Plasma Bags Based on Machine Vision

: In response to the lack of plasma bag-breaking equipment and time-consuming manual recovery of plasma in China, this study focuses on the distal end cutting of a plasma bag residual-input tube and designs a machine-vision-based plasma bag residual-input tube cutting system. The system comprises a plasma bag rotation device, a bottom disc, an image acquisition device, a cutting device, and a device control system. The image acquisition device captures images of the rotating plasma bag and calculates the Euclidean distance from the end of the plasma bag input-tube distal end to the outer edge of the bottom support plate and the distance from the input-tube distal end to the centerline of the plasma bag. Two distinct value acquisition algorithms are designed for the two types of input tubes. The screw slide moves accordingly. When the plasma bag is above the cutting part, the cutting part cuts the end of the residual-input tube of the plasma bag. The prototype performance tests reveal that the cutting error is within 10% of the end of the plasma bag input tube distal end, the cutting success rate is 100%, and the processing time for each bag is 2.5 s, which meets the time requirements of the plasma bag breaker.


Introduction
Plasma-based pharmaceuticals are extensively applied in various medical fields, including for anemia treatment, clotting factor replacement, and immunotherapy. As the demand for blood products has consistently increased over the years, the number of plasma stations in China has continuously expanded, leading to an expansion in the market and supply scale. The market size reached $39 billion as of 2021, and is expected to remain high in the upcoming years. Therefore, improving the plasma recovery rate and efficiency has become a pressing concern for the blood-product pharmaceutical industry.
Currently, the existing plasma-bag-splitter machines face two major issues, namely a low working efficiency and low plasma recovery rates. As a result, the process of extracting plasma still relies heavily on manual labor. With the continuous expansion of the bloodproduct market, the cost of using manual labor to extract plasma is too high, and there are issues with low efficiency and hygiene safety. Therefore, there is a need in the market for a highly efficient and high plasma recovery rate plasma-bag-splitter machine.
The aim of this paper is to address the above two issues considering our designed plasma-bag-splitter machine. To address the issue of working efficiency, we adopt a pipeline workstation-style design, splitting different procedures apart. The procedures that need to be stopped before completion are placed on the workstation, while the procedures that can be completed during the movement process are placed on the moving path. The system can recognize the residual-input tube-end position of the plasma bag and cut the residual-input tube end during the movement process.
The experimental section of this paper only includes the recognition of the input tube's endpoint and the cutting of the input tube's endpoint during the plasma bag's movement process. This part is crucial for determining whether the plasma bag splitter machine can improve the recovery rate. The residual-input tube contains plasma and the endpoint of the input tube will be sealed. To extract all of the blood inside, the endpoint of the input tube must be cut as close to the edge as possible to allow both sides to have contact with the outside air pressure. However, the difficulty lies in the fact that the input tube is irregularly placed in the freezing process, causing a significant difference in the endpoint's position, and the plasma bag is continuously moving. Therefore, it is necessary to develop a system that can accurately identify the endpoint of the input tube during the movement process and cut it. This will enable the residual plasma to be taken out of the input tube, making the endpoint-cutting system for the plasma bag an essential technology component of the automatic plasma-bag splitter.
As the residual-input tube is a flexible tube and its position varies randomly, noncontact measurement methods are necessary to detect the distance of the input tube's endpoint. Non-contact measurement methods include laser triangulation, eddy current testing, ultrasonic measurement, and machine vision measurement. However, laser triangulation and ultrasonic measurement also face the challenge that the position of the residual-input tube is random and changes as the plasma bag moves, making it difficult to identify the accurate position of the tube's endpoint. The accurate position is the relative position of the input tube's end in the plasma bag. Additionally, eddy current testing requires a conductor, which is not suitable for use with a plasma bag.
Visual measurement is a non-contact method with a high accuracy and extensive uses, and is especially suitable for detecting the position of the residual-input tube of the plasma bag. Based on machine vision, processing equipment has been widely used, providing a new approach for accurate identification of the cutting position of the input tube of the plasma bag. Peng Wang et al. [1] addressed the problem of inaccurate positioning of traditional steel tapes by designing an automatic calibration device for steel tapes, simplifying the recognition process with a mechanical structure, and designing three different recognition algorithms based on the pictures of different types of tapes to adapt to different types of steel tapes. The errors of the three algorithms were within the allowable range after testing. However, this proposal is only applicable to changes in the length of the residual-input tube of the plasma bag, and cannot address changes in the input-tube position. Lee W et al. [2] addressed the problem of inaccurate measurement of solder by capturing images from two different perspectives, which achieved a higher accuracy when compared with single-perspective methods. This method is suitable for image processing with non-overlapping features and can improve accuracy by using multiple perspectives. However, taking samples from the side of the plasma bag means the plasma bag will overlap with the residual-input tube in the camera, which will be challenging to implement in this study. Furferi et al. [3] used machine vision and probabilistic neural networks to classify pure color, colored, and recycled woolen fabrics based on their color, addressing the problem of difficulty recognizing similar colors in existing visual processing algorithms. Wei Chien Wang et al. [4] evaluated various features of printed circuit board holes by using image registration, geometric image transformation, labeling, and matching methods to create an AOI system. The system evaluated a series of features including missing holes and incorrectly positioned holes. Its measurement accuracy was superior to existing technologies.
In addition to research on the visual aspects, there are different algorithms designed for detection based on various working conditions and requirements in order to adapt to a wider range [5]. For instance, multiple cameras, viewpoints, and dimensions can be employed to record surfaces and directly identify foreign objects [6]. Regarding visual applications in welding, some researchers have established a weld seam coordinate system by extracting feature points and calibrating them using algorithms to enhance measurement efficiency and accuracy. Others have used machine vision to perform adaptive corrections for the height variation of welds caused by the thermal deformation of the welded workpiece, which significantly improves the welding quality [7,8]. In addition, deep learning combined with machine vision has been shown to achieve good results in irregular feature defect detection, enabling the detection of very small scratches [9,10]. This approach has also been applied in many food inspection scenarios, where color or texture features are used to identify food quality through a combination of various prediction models and algorithms [11,12]. Moreover, two different paths, namely machine vision and deep learning, have been separately verified to detect defects, and it has been pointed out that each approach has its advantages and disadvantages for different types of defects [13]. Finally, vision and servo system integration can be employed to maintain a stable camera level status by simultaneously decoupling the machine kinematics and imaging geometry for control [14].
Domestic and international scholars have conducted many studies covering various aspects regarding machine-vision-based systems, such as precision, color, shape, and position. However, there has been no research on the recognition of the residual-input tube end of a plasma bag. Therefore, this study focuses on the cutting process of the residual-input tube end of a plasma bag and explores the process requirements for cutting the input tube end. Based on the display results, the execution mechanism is driven to cut the end of the input tube. Finally, a residual-input tube-end cutting system for plasma bags is successfully designed. The machine-vision technology examines the input tube cutting position to achieve precise cutting of the input tube, aiming to achieve automation and intelligence in plasma-bag breaking equipment and to promote the development and application of plasma-bag breaking equipment.

Experimental Subjects
This study aimed to design a system that could accurately identify the exact location of a residual-input tube randomly distributed in a frozen plasma bag and to precisely cut it. Specifically, an unused semi-transparent plasma bag made of polyvinyl chloride material, as shown in Figure 1a. After collection, the input tube was cut and sealed before the first bifurcation point, as shown in Figure 1b. The color of the input tube was light yellow, and after freezing, the residual-input tube exhibited partial flexibility. The residual-input tube was randomly distributed when frozen, as shown in Figure 1c, and the red area indicates the range of the randomly distributed residual-input tube. The residual-input tube was distributed around the endpoint of the plasma bag and formed a cone-shaped range. The cutting requirement of the system was to cut more than half of the radial end of the input tube, while the end was still attached to the input tube, as shown in Figure 1d, making subsequent operations easier and reducing subsequent design difficulties. extracting feature points and calibrating them using algorithms to enhance measurement efficiency and accuracy. Others have used machine vision to perform adaptive corrections for the height variation of welds caused by the thermal deformation of the welded workpiece, which significantly improves the welding quality [7,8]. In addition, deep learning combined with machine vision has been shown to achieve good results in irregular feature defect detection, enabling the detection of very small scratches [9,10]. This approach has also been applied in many food inspection scenarios, where color or texture features are used to identify food quality through a combination of various prediction models and algorithms [11,12]. Moreover, two different paths, namely machine vision and deep learning, have been separately verified to detect defects, and it has been pointed out that each approach has its advantages and disadvantages for different types of defects [13]. Finally, vision and servo system integration can be employed to maintain a stable camera level status by simultaneously decoupling the machine kinematics and imaging geometry for control [14]. Domestic and international scholars have conducted many studies covering various aspects regarding machine-vision-based systems, such as precision, color, shape, and position. However, there has been no research on the recognition of the residual-input tube end of a plasma bag. Therefore, this study focuses on the cutting process of the residualinput tube end of a plasma bag and explores the process requirements for cutting the input tube end. Based on the display results, the execution mechanism is driven to cut the end of the input tube. Finally, a residual-input tube-end cutting system for plasma bags is successfully designed. The machine-vision technology examines the input tube cutting position to achieve precise cutting of the input tube, aiming to achieve automation and intelligence in plasma-bag breaking equipment and to promote the development and application of plasma-bag breaking equipment.

Experimental Subjects
This study aimed to design a system that could accurately identify the exact location of a residual-input tube randomly distributed in a frozen plasma bag and to precisely cut it. Specifically, an unused semi-transparent plasma bag made of polyvinyl chloride material, , as shown in Figure 1a. After collection, the input tube was cut and sealed before the first bifurcation point, as shown in Figure 1b. The color of the input tube was light yellow, and after freezing, the residual-input tube exhibited partial flexibility. The residual-input tube was randomly distributed when frozen, as shown in Figure 1c, and the red area indicates the range of the randomly distributed residual-input tube. The residual-input tube was distributed around the endpoint of the plasma bag and formed a cone-shaped range. The cutting requirement of the system was to cut more than half of the radial end of the input tube, while the end was still attached to the input tube, as shown in Figure 1d, making subsequent operations easier and reducing subsequent design difficulties.

Experimental Principles
After obtaining the coordinates of the plasma bag for the input tube end ( , ) and the circle center fitted on the rotating platform ( , ), the system calculated a straightline function to draw a continuous extension line. Subsequently, we used a loop function to determine the intersection point ( , ) between the extension line and the disc edge. This intersection point determined the distance between the plasma bag and the disc.  The Euclidean distance between the end position of the plasma-bag input tube ( , ) and the coordinates of the intersection point ( , ) was calculated using the formula: As the detected corner points exhibited a certain degree of symmetry, we calculated the midpoint coordinates of the outermost pair of corner points. Subsequently, we iteratively calculated the midpoint coordinates of the corner points, with eight iterations in total. Finally, we drew a line connecting the two midpoint coordinates to approximate the central line. We then drew a line perpendicular to the central line through point A and determined the intersection point as point C. The distance between points A and C represents the distance from the input-tube endpoint to the central line. Although this method may have a relatively large measurement error, it is sufficient if cutting with longer blades, meeting the required cutting precision.
In addition, the system faced recognition errors due to the stainless-steel material of the background, which had a color similar to that of the plasma bag and produced

Experimental Principles
After obtaining the coordinates of the plasma bag for the input tube end (X A , Y A ) and the circle center fitted on the rotating platform (X O , Y O ), the system calculated a straightline function to draw a continuous extension line. Subsequently, we used a loop function to determine the intersection point (X B , Y B ) between the extension line and the disc edge. This intersection point determined the distance between the plasma bag and the disc. Figure 2 illustrates the measurement principle.

Experimental Principles
After obtaining the coordinates of the plasma bag for the input tube end ( , ) and the circle center fitted on the rotating platform ( , ), the system calculated a straightline function to draw a continuous extension line. Subsequently, we used a loop function to determine the intersection point ( , ) between the extension line and the disc edge. This intersection point determined the distance between the plasma bag and the disc.  The Euclidean distance between the end position of the plasma-bag input tube ( , ) and the coordinates of the intersection point ( , ) was calculated using the formula: As the detected corner points exhibited a certain degree of symmetry, we calculated the midpoint coordinates of the outermost pair of corner points. Subsequently, we iteratively calculated the midpoint coordinates of the corner points, with eight iterations in total. Finally, we drew a line connecting the two midpoint coordinates to approximate the central line. We then drew a line perpendicular to the central line through point A and determined the intersection point as point C. The distance between points A and C represents the distance from the input-tube endpoint to the central line. Although this method may have a relatively large measurement error, it is sufficient if cutting with longer blades, meeting the required cutting precision.
In addition, the system faced recognition errors due to the stainless-steel material of the background, which had a color similar to that of the plasma bag and produced The Euclidean distance between the end position of the plasma-bag input tube (X A , Y A ) and the coordinates of the intersection point (X B , Y B ) was calculated using the As the detected corner points exhibited a certain degree of symmetry, we calculated the midpoint coordinates of the outermost pair of corner points. Subsequently, we iteratively calculated the midpoint coordinates of the corner points, with eight iterations in total. Finally, we drew a line connecting the two midpoint coordinates to approximate the central line. We then drew a line perpendicular to the central line through point A and determined the intersection point as point C. The distance between points A and C represents the distance from the input-tube endpoint to the central line. Although this method may have a relatively large measurement error, it is sufficient if cutting with longer blades, meeting the required cutting precision.
In addition, the system faced recognition errors due to the stainless-steel material of the background, which had a color similar to that of the plasma bag and produced reflection under the light source. To address this issue, we continuously sampled the residual-input tube when it was in the camera's field of view and took average of the collected data to obtain the final cutting position. After being frozen, the residual-input tube of a blood plasma bag was randomly dispersed. In general, it moved freely with the bag, but in some instances, the end of the input tube came into contact with the supporting surface, resulting in new deformation when the bag was moved. If we used the common approach of sampling with the camera and then averaging all of the results to eliminate camera errors, we could see a significant deviation in the final cutting point from the end in such cases.
When the input tube came into frictional contact with the supporting surface, it underwent deformation in three stages. The first stage was the pre-deformation of the input tube before the plasma bag rotated. The second stage was the deformation that occurred when the plasma bag moved and the input tube experienced some deformation due to friction with the surface. The third stage was when the input tube, affected by the force of friction, moved uniformly with the plasma bag until it reached a stable state. Therefore, it was necessary to obtain the positional information of the input tube after the third stage of deformation in the system and to take the average to obtain a more accurate position of the end of the input tube.
As the residual-input tube was in a state of ice-water mixture and had flexible characteristics, soft body dynamics analysis was required [15].
Before performing soft body dynamics analysis, we needed to establish the global and relative coordinate systems. The center of the supporting plate was obtained by segmenting the background in the images and fitting the circular contour. We then used the supporting plate surface as the origin plane for the global coordinate system [X, Y, Z] and the center of the supporting plate as the origin. To establish the relative coordinate system, we used the plasma bag centerline as the y 1 -axis; then, we translated the previously calculated line AC to the contour corner mutation point, using this translated line as the x 1 -axis, and set the supporting plane as the origin plane to obtain the relative coordinate system x 1 , y 1 , z 1 . The established coordinate system is shown in Figure 2.
After the coordinate system was established, we used the floating coordinate method to design and analyze it. The endpoint position of the end input tube was point A, and its position in the global coordinate system [X 1 , Y 1 , Z 1 ] was calculated using Equation (1), where D is the direction cosine matrix C A A 1 of the relative coordinate system with respect to the global coordinate system; u 0 is the position of the input tube endpoint A in the relative coordinate system before deformation; A1 x 1 1 , y 1 1 , z 1 1 is the position of the deformed input tube endpoint in the relative coordinate system, as shown in Figure 3; u f is the deformation displacement of the input tube; and R is the position of point A when the input tube is undeformed in the global coordinate system. We then differentiated Equation (1) to obtain the motion velocity of point A, as shown in Equation (3), and differentiated Equation (3) again to obtain the motion acceleration of point A, as shown in Equation (4). The velocity of the plasma bag movement was known, and the time required for the residualinput tube to move without relative displacement was obtained using Equation (5). Once the time 't' was determined, the system calculated the average of the images captured after time 't' to obtain more accurate positional information.
To calculate the waiting time required for the cutting blade, we determined the angle between line segments OA and OC. The radius of the plasma bag tray, which is known to be 650 mm, was used to calculate the additional rotation angle α needed by the bottom motor, as shown in Equation (6). The bottom stepper motor rotated at a constant speed, and the number of steps required for the additional rotation angle was used to calculate the motor's forward steps. The step count of the stepper motor was set to n/360°, and the additional rotation steps were determined using Equation (7). The system counted the pulse steps of the stepper motor, and when the required step count was reached, the electromagnet was activated to initiate the cutting process.

Experimental Setup
The residual-input tube-cutting system for plasma bags is a simplified version of the plasma-bag cutting machine that focuses on the cutting function of the input tube. The plasma-bag cutting machine consists of input, cutting, and output functions, while the plasma-bag tray is reciprocated on the bottom disk. This system only retains the function After the system obtained the initial residual-input tube endpoint information, the lead screw slide moved accordingly. When the averaged data were finally obtained, the lead screw slide moved to the calculated position and waited for the residual-input tube endpoint to reach that point before initiating the cutting process. . ..
To calculate the waiting time required for the cutting blade, we determined the angle between line segments OA and OC. The radius of the plasma bag tray, which is known to be 650 mm, was used to calculate the additional rotation angle α needed by the bottom motor, as shown in Equation (6). The bottom stepper motor rotated at a constant speed, and the number of steps required for the additional rotation angle was used to calculate the motor's forward steps. The step count of the stepper motor was set to n/360 • , and the additional rotation steps were determined using Equation (7). The system counted the pulse steps of the stepper motor, and when the required step count was reached, the electromagnet was activated to initiate the cutting process.

Structural Components of the System Unit
The residual-input tube-cutting system for plasma bags is a simplified version of the plasma-bag cutting machine that focuses on the cutting function of the input tube. The plasma-bag cutting machine consists of input, cutting, and output functions, while the plasma-bag tray is reciprocated on the bottom disk. This system only retains the function of cutting the input tube to facilitate research. The system is composed of a plasma-bag rotating device, a bottom support plate, an image-acquisition device, a screw-slide table, a cutting component, and a device control system, as shown in Figure 4.
The plasma bag was placed on a tray with a clamping mechanism at the top to secure its bottom edge, while baffles on both sides prevented any relative movement between the bag and tray during rotation. The plasma bag rotation device was driven by a reducer stepper motor with a maximum speed of 174 r/min. A side optical sensor was mounted to detect whether the input tube was in contact with the bottom surface. The image acquisition device, comprised of a photoelectric sensor, a light source, and a camera, was positioned above the rotation path of the bag. The camera lens was positioned 300 mm above the bottom support plate and had a resolution of 640 × 480. It captured 120 frames per second. The cutting device was composed of a lead screw slide, an electromagnetic actuator, and a cutting blade. The lead screw slide table had a 50 mm stroke and was powered by a separate stepper motor. It was mounted parallel to the edge of the lower support plate. The electromagnetic actuator was fixed to the lead screw slide, and the cutting blade was attached to the push rod's end. The cutting device moved along the Y-axis of the global coordinate system, as shown in Figure 4. Using the distance read by the vision system, the cutting device moved to the corresponding position on the Y axis and waited for the end of the remaining input tube. Once the end arrived, the electromagnetic switch was turned on, causing the cutting blade to move downwards along the Z axis of the global coordinate system and cut the input tube. The maximum distance that the electromagnetic switch could travel was 1 mm from the support surface, which satisfied the design requirements for cutting the end of the input tube. The electromagnetic switch had a travel distance of less than 10 mm, allowing for fast response times. The plasma bag was placed on a tray with a clamping mechanism at the top to secure its bottom edge, while baffles on both sides prevented any relative movement between the bag and tray during rotation. The plasma bag rotation device was driven by a reducer stepper motor with a maximum speed of 174 r/min. A side optical sensor was mounted to detect whether the input tube was in contact with the bottom surface. The image acquisition device, comprised of a photoelectric sensor, a light source, and a camera, was positioned above the rotation path of the bag. The camera lens was positioned 300 mm above the bottom support plate and had a resolution of 640 × 480. It captured 120 frames per second. The cutting device was composed of a lead screw slide, an electromagnetic actuator, and a cutting blade. The lead screw slide table had a 50 mm stroke and was powered by a separate stepper motor. It was mounted parallel to the edge of the lower support plate. The electromagnetic actuator was fixed to the lead screw slide, and the cutting blade was attached to the push rod's end. The cutting device moved along the Y-axis of the global coordinate system, as shown in Figure 4. Using the distance read by the vision system, the cutting device moved to the corresponding position on the Y axis and waited for the end of the remaining input tube. Once the end arrived, the electromagnetic switch was turned on, causing the cutting blade to move downwards along the Z axis of the global coordinate system and cut the input tube. The maximum distance that the electromagnetic switch could travel was 1 mm from the support surface, which satisfied the design requirements for cutting the end of the input tube. The electromagnetic switch had a travel distance of less than 10 mm, allowing for fast response times.

Device Control System
The control system of the residual-input tube-cutting system for plasma bags comprised a computer, camera, Stm32 micro controller, photoelectric sensor, screw slide, stepper motor driver, reducer stepper motor, electromagnet, and serial module, among other components. Its major function was to detect the end position of the input tube by capturing the image of the plasma-bag input tube and controlling the feed and reset of the cutting device driven by the screw slide. The reducer stepper motor drove the plasma bag in a reciprocating cycle of work, ultimately energizing the electromagnet to perform the input tube-cutting action. Figure 5 illustrates the control system of the plasma-bag-cutting device.

Device Control System
The control system of the residual-input tube-cutting system for plasma bags comprised a computer, camera, Stm32 micro controller, photoelectric sensor, screw slide, stepper motor driver, reducer stepper motor, electromagnet, and serial module, among other components. Its major function was to detect the end position of the input tube by capturing the image of the plasma-bag input tube and controlling the feed and reset of the cutting device driven by the screw slide. The reducer stepper motor drove the plasma bag in a reciprocating cycle of work, ultimately energizing the electromagnet to perform the input tube-cutting action. Figure 5 illustrates the control system of the plasma-bag-cutting device. During the operation of the plasma bag's residual-input tube-cutting system, the bag was positioned on a tray with its input tube facing outward. As the conveying device rotated, the plasma bag passed through an image-acquisition device. A photoelectric sensor

Device Working Process
During the operation of the plasma bag's residual-input tube-cutting system, the bag was positioned on a tray with its input tube facing outward. As the conveying device rotated, the plasma bag passed through an image-acquisition device. A photoelectric sensor on the top triggered the camera to capture images of the plasma bag, while a photoelectric sensor on the side verified the contact between the input tube and the bottom surface. The camera captured 20 frames of images at equal intervals. Upon acquiring the first frame of the image, the image processing program was invoked to compute the position information, which was then communicated to the STM32 via a serial port. The microcontroller governed the movement of the lead screw slide according to the data obtained in the first frame. If the program detected contact between the input tube and the bottom surface, it selected an image sampled at the duration required for the input tube to exhibit no relative displacement, and computed and processed it using the soft body kinematics algorithm. If no contact was detected, the image processing program processed all of the collected images. The averaged processed data were then relayed to the STM32 to control the lead screw slide until it reached the final position. Once the input tube reached the cutting position, the electromagnet energized it to cut it. A flow chart of the system's operational process is illustrated in Figure 6.

Experimental Preparation
In practical production, the length of the residual-input tube must be at least as long as the length of a barcode to attach it. During the preparation of the experimental plasma bags, the input tube was cut and sealed after the first node closest to the bag, before affixing the barcode label, within a length range of approximately45-85 mm.
To test whether the system could perform cutting under extreme conditions of the longest and shortest input tube lengths, we conducted other tests. We cut and sealed the input tube at 85 mm and 45 mm for 10 bags of plasma, which were then randomly placed in a freezer. The straight-line distance from the end of the input tube to the edge of the plasma bag was measured, and 200 data points were collected and statistically analyzed, as shown in Figure 7. The results indicated that the maximum radial distance of the input tube was 81 mm, while the minimum was 38 mm, with a difference of 43 mm between the two. The lead screw slide used by the system met the requirements.

Experimental Preparation
In practical production, the length of the residual-input tube must be at least as long as the length of a barcode to attach it. During the preparation of the experimental plasma bags, the input tube was cut and sealed after the first node closest to the bag, before affixing the barcode label, within a length range of approximately 45-85 mm.
To test whether the system could perform cutting under extreme conditions of the longest and shortest input tube lengths, we conducted other tests. We cut and sealed the input tube at 85 mm and 45 mm for 10 bags of plasma, which were then randomly placed in a freezer. The straight-line distance from the end of the input tube to the edge of the plasma bag was measured, and 200 data points were collected and statistically analyzed, as shown in Figure 7. The results indicated that the maximum radial distance of the input tube was 81 mm, while the minimum was 38 mm, with a difference of 43 mm between the two. The lead screw slide used by the system met the requirements. bags, the input tube was cut and sealed after the first node closest to the bag, before affixing the barcode label, within a length range of approximately45-85 mm.
To test whether the system could perform cutting under extreme conditions of the longest and shortest input tube lengths, we conducted other tests. We cut and sealed the input tube at 85 mm and 45 mm for 10 bags of plasma, which were then randomly placed in a freezer. The straight-line distance from the end of the input tube to the edge of the plasma bag was measured, and 200 data points were collected and statistically analyzed, as shown in Figure 7. The results indicated that the maximum radial distance of the input tube was 81 mm, while the minimum was 38 mm, with a difference of 43 mm between the two. The lead screw slide used by the system met the requirements.

Image Processing Process
In this study, we utilized an image processing approach to measure the position of the distal end of the input tube and calculate the cutting position. When the plasma bag arrived at the image acquisition point, the camera captured an image of the bag, which was then saved to a designated folder. The original picture of the plasma bag, as shown in Figure 8a, was preprocessed to improve the speed of the algorithm.

Image Processing Process
In this study, we utilized an image processing approach to measure the position of the distal end of the input tube and calculate the cutting position. When the plasma bag arrived at the image acquisition point, the camera captured an image of the bag, which was then saved to a designated folder. The original picture of the plasma bag, as shown in Figure 8a, was preprocessed to improve the speed of the algorithm.
In this study, we conducted grayscale conversion [16,17] on the captured image, and the resulting image is depicted in Figure 8b. The grayscale image was obtained using the formula Gray( , ) = 0.30 * ( , ) + 0.59 * ( , ) + 0.11 * ( , ) . Then, we converted the grayscale image to a binary image using a threshold value of ℎ = 20, which was determined based on preliminary experiments. The binary image, shown in Figure 8c, was processed to extract the disk's edge, which was identified as the black boundary. As the acquired image only covered a small part of the disk, we performed circular fitting on the continuous edge using the least-squares method to estimate the circle's parameters and determine the disk's center coordinates in the camera coordinate system. The input tube of the plasma bag was recognized by first extracting the bag's color [18][19][20][21] and constructing a corresponding color image. Then, the Euclidean distance between each pixel in the camera-captured image and each pixel in the constructed-color image was calculated. Following optimization and experimentation, a recognition distance of Dos = 25 was selected for the input tube's color identification. Any pixel in the sampled photo whose distance to the similar pixel in the image was less than Dos satisfied the recognition distance criterion. A mask image was then constructed based on the corresponding pixel points in the sampled photo, with the input tube's position marked as 255 and all other unsatisfied pixel values set to 0, resulting in the mask image of the input tube's location, as shown in Figure 9a.
We performed corner-point detection [22][23][24][25] on the mask image to identify pixels with a high rate of change. After calibration, we selected a threshold value of 100 and marked the corner points with circles, and plotted them on the graph. We applied a cyclic function to filter out low-confidence corner points and identify reliable ones. Thus, we found the endpoint of the plasma input tube among all corner points. In addition, the image was input in a circular way. If the pixel value was higher than the threshold value, then the point was a corner point and plotted on the graph; if it was lower than the threshold value, then the point could be discarded directly. Utilizing the identified corner points, we calculated the distance from the previously obtained disc outline to pinpoint the end of the input tube. The endpoint was determined as the corner point that was closest to the In this study, we conducted grayscale conversion [16,17] on the captured image, and the resulting image is depicted in Figure 8b. The grayscale image was obtained using the formula Gray(i, j) = 0.30 * R(i, j) + 0.59 * G(i, j) + 0.11 * B(i, j). Then, we converted the grayscale image to a binary image using a threshold value of T h = 20, which was determined based on preliminary experiments. The binary image, shown in Figure 8c, was processed to extract the disk's edge, which was identified as the black boundary. As the acquired image only covered a small part of the disk, we performed circular fitting on the continuous edge using the least-squares method to estimate the circle's parameters and determine the disk's center coordinates in the camera coordinate system.
The input tube of the plasma bag was recognized by first extracting the bag's color [18][19][20][21] and constructing a corresponding color image. Then, the Euclidean distance between each pixel in the camera-captured image and each pixel in the constructed-color image was calculated. Following optimization and experimentation, a recognition distance of Dos = 25 was selected for the input tube's color identification. Any pixel in the sampled photo whose distance to the similar pixel in the image was less than Dos satisfied the recognition distance criterion. A mask image was then constructed based on the corresponding pixel points in the sampled photo, with the input tube's position marked as 255 and all other unsatisfied pixel values set to 0, resulting in the mask image of the input tube's location, as shown in Figure 9a. In this study, after obtaining the pixel distance, we converted it to linear distance [26,27]. The triangulation method was employed to calibrate the actual distance as the scaling ratios for the horizontal and vertical directions in the image were not the same, which required calibration of two sets of points to solve the equation. The following two equations were used: The distance of the residual-input tube in practice was derived from the values obtained for and and the previously obtained pixel distances. The ranging plot is shown in Figure 10, and some of the experimental ranging errors are presented in Table  1. The image processing time was about 60 ms, and the camera field of view was about one-half of the disc so as to ensure that the image was fully processed and cutting was completed. The rotation time of the tray was also controlled to be within 10 s per rotation. According to Table 1, there was some error in the distance in the X and Y directions. In the X direction, the error was larger, and the measured values had positive and negative values, which was within the expected error. In the Y direction, the error was smaller and met the requirements for practical use. We performed corner-point detection [22][23][24][25] on the mask image to identify pixels with a high rate of change. After calibration, we selected a threshold value of 100 and marked the corner points with circles, and plotted them on the graph. We applied a cyclic function to filter out low-confidence corner points and identify reliable ones. Thus, we found the endpoint of the plasma input tube among all corner points. In addition, the image was input in a circular way. If the pixel value was higher than the threshold value, then the point was a corner point and plotted on the graph; if it was lower than the threshold value, then the point could be discarded directly. Utilizing the identified corner points, we calculated the distance from the previously obtained disc outline to pinpoint the end of the input tube. The endpoint was determined as the corner point that was closest to the disc. Figure 9b shows the identified corner points.
In this study, after obtaining the pixel distance, we converted it to linear distance [26,27]. The triangulation method was employed to calibrate the actual distance as the scaling ratios for the horizontal and vertical directions in the image were not the same, which required calibration of two sets of points to solve the equation. The following two equations were used: The distance of the residual-input tube in practice was derived from the values obtained for d x and d y and the previously obtained pixel distances. The ranging plot is shown in Figure 10, and some of the experimental ranging errors are presented in Table 1. The image processing time was about 60 ms, and the camera field of view was about one-half of the disc so as to ensure that the image was fully processed and cutting was completed. The rotation time of the tray was also controlled to be within 10 s per rotation.
According to Table 1, there was some error in the distance in the X and Y directions. In the X direction, the error was larger, and the measured values had positive and negative values, which was within the expected error. In the Y direction, the error was smaller and met the requirements for practical use.
The distance of the residual-input tube in practice was derived from the values obtained for and and the previously obtained pixel distances. The ranging plot is shown in Figure 10, and some of the experimental ranging errors are presented in Table  1. The image processing time was about 60 ms, and the camera field of view was about one-half of the disc so as to ensure that the image was fully processed and cutting was completed. The rotation time of the tray was also controlled to be within 10 s per rotation. According to Table 1, there was some error in the distance in the X and Y directions. In the X direction, the error was larger, and the measured values had positive and negative values, which was within the expected error. In the Y direction, the error was smaller and met the requirements for practical use.  To minimize identification errors, we conducted image sampling and recognition of the plasma bag every 50 ms using the camera, followed by averaging the obtained parameters for more precise values, which were subsequently relayed to the lead screw slide. To evaluate the efficacy of this approach for enhancing accuracy, we initially conducted sampling upon detection of the plasma bag by the upper photoelectric sensor, after which we intermittently halted the tray rotation every 0.2 s for camera sampling and manual measurement of the input tube position, so as to determine the error magnitude. We repeated the sampling and halting process five times and compared the first sampled value with the mean of six samples, thereby assessing the degree to which the accuracy had been improved. Table 2 shows the positional data of the same plasma bag measured multiple times. The table reveals that during the same experiment, the first sampling may have resulted in relatively large a-directional errors due to the plasma bag not being fully captured by the camera. Therefore, we excluded the first sampling data and averaged the remaining data when calculating the mean error in the a-direction. The b-directional error fluctuated less during each sampling, so we averaged the b-values of the six samplings. The data in the table show that the error was effectively reduced in most cases. However, when the error was already low during the first sampling, there may have been reverse optimization results. Therefore, after weighing the pros and cons of the options, we ultimately chose the mean error method. In actual production processes, a 100% cutting completion rate should be achieved despite larger cutting errors. As the b-directional error was consistently positive, the screw slide only needed to be cut at the averaged b-value to ensure complete cutting.

Control Accuracy
In the system, errors appeared superimposed. To achieve the system's functionality accurately, both the accuracy of the visual inspection and that of the individual actuators needed to be met [28][29][30][31]. Consequently, the accuracy of the individual actuators was verified.
(1) Verification of the accuracy of the reducer stepper motor control.
The accuracy of the reducer stepper motor was crucial for the camera to achieve optimal functionality in terms of capturing sufficient samples and achieving accurate cutting. The reducer stepper motor was equipped with a code plate on the output shaft, enabling the detection of the angle of rotation and closed-loop control of the motor angle. However, speed requirements also needed to be met. Thus, we conducted tests to determine the time required to rotate the same angle in practice.
Two photoelectric sensors were installed at a specific distance apart in the rotation path of the plasma bag tray. They were triggered in sequence as the plasma bag tray rotated, and the timer in the STM32 recorded the duration between the sensor triggers.
The experimental results presented in Figure 11 demonstrate that the average rotation time was 695.5 ms. The graph also shows that the angle fluctuation range of the gearbox stepper motor was small and stable.

Control Accuracy
In the system, errors appeared superimposed. To achieve the system's functionality accurately, both the accuracy of the visual inspection and that of the individual actuators needed to be met [28][29][30][31]. Consequently, the accuracy of the individual actuators was verified.
(1) Verification of the accuracy of the reducer stepper motor control.
The accuracy of the reducer stepper motor was crucial for the camera to achieve optimal functionality in terms of capturing sufficient samples and achieving accurate cutting. The reducer stepper motor was equipped with a code plate on the output shaft, enabling the detection of the angle of rotation and closed-loop control of the motor angle. However, speed requirements also needed to be met. Thus, we conducted tests to determine the time required to rotate the same angle in practice.
Two photoelectric sensors were installed at a specific distance apart in the rotation path of the plasma bag tray. They were triggered in sequence as the plasma bag tray rotated, and the timer in the STM32 recorded the duration between the sensor triggers.
The experimental results presented in Figure 11 demonstrate that the average rotation time was 695.5 ms. The graph also shows that the angle fluctuation range of the gearbox stepper motor was small and stable. Figure 11. Speed-reducer stepper-motor-rotation time-folding diagram.
(2) Verification of the control accuracy of the screw slide Efficiency was one of the important indicators in the system design requirements, and as such, the rotation platform must move quickly. However, due to the significant speed loss associated with the screw structure's conversion of rotary motion to linear motion, it w essential to strike a balance between precise control of the screw slide and increased speed. The more subdivisions the stepping motor had, the more precise it became, Figure 11. Speed-reducer stepper-motor-rotation time-folding diagram.
(2) Verification of the control accuracy of the screw slide Efficiency was one of the important indicators in the system design requirements, and as such, the rotation platform must move quickly. However, due to the significant speed loss associated with the screw structure's conversion of rotary motion to linear motion, it w essential to strike a balance between precise control of the screw slide and increased speed. The more subdivisions the stepping motor had, the more precise it became, but its rotation speed decreased. The table below displays the step angle setting and the time required for the screw slide to move 50 mm. Based on the pitch of the screw rod being 6 mm, we calculated the required number of motor steps and used the proportion of error between the actual and calculated pulse counts to determine the appropriate frequency division pulse. Figure 12 shows that the stepper motor experienced a significant loss of step at a frequency division pulse of 400. However, after removing this data, the remaining data exhibited minor fluctuations and good stability. The system required the slide to travel a maximum distance of 50 mm, had a camera first shot time of 0.3 s and a complete pallet rotation time of 2.5 s, allowing ample time for system movement. Additionally, the error ratio satisfied the selection criteria, and thus the pulse 800 frequency division was selected.

Experimental Effects
In order to validate the performance of the residual-input end-cutting system for plasma bags, we conducted experiments simulating actual plasma-bag conditions. We placed the blood bags in random positions during the freezing process, and after the freezing was completed, we conducted experiments on the experimental platform. During the experiment, we fixed the front end of the plasma bag and randomly placed the input tube, recorded whether the system could cut out the required incision completely, and measured the distance between the cutting incision and the end of the input tube. Some of the experimental data are shown in Table 3. In addition, we also conducted experiments on the cutting effect when the input tube was in contact with the bottom surface. The experimental data are shown in Table 4. The experimental setup for the residual-input end-cutting system for plasma bags is shown in Figure 13. According to the data in the table, the error rate of the incision cut by the system was within 10%, which met the process requirements and achieved the design goal. Additionally, the use of the flexible body kinematics algorithm significantly improved the cutting accuracy when the residual-input tube of the plasma bag was in contact with the bottom surface compared with when no additional algorithm was used.

Experimental Effects
In order to validate the performance of the residual-input end-cutting system for plasma bags, we conducted experiments simulating actual plasma-bag conditions. We placed the blood bags in random positions during the freezing process, and after the freezing was completed, we conducted experiments on the experimental platform. During the experiment, we fixed the front end of the plasma bag and randomly placed the input tube, recorded whether the system could cut out the required incision completely, and measured the distance between the cutting incision and the end of the input tube. Some of the experimental data are shown in Table 3. In addition, we also conducted experiments on the cutting effect when the input tube was in contact with the bottom surface. The experimental data are shown in Table 4. The experimental setup for the residual-input end-cutting system for plasma bags is shown in Figure 13. According to the data in the table, the error rate of the incision cut by the system was within 10%, which met the process requirements and achieved the design goal. Additionally, the use of the flexible body kinematics algorithm significantly improved the cutting accuracy when the residual-input tube of the plasma bag was in contact with the bottom surface compared with when no additional algorithm was used.

Discussion
The paper presents a system that performs detection and execution during its motion process through the collaboration of detection algorithms and driving actuators. The system's detection accuracy, execution accuracy, and overall accuracy are all verified. After repeated testing, the system had some random errors in detection, which were reduced by continuously collecting images and optimizing the average values. Regarding drive execution, the system planned the timing to improve the efficiency of the screw slide movement and achieved a balance between efficiency and precision.
In this paper, we first observed and analyzed the distribution of residual-input tubes in the plasma-bag distribution feature and classified it into two types: residual tube ends rotate normally with the plasma bag and residual tube ends rub against the supporting surface during rotation. In the design of the plasma bag cutting machine, it needs to recognize and cut the residual-input tube ends during the rotation process. When the residual-input tube end rubs against the supporting surface, it produces displacement relative to the plasma bag for some time. To solve this issue, the paper established a coordinate system model based on data collected from multiple images and introduced a soft-body dynamics algorithm to calculate the time required to complete the deformation. After the deformation was completed, images were collected and detected, and the average value was optimized. The cutting component then moved to the calculated value and waited for the residual-input tube to arrive, finally completing the end cutting and

Discussion
The paper presents a system that performs detection and execution during its motion process through the collaboration of detection algorithms and driving actuators. The system's detection accuracy, execution accuracy, and overall accuracy are all verified. After repeated testing, the system had some random errors in detection, which were reduced by continuously collecting images and optimizing the average values. Regarding drive execution, the system planned the timing to improve the efficiency of the screw slide movement and achieved a balance between efficiency and precision.
In this paper, we first observed and analyzed the distribution of residual-input tubes in the plasma-bag distribution feature and classified it into two types: residual tube ends rotate normally with the plasma bag and residual tube ends rub against the supporting surface during rotation. In the design of the plasma bag cutting machine, it needs to recognize and cut the residual-input tube ends during the rotation process. When the residual-input tube end rubs against the supporting surface, it produces displacement relative to the plasma bag for some time. To solve this issue, the paper established a coordinate system model based on data collected from multiple images and introduced a soft-body dynamics algorithm to calculate the time required to complete the deformation. After the deformation was completed, images were collected and detected, and the average value was optimized. The cutting component then moved to the calculated value and waited for the residual-input tube to arrive, finally completing the end cutting and obtaining a more accurate final result.

Conclusions
This study developed a machine-vision-based system for cutting the residual-input tubes of blood-plasma bags. The system included a detection unit and an execution unit. To ensure its precision would meet industrial requirements, we improved the cutting accuracy by reducing identification and driving errors, separately. For identification errors, we used multiple data samples and average the values to reduce end-position identification errors. To address the input tube's contact with the bottom, we applied a soft-body kinematics algorithm to calculate the input tube's required time for stabilization and processed camera sampling and multiple data averaging. We verified the effectiveness of this method by setting up a control group, which improved the system's cutting precision. Regarding driving errors, we performed driving tests on each actuator and verified their stability and accuracy. The experimental results demonstrated that the system could complete the entire process within 2.5 s per bag, with a relative error of less than 10% for the knife distance, and excellent cutting performance of the input tube's knife mouth, which meets the industrial requirements for subsequent blood extraction. This system solves one of the technical challenges in automatic equipment for breaking blood-plasma bags.