A method, system, electronic device and storage medium for counting the number of ampoule bottles

By combining multi-angle image processing and gravity sensor data and intersecting method, the problem of insufficient accuracy and reliability of ampoule quantity statistics in the prior art is solved, and a more efficient and robust statistical effect is achieved.

CN118968402BActive Publication Date: 2025-02-18PEKING UNIVERSITY THIRD HOSPITAL (THE THIRD CLINICAL MEDICAL SCHOOL OF PEKING UNIVERSITY)
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410974329.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2025-02-18
Estimated Expiration
2044-07-19

AI Technical Summary

Technical Problem

The prior art shows that when counting the number of ampoules, the accuracy and reliability are insufficient due to the transparency and overlap of ampoules, especially in complex scenarios and variable external conditions.

Method used

Combining multi-angle image processing and gravity sensor data, the number of ampoules is identified through image processing and the number is inferred by gravity sensor, and the intersection of the two is taken to improve statistical accuracy and efficiency.

Benefits of technology

It improves the accuracy and efficiency of ampoule quantity statistics, enhances the robustness of the system, can adapt to different working environments, and reduces the possibility of manual intervention and human error.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118968402B_ABST
    Figure CN118968402B_ABST
Patent Text Reader

Abstract

A method, system, electronic device and storage medium for counting the number of ampoules, relating to the field of medical devices. In the method, multiple images of ampoules in a detection area are collected from multiple angles to form an image set, with one angle corresponding to at least one image; image processing is performed on the image set, and the processed image set is input into a preset ampoule quantity statistical model to obtain a first ampoule quantity interval; gravity data of a gravity sensor in the detection area is obtained, and a second ampoule quantity interval is obtained based on the gravity data; the number of ampoules in the detection area is determined based on the intersection of the first ampoule quantity interval and the second ampoule quantity interval. The implementation of the technical solution provided by the present application improves the accuracy of quantity statistics.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of medical devices, and in particular to a method, system, electronic device and storage medium for counting the number of ampoules. Background Art

[0002] With the continuous development of the medical industry, ampoules, as common medical packaging containers, are widely used in medical institutions, pharmaceutical factories and other occasions. Due to the large number of ampoules, how to accurately and quickly count the number of ampoules has become an important issue. The traditional manual counting method is inefficient and prone to errors, so there is an urgent need for a method that can automatically count the number of ampoules.

[0003] In existing automation technologies, image recognition technology is usually used to count the number of objects. For example, a camera captures an image of the detection area, and then a computer vision algorithm is used to process the image to identify and count the objects in the image. However, due to the transparency and overlap of ampoules, the accuracy and reliability of a single image processing method still need to be improved. At the same time, existing technologies are unable to cope with complex scenes and changing external conditions.

[0004] Therefore, it is necessary to find a more reliable method for counting the number of ampoules. Summary of the invention

[0005] The present application provides a method, system, electronic device and storage medium for counting the number of ampoules, which combines multi-angle image processing with gravity sensor data to improve the accuracy and efficiency of counting the number of ampoules.

[0006] In a first aspect of the present application, a statistical method for the number of ampoules is provided, which is applied to an ampoule number statistical platform, and the method comprises:

[0007] Collecting multiple images of the ampoule in the detection area from multiple angles to form an image set, wherein one angle corresponds to at least one image;

[0008] Performing image processing on the image set, and inputting the processed image set into a preset ampoule quantity statistical model to obtain a first ampoule quantity interval;

[0009] Acquire gravity data of a gravity sensor in the detection area, and obtain a second ampoule quantity interval according to the gravity data;

[0010] The number of ampoules in the detection area is determined according to the intersection of the first ampoule number interval and the second ampoule number interval.

[0011] By adopting the above technical solution, image processing and gravity sensor data are combined to estimate the number of ampoules from two different dimensions. Image processing can accurately identify the number of ampoules in the image by capturing and analyzing the visual features of ampoules, while the gravity sensor indirectly infers the approximate number of ampoules based on the total weight of the objects in the detection area. The combination of the two can effectively reduce the errors that may be caused by a single method by taking the intersection method, thereby improving the accuracy of statistics. In practical applications, the detection environment may be complex and changeable, such as changes in lighting conditions, irregular arrangement of ampoules, partial occlusion, etc., which may affect the accuracy of image processing. The gravity sensor is not affected by these factors and can provide data stably. Therefore, the combination of the two methods makes the entire statistical system more robust and adaptable to different working environments. By automatically processing images and acquiring gravity data in real time, the number of ampoules can be quickly counted, reducing the need for manual intervention and improving work efficiency. At the same time, the automated processing method also reduces the possibility of human error. Accurate statistics on the number of ampoules can help companies better understand inventory conditions and adjust production and supply chain plans in a timely manner to avoid oversupply or undersupply. This helps optimize resource allocation and improve production efficiency and economic benefits.

[0012] Optionally, determining the number of ampoules in the detection area according to the intersection of the first ampoule number interval and the second ampoule number interval includes:

[0013] Determine all integer values ​​in the intersection of the first ampoule quantity interval and the second ampoule quantity interval, calculate an average value of all the integer values, round the result, and use the rounded result as the ampoule quantity in the detection area.

[0014] By adopting the above technical solution, taking the intersection of the number intervals obtained by two independent methods (image processing and gravity data), and searching for the possible number of ampoules in this intersection, the possible error range has been greatly reduced. Further calculating the average of these possible numbers and rounding the results can further "smooth out" some random errors on this basis, thereby obtaining a number of ampoules that is closer to the true value. In some cases, due to slight fluctuations in image recognition or gravity sensor data, using any one method alone may lead to slight deviations in quantity statistics. By calculating the average of the integers in the intersection and rounding, these fluctuations can be "offset" to a certain extent, making the statistical results more stable and reliable. In the decision-making process such as inventory management and production planning, the accurate number of ampoules is crucial. The number of ampoules obtained by the above method can provide enterprises with more reliable decision-making basis, help enterprises better plan production and supply chain, and reduce waste or shortages caused by inaccurate quantity. This application does not rely on a specific image recognition algorithm or gravity sensor model. As long as the number interval can be output, the final number can be determined by calculating the intersection and average value. Therefore, this method has strong adaptability and can be applied to different devices and scenarios.

[0015] Optionally, before inputting the processed image set into the preset ampoule quantity statistical model to obtain the first ampoule quantity interval, the method further includes training the preset ampoule quantity statistical model, wherein the training of the preset ampoule quantity statistical model includes:

[0016] Acquire a basic sample set of ampoule bottle images, and expand the basic sample set using data enhancement technology to obtain an expanded sample set;

[0017] Inputting the expanded sample set into the convolutional neural network model to be trained to perform semantic segmentation and feature extraction on the images in the expanded sample set through the convolutional neural network model to be trained and output the number of ampoules;

[0018] Construct a loss function to compare the output number of ampoules with the actual number marked in the sample image;

[0019] The parameters of the convolutional neural network model are updated according to the comparison results and the above steps are repeated until the loss function converges, and the final convolutional neural network model is used as the preset ampoule bottle quantity statistical model.

[0020] By adopting the above technical solution and expanding the basic sample set through data enhancement technology, more diverse ampoule images can be generated. These images differ in lighting, angle, occlusion, etc., which helps the CNN model learn more robust feature representation. The use of such diverse training data can significantly improve the generalization ability of the model when facing new samples, that is, the model can more accurately identify the number of ampoules under different conditions. Using the CNN model for semantic segmentation and feature extraction can make full use of the spatial information and texture features in the image to accurately locate and count the ampoules. Through multi-layer convolution and pooling operations, the CNN model can automatically extract high-level features in the image, which are very effective in distinguishing ampoules from other objects. Therefore, the CNN-based ampoule number statistical model usually has a high recognition accuracy. By constructing a loss function and comparing the number of ampoules output by the model with the actual number marked by the sample image, the accuracy of the model prediction can be quantified. By updating the parameters of the CNN model according to the comparison results, the prediction error can be gradually reduced, making the model closer to the actual situation. This gradient descent-based optimization algorithm can efficiently adjust model parameters so that the loss function converges as quickly as possible, thereby obtaining a preset ampoule quantity statistics model with excellent performance. The entire training process is highly automated and can be completed without human intervention. This makes model training more convenient and efficient, while also reducing the impact of human factors on model performance. Automated training also enables the model to continuously learn and adapt to new data distributions, maintaining its accuracy and robustness. By continuously optimizing the CNN model structure and training strategy, the accuracy and efficiency of ampoule quantity statistics can be further improved. This technological innovation not only helps to improve the automation level of existing production lines, but also promotes the application and development of related technologies in other fields, such as item counting and identification in industries such as medical and logistics.

[0021] Optionally, the collecting a plurality of images of the ampoule bottle in the detection area from a plurality of angles to form an image set comprises:

[0022] When there is liquid medicine in the ampoule, the intensity and angle of the light in the detection area are adjusted according to the transparency and color of the liquid medicine in the ampoule.

[0023] By adopting the above technical solution, by adjusting the intensity and angle of the light in the detection area, the lighting conditions can be optimized, and problems such as reflection, shadow and color distortion can be reduced, thereby improving the quality of the collected images. High-quality images contribute to the accuracy and efficiency of subsequent image processing algorithms. The liquid medicine in the ampoule may have different physical and chemical properties, which will affect the features such as the outline, texture and color of the ampoule in the image. By adjusting the lighting according to the transparency and color of the liquid medicine, the ampoule can be made more prominent and easy to identify in the image, thereby improving the accuracy of the number counting. Different types of liquid medicine may have different transparency and color, which puts different requirements on image acquisition. By dynamically adjusting the lighting conditions, it is possible to flexibly adapt to the detection needs of different types of liquid medicine without large-scale modification or adjustment of the system. In an automated production line, accurately and quickly counting the number of ampoules is essential to improving production efficiency and ensuring product quality. By optimizing the lighting conditions to improve image quality and recognition accuracy, this method can reduce false positives and false negatives, thereby improving the overall user experience. With the continuous development of artificial intelligence and machine vision technology, the requirements for intelligent and precise automation of production lines are getting higher and higher. This application introduces a lighting adjustment mechanism to make the image acquisition process more intelligent and adaptive, providing better basic conditions for subsequent image processing and quantity statistics. This intelligent development trend will help promote the automation and intelligence level of the entire production process.

[0024] Optionally, adjusting the intensity and angle of light in the detection area according to the transparency and color of the liquid medicine in the ampoule bottle includes:

[0025] Acquire the color of the liquid medicine in the ampoule via a color sensor, acquire the first light intensity of light passing through the empty ampoule via a first light intensity sensor, and acquire the second light intensity of light passing through the liquid medicine in the ampoule via a second light intensity sensor, and determine the transparency of the liquid medicine according to the first light intensity and the second light intensity;

[0026] Inputting the color and transparency of the liquid medicine into a preset light adjustment model to obtain light parameters, wherein the light parameters include light intensity, light angle and light time, and the preset light adjustment model stores the corresponding relationship between the color and transparency of the liquid medicine and the light parameters;

[0027] The light source of the detection area is adjusted according to the illumination parameter.

[0028] By adopting the above technical solution, the color of the liquid medicine and the light intensity information of the liquid medicine can be accurately obtained through the accurate measurement of the color sensor and the light intensity sensor, and then the transparency of the liquid medicine can be calculated. This information provides a reliable data basis for light adjustment. The preset light adjustment model can output the light parameters that match the current liquid medicine characteristics according to these data, and realize accurate light adjustment. Accurate light adjustment can optimize the light conditions of the detection area, reduce reflections, shadows and color distortion, and improve the quality of the collected images. High-quality images contribute to the accuracy and efficiency of subsequent image processing algorithms and improve the accuracy of ampoule bottle quantity statistics. Different liquid medicine colors and transparency have different requirements for light conditions. By dynamically adjusting the light parameters, the present application can adapt to the detection requirements of different types of liquid medicines and reduce the recognition errors caused by changes in liquid medicine characteristics. This adaptive adjustment mechanism enhances the stability of the recognition system and improves the reliability and robustness of the system. The entire light adjustment process is highly automated and can be completed without human intervention. This reduces the requirements for operator skills and improves the automation level of the production line. At the same time, automated adjustment also reduces the impact of human factors on the detection results and improves the objectivity and accuracy of the detection. With the continuous development of artificial intelligence and machine vision technology, the role of light adjustment in image acquisition and processing is becoming more and more important. This application realizes the intelligent adjustment and optimization of lighting conditions by introducing intelligent elements such as color sensors, light intensity sensors, and preset light adjustment models. This intelligent development trend will help promote the automation and intelligence level of the entire production process. By quickly and accurately adjusting the lighting conditions, this application can shorten the time of image acquisition and processing and improve production efficiency. At the same time, high-quality images and accurate recognition results also help reduce errors and waste in the production process and further improve overall production efficiency.

[0029] Optionally, obtaining the second ampoule quantity interval according to the gravity data includes:

[0030] The target drug solution is matched from the database according to the color and transparency of the drug solution, the total weight of a single ampoule is determined according to the density of the target drug solution and the volume of the ampoule, and the second ampoule quantity interval is determined according to the gravity data and the total weight.

[0031] By adopting the above technical solution, the total weight of a single ampoule can be calculated more accurately by comprehensively considering gravity data, liquid characteristics (color and transparency), and the physical properties of ampoules (density and volume), and the approximate number of ampoules in the detection area can be further derived. This method reduces the errors that may be generated when relying on a single factor (such as gravity data) for quantity statistics, and improves the accuracy of statistics. In practical applications, the types and physical properties of liquid medicines in ampoules may be varied, and the detection environment may also be complex and changeable. By introducing information on liquid medicine characteristics and ampoule properties, the system can better adapt to different situations and reduce statistical errors caused by changes in liquid medicine or environmental interference. This flexibility enhances the robustness of the system, enabling it to maintain stable and accurate performance in a wider range of application scenarios. Accurate ampoule quantity statistics help companies better understand inventory conditions and adjust production and supply chain plans in a timely manner. By comprehensively considering multiple factors to determine the quantity interval, companies can more accurately understand the actual number of ampoules, thereby avoiding over- or under-quantity. This helps optimize resource allocation, reduce waste and costs, and improve production efficiency and economic benefits. Integrating information such as liquid drug characteristics, ampoule bottle properties, and gravity data into the quantity counting process is an important manifestation of intelligent management. This application makes quantity counting more automated and intelligent, reducing the need for manual intervention. At the same time, by continuously collecting and analyzing data, the system can also continuously optimize and adjust the statistical model to further improve the accuracy and efficiency of statistics.

[0032] Optionally, matching the target medicine solution from a database according to the color and transparency of the medicine solution includes:

[0033] Calculating a first similarity between the color of the liquid medicine and each color in the database, and calculating a second similarity between the transparency of the liquid medicine and each transparency in the database;

[0034] The total similarity of the to-be-matched liquids in the database is obtained by weighted summing the first similarity and the second similarity, the first to-be-matched liquid is taken as the target liquid, the first to-be-matched liquid and the second to-be-matched liquid are any two liquids in the database, and the total similarity of the first to-be-matched liquid is greater than the similarity of the second to-be-matched liquid.

[0035] By adopting the above technical solution, by calculating the similarity between the color of the liquid and the color in the database, and the similarity between the transparency of the liquid and the transparency in the database, and weighted summing the two similarities, a comprehensive similarity index can be obtained. This method comprehensively considers the two key attributes of the liquid, making the matching result more accurate. Compared with the traditional method of matching only relying on a single attribute (such as color), the present application can more comprehensively reflect the characteristics of the liquid and reduce the possibility of mismatching. Since the color and transparency of different liquids may vary greatly, and the database may contain information on multiple liquids. By calculating the similarity and sorting, the system can automatically select the target liquid that is most similar to the liquid to be matched. This method enables the system to adapt to the detection requirements of different types of liquids and improves the adaptability and flexibility of the system. By calculating the similarity and performing weighted summing, the system can quickly screen out the candidate liquid that is most similar to the target liquid, reducing the amount of data to be processed later. This method of optimizing the data processing flow improves the processing speed and efficiency of the system, allowing the system to respond to detection requirements more quickly.

[0036] In a second aspect of the present application, a statistical system for the number of ampoules is provided, characterized in that it includes a collection module, an image module, a gravity module and a statistical module, wherein:

[0037] A collection module, configured to collect multiple images of the ampoule bottle in the detection area from multiple angles to form an image set, one angle corresponding to at least one image;

[0038] An image module configured to perform image processing on the image set, and input the processed image set into a preset ampoule quantity statistical model to obtain a first ampoule quantity interval;

[0039] A gravity module configured to obtain gravity data of a gravity sensor in the detection area, and obtain a second ampoule quantity interval according to the gravity data;

[0040] A statistical module is configured to determine the number of ampoules in the detection area according to the intersection of the first ampoule number interval and the second ampoule number interval.

[0041] In the third aspect of the present application, an electronic device is provided, including a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are both used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device executes any one of the methods described above.

[0042] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores instructions, and when the instructions are executed, any of the methods described above is executed.

[0043] In summary, one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:

[0044] 1. Image processing can identify and count the number of ampoules in the image, while gravity data indirectly infers the number of ampoules by measuring the total weight of objects in the detection area. By taking the intersection of the two, the errors that may be caused by a single method can be eliminated, thereby improving the accuracy of statistics; different production environments and conditions may affect the identification and statistics of ampoules, such as lighting changes, obstructions, and the placement of ampoules. By combining image processing and gravity data, this application can better adapt to these changes and enhance the robustness of the statistical system.

[0045] 2. The image is processed through a preset ampoule number statistical model, and gravity data is used for further analysis and inference. This process design makes data processing more efficient and orderly, reduces the need for manual intervention, and improves the degree of automation;

[0046] 3. Accurate statistics of the number of ampoules are crucial for monitoring and management of production lines. By providing reliable statistical results, this application helps companies to understand production conditions in a timely manner, optimize production plans and inventory management. At the same time, the automated statistical process also reduces the burden on operators and improves the overall user experience.

[0047] 4. This application is not only applicable to static detection areas, but can also be extended to dynamic production lines. By combining real-time image acquisition and gravity data monitoring, continuous monitoring and statistics of the number of ampoules on the production line can be achieved to meet application needs in different scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 It is a schematic flow chart of the method for counting the number of ampoules disclosed in the embodiment of the present application;

[0049] Figure 2 It is a module schematic diagram of a statistical system for the number of ampoules disclosed in an embodiment of the present application;

[0050] Figure 3 It is a structural schematic diagram of an electronic device disclosed in an embodiment of the present application.

[0051] Explanation of the reference numerals: 201, acquisition module; 202, image module; 203, gravity module; 204, statistical module; 301, processor; 302, communication bus; 303, user interface; 304, network interface; 305, memory. DETAILED DESCRIPTION

[0052] In order to enable technicians in this field to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments.

[0053] In the description of the embodiments of the present application, words such as "for example" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "for example" or "for example" is intended to present related concepts in a specific way.

[0054] In the description of the embodiments of the present application, the meaning of the term "multiple" refers to two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals. In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. The terms "include", "comprise", "have" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.

[0055] This embodiment discloses a method for counting the number of ampoules, which is applied to an ampoule number counting platform. Figure 1 : is a flow chart of the method for counting the number of ampoules disclosed in the embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:

[0056] S110, collecting multiple images of the ampoule bottle in the detection area from multiple angles to form an image set, where one angle corresponds to at least one image;

[0057] In automated production lines or pharmaceutical packaging processes, accurate counting of ampoules is a key link to ensure product quality and production efficiency. Since ampoules may appear in the inspection area in different directions, positions, and stacking methods, it is often difficult to fully capture the information of all ampoules by capturing images from a single angle. To solve this problem, images need to be captured from multiple angles to more comprehensively cover the inspection area and reduce the possibility of missed detection and false detection. This means that multiple cameras or image acquisition devices need to be set around or above the inspection area to capture images of ampoules from different perspectives. These angles may include the front, side, top, bottom, etc., depending on the layout of the inspection area and the placement of the ampoules. By capturing images from different angles, it can be ensured that the ampoules in the inspection area are clearly displayed in at least one image. At the same time, there may be overlapping or complementary relationships between images at different angles, which helps to more accurately identify and count ampoules in subsequent image processing. In order to improve the reliability and stability of the system, at least one image acquisition device is usually set at each angle, and a redundant design may be used to increase the fault tolerance of the system. Even if a device fails or the image quality is poor, other devices can provide enough information to complete the statistical task. Images collected from multiple angles will be integrated into an image set. This set contains all image information of ampoules in the inspection area at different viewing angles. Each angle corresponds to at least one image, which means that the number of images in the set will depend on the number of acquisition angles and the number of images collected at each angle. The composition of the image set is crucial for subsequent image processing and quantitative statistics because it provides a comprehensive and accurate image data foundation.

[0058] Optionally, the collecting a plurality of images of the ampoule bottle in the detection area from a plurality of angles to form an image set comprises:

[0059] When there is liquid medicine in the ampoule, the intensity and angle of the light in the detection area are adjusted according to the transparency and color of the liquid medicine in the ampoule.

[0060] When the ampoule contains liquid medicine, it may have a significant impact on the acquisition and analysis of the image. The transparency and color of the liquid medicine affect the transmission of light through the ampoule, which in turn affects the clarity and contrast of the image. Liquid medicine with low transparency or darker color may absorb or scatter light, making the image of the ampoule and its internal structure blurred or difficult to identify. In order to overcome the effect of liquid medicine on image acquisition, it is necessary to adjust the intensity and angle of light in the detection area according to the transparency and color of the liquid medicine. Specifically: by increasing or decreasing the brightness of the light source, the amount of light irradiated on the ampoule can be controlled. For liquid medicine with low transparency or darker color, the brightness of the light source may need to be increased to improve the brightness and contrast of the image. However, too high brightness may also cause the image to be overexposed, so appropriate adjustments are required; adjusting the angle between the light source and the ampoule can change the reflection and refraction of light on the surface of the ampoule. By optimizing the angle of the light source, the problem of image blur caused by the absorption or scattering of light by the liquid medicine can be reduced. For example, using oblique light or annular light can reduce the impact of the drug solution on the image quality to a certain extent. In actual operation, it is necessary to comprehensively consider multiple factors such as the material, shape, size of the ampoule, and the transparency and color of the drug solution to develop a suitable image acquisition plan. At the same time, it is also necessary to make appropriate settings and adjustments based on the performance and parameters of the image acquisition equipment to ensure that the quality of the acquired image meets the needs of subsequent processing and analysis.

[0061] The transparency and color of the liquid medicine may directly affect the visibility and clarity of the ampoule in the image. By adjusting the intensity and angle of the light, you can ensure that the light can penetrate the liquid medicine and clearly illuminate the outline and details of the ampoule, thereby generating a higher quality image. This is critical for subsequent image processing and recognition algorithms, as they rely on clear images to accurately identify and count the ampoules. Some liquid medicines may produce reflections or shadows due to the illumination of light, which will increase the difficulty of image processing and may cause misidentification. By fine-tuning the intensity and angle of the light, these unfavorable factors can be reduced or eliminated, making the image clearer and easier to process. The color of the liquid medicine may affect the color contrast and saturation in the image. By adjusting the color and intensity of the light source, the color contrast between the ampoule and the background can be enhanced, making the ampoule more prominent and easier to identify in the image. Due to the improved image quality, the subsequent ampoule counting process will be more accurate and reliable. Clear images help image processing algorithms to more accurately identify and count ampoules, thereby reducing the possibility of errors and missed detections. Different liquid medicines may have different transparency and color characteristics. By dynamically adjusting the intensity and angle of light to accommodate different types of liquid medicine, the present application can increase the flexibility and adaptability of the system, enabling it to function in a wider range of application scenarios.

[0062] Optionally, adjusting the intensity and angle of light in the detection area according to the transparency and color of the liquid medicine in the ampoule bottle includes:

[0063] Acquire the color of the liquid medicine in the ampoule via a color sensor, acquire the first light intensity of light passing through the empty ampoule via a first light intensity sensor, and acquire the second light intensity of light passing through the liquid medicine in the ampoule via a second light intensity sensor, and determine the transparency of the liquid medicine according to the first light intensity and the second light intensity;

[0064] Inputting the color and transparency of the liquid medicine into a preset light adjustment model to obtain light parameters, wherein the light parameters include light intensity, light angle and light time, and the preset light adjustment model stores the corresponding relationship between the color and transparency of the liquid medicine and the light parameters;

[0065] The light source of the detection area is adjusted according to the illumination parameter.

[0066] Use the color sensor to focus on the liquid medicine in the ampoule to obtain its color information such as RGB value or HSL value. When the light source is fixed, use the first light intensity sensor to measure the light intensity of the empty ampoule (i.e., no liquid medicine) under a specific light source, recorded as I 0 Aim the same light source at the ampoule containing the drug solution, and use the second light intensity sensor to measure the light intensity transmitted through the drug solution, recorded as I 1 According to the collected first light intensity I 0 and the second light intensity I 1 , the relative transparency T of the liquid can be calculated. A simple method is to use the ratio: T = I 0 / I 1 . Note that other factors such as light source stability and sensor accuracy may need to be considered in actual calculations, and corresponding corrections may be made. The color value (such as RGB or HSL) of the liquid medicine and the calculated transparency T are used as input to query the preset light adjustment model. Based on the input color and transparency information, the model outputs the corresponding lighting parameters: light intensity (such as brightness percentage), lighting angle (such as the tilt angle relative to the ampoule), and possible lighting time (if the light source supports dynamic on / off control). According to the lighting parameters output by the model, the light source of the detection area is adjusted through the control system. This includes changing the brightness of the light source, adjusting the illumination angle of the light source, and controlling the on / off time of the light source if necessary. After adjusting the light source, the image acquisition device is used again to capture the image of the ampoule, and a preliminary image quality assessment is performed. If the image quality does not meet the requirements (such as unclear ampoule outline, distorted liquid color, etc.), the lighting parameters are fine-tuned according to the evaluation results, and the above steps are repeated until satisfactory image quality is achieved.

[0067] The color sensor and light intensity sensor are used to accurately obtain the color of the liquid and the light intensity information of the liquid, and then determine the transparency of the liquid. This information is input into the preset light adjustment model, and the model calculates the light parameters that are most suitable for the current liquid characteristics according to the corresponding relationship stored internally. This precise matching ensures that the light source setting can minimize the impact of the liquid on image acquisition and improve the clarity and contrast of the image. Dynamic adjustment of light source parameters can effectively reduce problems such as reflection, shadow and color distortion, thereby significantly improving the quality of the image. High-quality images provide a solid foundation for subsequent image processing, feature extraction and quantity statistics, and help reduce the false recognition rate and missed detection rate. Since different batches or types of liquids may have different colors and transparencies, traditional fixed light source settings are often difficult to adapt to such changes. However, the present application enables the system to automatically adapt to different liquid characteristics by real-time detection and dynamic adjustment of light source parameters, thereby enhancing the flexibility and adaptability of the system. Automatic adjustment of light source parameters reduces the need for manual intervention and improves the degree of automation of the production line. At the same time, due to the improvement of image quality and recognition accuracy, the overall efficiency of the production line has also been improved.

[0068] The training process of the preset light adjustment model is as follows:

[0069] Collect samples of ampoules containing liquid medicine of different colors and transparencies. These samples should cover the possible range of colors and transparencies to ensure the generalization ability of the model. Use professional image acquisition equipment to take images of these ampoules under different lighting conditions. The images should clearly reflect the color, transparency and shape of the liquid medicine. Annotate the collected images, including the color and transparency of the liquid medicine and the corresponding optimal lighting parameters (such as light intensity, light angle and light time). The annotation work can be done manually by professionals or with the assistance of automated tools.

[0070] Use color sensors or image processing algorithms to extract color features of the drug solution, such as RGB values, HSV values, etc. Estimate the transparency of the drug solution by comparing the light intensity difference between an empty ampoule and an ampoule filled with drug solution under the same lighting conditions. This can be achieved using a light intensity sensor or image processing algorithm. Use the labeled optimal lighting parameters as the output target of the model and extract its numerical features.

[0071] Choose the appropriate machine learning or deep learning model architecture based on the complexity of the problem and the characteristics of the data. Common models include linear regression, decision tree, random forest, neural network, etc. The input layer of the model should receive the color and transparency characteristics of the liquid medicine, and the output layer should output the optimal lighting parameters. For deep learning models, it is necessary to design appropriate hidden layer structures and activation functions to capture the complex relationship between input and output.

[0072] The collected data set is divided into training set, validation set and test set for model training, validation and testing. The model is trained using the training set data, and the model parameters are adjusted through optimization algorithms (such as gradient descent) to minimize the prediction error. The performance of the model is evaluated using the validation set data, and the parameters are tuned as needed. The tuning process may include adjusting the model architecture, increasing the number of training rounds, changing the learning rate, etc. Finally, the final performance of the model is evaluated using the test set data. Evaluation indicators may include prediction accuracy, generalization ability, etc.

[0073] S120, performing image processing on the image set, and inputting the processed image set into a preset ampoule quantity statistical model to obtain a first ampoule quantity interval;

[0074] Each image in the image collection is preprocessed to improve image quality and remove noise. This includes, but is not limited to, steps such as image enhancement (such as contrast adjustment, sharpening), image denoising (such as median filtering, Gaussian filtering), and image cropping (removing irrelevant background information). The purpose of preprocessing is to provide high-quality image data for subsequent feature extraction and recognition. Feature extraction is performed on the preprocessed image. These features can be color-based (such as a specific color range of an ampoule), shape-based (such as a circular or elliptical outline), texture-based (such as a unique texture of a liquid medicine), or any other features that help distinguish an ampoule from the background. The purpose of feature extraction is to convert useful information in the image into a format that can be used for quantitative statistics. Using the extracted features, separate the ampoule from the background in the image. This is usually achieved through image segmentation algorithms, such as threshold segmentation, edge detection, region growing, etc. The purpose of image segmentation is to extract each ampoule as an independent object for quantitative statistics. The preset ampoule count model is a pre-trained machine learning (or deep learning) model used to count the number of ampoules based on the features of the processed image collection. The model may be a classifier (used to distinguish between ampoules and non-ampoule objects), a regressor (used to predict the number of ampoules), or a more complex network structure (such as an object detection network that can simultaneously locate and count ampoules). Input the image collection after image processing into the preset ampoule count model. The model will identify and count the ampoules in each image. After the model has processed all images, it will output a statistical result of the number of ampoules. This result may be a specific value, but in some cases, due to image quality, model performance, or the complexity of ampoule distribution, the model may give a number interval (i.e., the first ampoule number interval) indicating the possible range of the number of ampoules.

[0075] Optionally, before inputting the processed image set into the preset ampoule quantity statistical model to obtain the first ampoule quantity interval, the method further includes training the preset ampoule quantity statistical model, wherein the training of the preset ampoule quantity statistical model includes:

[0076] Acquire a basic sample set of ampoule bottle images, and expand the basic sample set using data enhancement technology to obtain an expanded sample set;

[0077] Inputting the expanded sample set into the convolutional neural network model to be trained to perform semantic segmentation and feature extraction on the images in the expanded sample set through the convolutional neural network model to be trained and output the number of ampoules;

[0078] Construct a loss function to compare the output number of ampoules with the actual number marked in the sample image;

[0079] The parameters of the convolutional neural network model are updated according to the comparison results and the above steps are repeated until the loss function converges, and the final convolutional neural network model is used as the preset ampoule bottle quantity statistical model.

[0080] Collect a basic sample set containing ampoule images. These samples should cover ampoule images at different angles, lighting conditions, and background complexity to ensure the generalization ability of the model. In order to further increase the diversity and number of samples, the basic sample set is expanded using data augmentation techniques. Data augmentation techniques include but are not limited to rotation, scaling, translation, flipping, adding noise, adjusting brightness and contrast, etc. These operations can generate a large number of images that are similar to the original samples but not exactly the same, which helps to improve the robustness and accuracy of the model. Convolutional neural network (CNN) was selected as the model to be trained because of its outstanding performance in the field of image processing. CNN can automatically extract hierarchical feature representations from images and is very suitable for image segmentation and recognition tasks. During the training process, the CNN model performs semantic segmentation on each image in the augmented sample set, that is, classifying each pixel or region in the image as an ampoule or background. At the same time, the model also performs feature extraction to capture key features such as the shape, size, and color of the ampoule. Based on the results of semantic segmentation, the model can calculate the number of ampoules in the image as output. In order to evaluate the difference between the number of ampoules output by the model and the actual number marked by the sample image, a loss function needs to be constructed. Common loss functions include mean square error (MSE), cross entropy loss, etc. In this task, a loss function that can directly reflect the accuracy of quantity prediction may be selected. According to the calculation results of the loss function, the parameters of the CNN model are updated using the back propagation algorithm. This process is repeated for multiple iterations until the loss function converges, that is, the performance of the model on the validation set is no longer significantly improved. During the training process, the dataset is usually divided into training set, validation set, and test set. The validation set is used to evaluate the performance of the model during the training process, so as to perform operations such as early stopping and parameter adjustment. The test set is used to evaluate the final performance of the model after the training is completed. When the loss function converges, the CNN model at this time is selected as the preset ampoule number statistical model. This model will be used in subsequent practical applications to count the number of ampoules on the processed image set.

[0081] By expanding the basic sample set through data enhancement technology, a large amount of diverse training data can be generated. These data cover a variety of factors such as different lighting conditions, angles, occlusions, etc., so that the model can learn richer feature representations during the training process, thereby improving the model's generalization ability for unknown data. This is of great significance for processing ampoule images in various complex scenes in practical applications. Using the CNN model for semantic segmentation and feature extraction, the ampoules in the image can be accurately distinguished from the background or other objects, and the number of ampoules can be accurately calculated. By automatically learning the hierarchical feature representation in the image, the CNN model can capture the unique shape, texture and other features of the ampoules, thereby achieving high-precision statistics on the number of ampoules. By constructing a loss function and continuously optimizing the parameters of the CNN model, the model can gradually approach the distribution of real data during the training process, thereby improving the prediction performance of the model. At the same time, using optimization algorithms such as gradient descent to iteratively update the model parameters can accelerate the convergence speed of the model and shorten the training time. During the training process, by continuously comparing the number of ampoules output by the model with the actual number marked in the sample image, and adjusting the model parameters according to the comparison results, the model can have a certain tolerance for various errors and noises. This mechanism enhances the robustness of the model, allowing the model to better cope with various complex situations in practical applications.

[0082] S130, acquiring gravity data of a gravity sensor in the detection area, and obtaining a second ampoule quantity interval according to the gravity data;

[0083] Since environmental factors (such as vibration, temperature changes, etc.) may cause noise in gravity data, it is necessary to remove these noises through methods such as filtering to ensure the accuracy of the data. Gravity sensors may drift or offset after long-term use, so regular calibration is required to ensure the accuracy of the measurement results. Extract features that reflect the number of ampoules from the processed gravity data. These features may include the amplitude, frequency, duration, etc. of gravity changes. Based on the extracted features, an algorithm or model can be built to estimate the number of ampoules. Establish a correspondence between gravity data features and the number of ampoules through experiments or simulations. This may require measuring gravity data under different numbers of ampoules and observing how the data features change with the number of ampoules. Once the correspondence is established, algorithms (such as regression analysis, machine learning algorithms, etc.) can be applied to estimate the number of ampoules based on gravity data features. Due to factors such as measurement errors, sensor accuracy limitations, and weight differences between ampoules, the estimated number of ampoules may be an interval rather than an exact value. Therefore, the algorithm outputs a second ampoule quantity interval, which represents the possible range of the ampoule quantity.

[0084] Optionally, obtaining the second ampoule quantity interval according to the gravity data includes:

[0085] The target drug solution is matched from the database according to the color and transparency of the drug solution, the total weight of a single ampoule is determined according to the density of the target drug solution and the volume of the ampoule, and the second ampoule quantity interval is determined according to the gravity data and the total weight.

[0086] According to the color and transparency information of the liquid medicine, the target liquid medicine is matched from the pre-established database. This database should contain the physical characteristics of various liquid medicines, such as color, transparency, density, and the corresponding ampoule type and volume. By comparing the color and transparency, the target liquid medicine can be located more accurately and its related physical parameters can be obtained. When the target liquid medicine is determined, the total weight of a single ampoule can be calculated based on the density of the target liquid medicine and the volume of the ampoule. The density of the liquid medicine is the mass per unit volume, and the mass of the liquid medicine can be obtained by multiplying it by the volume of the ampoule. Adding the weight of the ampoule itself (which is usually a known value or can be obtained from the database), the total weight of a single ampoule can be obtained. The gravity data measured by the gravity sensor in the detection area is used to determine the number interval of the ampoules. Since the gravity sensor measures the total gravity of the entire detection area, it is necessary to divide the measured total gravity by the total weight of a single ampoule to estimate the number of ampoules. However, due to measurement errors, sensor accuracy limitations, and possible weight differences between ampoules, the estimated quantity may be an approximation. In order to obtain a more accurate quantity interval, the following factors can be considered: the measurement results of the gravity sensor may have a certain error range, which will affect the accuracy of the quantity estimation, so this error range needs to be considered when calculating the quantity; even for the same liquid medicine and the same type of ampoule, due to slight differences in the production process, the weight of the ampoules may be slightly different, which will also affect the accuracy of the quantity estimation; there may be other objects (such as residues, dust, etc.) in the detection area, which will affect the gravity measurement results. Therefore, these interference factors need to be excluded when calculating the quantity.

[0087] By considering the density of the liquid medicine and the volume of the ampoule, the total weight of a single ampoule can be calculated. This information combined with gravity data can more accurately estimate the number of ampoules. Compared with the method that relies only on gravity data without considering the characteristics of the liquid medicine, the present application can reduce the estimation error. The color, transparency and density of different liquid medicines may be different, and these characteristics will affect the total weight of the ampoule. By matching the target liquid medicine from the database and obtaining its density information, the present application can adapt to the weight estimation of different types of liquid medicines, improving the flexibility and adaptability of the system. The present application relies on the liquid medicine density information and the volume data of the ampoule in the database, which are obtained through experiments or measurements and have high accuracy and reliability. Therefore, the estimation based on these data is more scientific and reasonable, which helps enterprises make more accurate production decisions. The entire estimation process can be automated through programming, reducing manual intervention and errors. When a new ampoule or liquid medicine enters the production line, only the relevant information needs to be added to the database, and the system can automatically match and estimate, improving production efficiency and accuracy. The present application can be used as an auxiliary verification method for quantitative statistical methods based on image processing or other technologies. By comparing the results obtained by different methods, the accuracy and reliability of quantity statistics can be further verified and optimized. At the same time, this application can also provide strong support for quality control and inventory management in the production process.

[0088] Optionally, matching the target medicine solution from a database according to the color and transparency of the medicine solution includes:

[0089] Calculating a first similarity between the color of the liquid medicine and each color in the database, and calculating a second similarity between the transparency of the liquid medicine and each transparency in the database;

[0090] The total similarity of the to-be-matched liquids in the database is obtained by weighted summing the first similarity and the second similarity, the first to-be-matched liquid is taken as the target liquid, the first to-be-matched liquid and the second to-be-matched liquid are any two liquids in the database, and the total similarity of the first to-be-matched liquid is greater than the similarity of the second to-be-matched liquid.

[0091] The color features of the liquid medicine are extracted and compared with the color features of each liquid medicine stored in the database. The color features can be extracted by a variety of methods, such as color histogram, color moment, etc. Then, an appropriate similarity measurement method (such as Euclidean distance, cosine similarity, etc.) is used to calculate the first similarity between the liquid medicine color and each color in the database. This similarity value reflects the closeness between the liquid medicine color and the color in the database. Similar to the color similarity calculation, the transparency features of the liquid medicine also need to be extracted and compared with the transparency features of each liquid medicine stored in the database. The transparency feature can be obtained by measuring the transmittance or reflectance of the liquid medicine to light. Similarly, a similarity measurement method is used to calculate the second similarity between the liquid medicine transparency and each transparency in the database. This similarity value reflects the closeness between the liquid medicine transparency and the transparency in the database. After obtaining the first similarity between the liquid medicine color and each color in the database, and the second similarity between the liquid medicine transparency and each transparency in the database, the two similarities need to be weighted and summed to obtain the total similarity of the liquid medicine to be matched in the database. The choice of weight depends on the importance of color and transparency in the matching process. Generally speaking, if color information is more critical, the weight of color can be set higher; vice versa. Finally, the total similarities of all the to-be-matched liquids in the database are compared, and the liquid with the highest total similarity is selected as the target liquid. The first to-be-matched liquid and the second to-be-matched liquid are any two liquids in the database, but according to the result of weighted summation, the total similarity of the first to-be-matched liquid is greater than the similarity of the second to-be-matched liquid, so it is selected as the target liquid.

[0092] By calculating the similarity between the color and transparency of the liquid and each liquid stored in the database, the closest match to the target liquid can be accurately found. This method is more accurate than simple keyword matching or classification matching because it takes into account two important physical properties of the liquid. Color and transparency are two important visual features of the liquid, which together determine the appearance of the liquid. Incorporating these two features into the matching algorithm, the liquid can be considered from multiple dimensions, thereby more comprehensively evaluating the similarity of the liquid. When calculating the total similarity, the importance of different features can be adjusted according to actual needs by weighted summing the similarities of color and transparency. For example, if color is more important for distinguishing different liquids, a higher weight can be given to color similarity. This flexibility enables the algorithm to adapt to different application scenarios and needs. The entire matching process can be automated through programming, reducing manual intervention and errors. When it is necessary to match a liquid that has just entered the system, just enter its color and transparency information into the system, and the system will automatically match and give the result, improving processing efficiency and accuracy.

[0093] S140: Determine the number of ampoules in the detection area according to the intersection of the first ampoule number interval and the second ampoule number interval.

[0094] Optionally, determining the number of ampoules in the detection area according to the intersection of the first ampoule number interval and the second ampoule number interval includes:

[0095] Determine all integer values ​​in the intersection of the first ampoule quantity interval and the second ampoule quantity interval, calculate an average value of all the integer values, round the result, and use the rounded result as the ampoule quantity in the detection area.

[0096] The number interval given by image processing is [85, 95], and the number interval given by gravity data is [90, 100]. Determine the intersection of these two intervals as [90, 95]. List all integer values ​​in the intersection [90, 95], that is, {90, 91, 92, 93, 94, 95}. Calculate the average of these integer values. Average = (90+91+92+93+94+95) / 6=92.5. Since the number of ampoules must be an integer, the average needs to be rounded. Here, you can choose to round up (i.e., ceiling function), round down (i.e., floor function), or round to the nearest integer. For simplicity, choose to round to the nearest integer, i.e., 93. Finally, the rounded result (93) is used as the number of ampoules in the detection area.

[0097] By considering only the integer values ​​in the intersection, the possible quantity is actually limited to a more precise range. Because in actual scenarios, the number of ampoules must be an integer, this method is more in line with the actual situation. At the same time, calculating the average of these integer values ​​and rounding can further reduce errors and improve the accuracy of the final quantity. Since the average of all possible integer values ​​is calculated before rounding, this method helps to reduce the final quantity deviation caused by the estimation bias of a single method. The average value tends to better reflect the central trend of the data, so by calculating the average value and rounding to determine the final quantity, the deviation of individual estimates can be offset to a certain extent. When the intersection of two quantity intervals is large, there may be more integer values, which helps to increase the stability of the final quantity determination. Because even if one or some integer values ​​deviate from the true value for some reason, the existence of other integer values ​​will make the final average value closer to the true quantity. By simplifying the complex quantity estimation problem to a specific integer value, this method provides a clearer and more direct basis for the company's production decision-making. The company can arrange production plans, adjust inventory, etc. based on the final number of ampoules. The entire process can be automated through programming, reducing the possibility of manual intervention and errors. When new data is input into the system, the system can automatically perform interval intersection calculation, integer value selection, average value calculation and rounding, and quickly give the final quantitative result.

[0098] This embodiment also discloses a statistical system for the number of ampoules. Figure 2 is a schematic diagram of a module of a statistical system for the number of ampoules disclosed in an embodiment of the present application, such as Figure 2 As shown, the system includes a collection module 201, an image module 202, a gravity module 203 and a statistics module 204, wherein:

[0099] The acquisition module 201 is configured to acquire multiple images of the ampoule bottle in the detection area from multiple angles to form an image set, and one angle corresponds to at least one image;

[0100] An image module 202 is configured to perform image processing on the image set, and input the processed image set into a preset ampoule quantity statistical model to obtain a first ampoule quantity interval;

[0101] A gravity module 203 is configured to obtain gravity data of a gravity sensor in the detection area, and obtain a second ampoule quantity interval according to the gravity data;

[0102] The statistical module 204 is configured to determine the number of ampoules in the detection area according to the intersection of the first ampoule number interval and the second ampoule number interval.

[0103] Optionally, the statistics module 204 is configured to:

[0104] Determine all integer values ​​in the intersection of the first ampoule quantity interval and the second ampoule quantity interval, calculate an average value of all the integer values, round the result, and use the rounded result as the ampoule quantity in the detection area.

[0105] Optionally, the statistical system further includes a training module, wherein the training module is configured to:

[0106] Acquire a basic sample set of ampoule bottle images, and expand the basic sample set using data enhancement technology to obtain an expanded sample set;

[0107] Inputting the expanded sample set into the convolutional neural network model to be trained to perform semantic segmentation and feature extraction on the images in the expanded sample set through the convolutional neural network model to be trained and output the number of ampoules;

[0108] Construct a loss function to compare the output number of ampoules with the actual number marked in the sample image;

[0109] The parameters of the convolutional neural network model are updated according to the comparison results and the above steps are repeated until the loss function converges, and the final convolutional neural network model is used as the preset ampoule bottle quantity statistical model.

[0110] Optionally, the acquisition module 201 is configured to:

[0111] When there is liquid medicine in the ampoule, the intensity and angle of the light in the detection area are adjusted according to the transparency and color of the liquid medicine in the ampoule.

[0112] Optionally, the acquisition module 201 is configured to:

[0113] Acquire the color of the liquid medicine in the ampoule via a color sensor, acquire the first light intensity of light passing through the empty ampoule via a first light intensity sensor, and acquire the second light intensity of light passing through the liquid medicine in the ampoule via a second light intensity sensor, and determine the transparency of the liquid medicine according to the first light intensity and the second light intensity;

[0114] Inputting the color and transparency of the liquid medicine into a preset light adjustment model to obtain light parameters, wherein the light parameters include light intensity, light angle and light time, and the preset light adjustment model stores the corresponding relationship between the color and transparency of the liquid medicine and the light parameters;

[0115] The light source of the detection area is adjusted according to the illumination parameter.

[0116] Optionally, the gravity module 203 is configured to:

[0117] The target drug solution is matched from the database according to the color and transparency of the drug solution, the total weight of a single ampoule is determined according to the density of the target drug solution and the volume of the ampoule, and the second ampoule quantity interval is determined according to the gravity data and the total weight.

[0118] Optionally, the gravity module 203 is configured to:

[0119] Calculating a first similarity between the color of the liquid medicine and each color in the database, and calculating a second similarity between the transparency of the liquid medicine and each transparency in the database;

[0120] The total similarity of the to-be-matched liquids in the database is obtained by weighted summing the first similarity and the second similarity, the first to-be-matched liquid is taken as the target liquid, the first to-be-matched liquid and the second to-be-matched liquid are any two liquids in the database, and the total similarity of the first to-be-matched liquid is greater than the similarity of the second to-be-matched liquid.

[0121] It should be noted that: when the device provided in the above embodiment realizes its function, only the division of the above functional modules is used as an example. In actual application, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0122] This embodiment also discloses an electronic device, referring to Figure 3 The electronic device may include: at least one processor 301 , at least one communication bus 302 , a user interface 303 , a network interface 304 , and at least one memory 305 .

[0123] The communication bus 302 is used to realize the connection and communication between these components.

[0124] The user interface 303 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 303 may also include a standard wired interface and a wireless interface.

[0125] The network interface 304 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0126] Among them, the processor 301 may include one or more processing cores. The processor 301 uses various interfaces and lines to connect various parts in the entire server, and executes various functions of the server and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 305, and calling data stored in the memory 305. Optionally, the processor 301 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 301 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 301, and it can be implemented separately through a chip.

[0127] Among them, the memory 305 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 305 includes a non-transitory computer-readable storage medium. The memory 305 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 305 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 305 may also be optionally at least one storage device located away from the aforementioned processor 301. As Figure 3 As shown, the memory 305 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an application program for a method for counting the number of ampoules.

[0128] exist Figure 3In the electronic device shown, the user interface 303 is mainly used to provide an input interface for the user and obtain data input by the user; and the processor 301 can be used to call the application program for storing the statistical method of the number of ampoules in the memory 305. When executed by one or more processors 301, the electronic device executes one or more methods in the above-mentioned embodiments.

[0129] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required for the present application.

[0130] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0131] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.

[0132] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0133] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0134] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory 305 and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory 305 includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk.

[0135] The above is only an exemplary embodiment of the present disclosure and cannot be used to limit the scope of the present disclosure. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the disclosure of the specification, those skilled in the art will easily think of other embodiments of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field that are not recorded in the present disclosure. The description and examples are only regarded as exemplary, and the scope and spirit of the present disclosure are defined by the claims.

Claims

1. A method for counting the number of ampoules, characterized in that: Applied to an ampoule quantity counting platform, the method comprises: Collecting multiple images of the ampoule in the detection area from multiple angles to form an image set, wherein one angle corresponds to at least one image; Performing image processing on the image set, and inputting the processed image set into a preset ampoule quantity statistical model to obtain a first ampoule quantity interval; Acquire gravity data of a gravity sensor in the detection area, and obtain a second ampoule quantity interval according to the gravity data; determining the number of ampoules in the detection area according to the intersection of the first ampoule number interval and the second ampoule number interval, The step of acquiring multiple images of the ampoule bottle in the detection area from multiple angles to form an image set includes: When there is liquid medicine in the ampoule, the intensity and angle of the light in the detection area are adjusted according to the transparency and color of the liquid medicine in the ampoule. The step of adjusting the intensity and angle of light in the detection area according to the transparency and color of the liquid medicine in the ampoule bottle comprises: Acquire the color of the liquid medicine in the ampoule via a color sensor, acquire the first light intensity of light passing through the empty ampoule via a first light intensity sensor, and acquire the second light intensity of light passing through the liquid medicine in the ampoule via a second light intensity sensor, and determine the transparency of the liquid medicine according to the first light intensity and the second light intensity; Inputting the color and transparency of the liquid medicine into a preset light adjustment model to obtain light parameters, wherein the light parameters include light intensity, light angle and light time, and the preset light adjustment model stores the corresponding relationship between the color and transparency of the liquid medicine and the light parameters; The light source of the detection area is adjusted according to the illumination parameter.

2. The method for counting the number of ampoules according to claim 1, characterized in that: The determining the number of ampoules in the detection area according to the intersection of the first ampoule number interval and the second ampoule number interval comprises: Determine all integer values ​​in the intersection of the first ampoule quantity interval and the second ampoule quantity interval, calculate an average value of all the integer values, round the result, and use the rounded result as the ampoule quantity in the detection area.

3. The method for counting the number of ampoules according to claim 1, characterized in that: Before inputting the processed image set into the preset ampoule quantity statistical model to obtain the first ampoule quantity interval, the method further includes training the preset ampoule quantity statistical model, wherein the training of the preset ampoule quantity statistical model includes: Acquire a basic sample set of ampoule bottle images, and expand the basic sample set using data enhancement technology to obtain an expanded sample set; Inputting the expanded sample set into the convolutional neural network model to be trained to perform semantic segmentation and feature extraction on the images in the expanded sample set through the convolutional neural network model to be trained and output the number of ampoules; Construct a loss function to compare the output number of ampoules with the actual number marked in the sample image; The parameters of the convolutional neural network model are updated according to the comparison results and the above steps are repeated until the loss function converges, and the final convolutional neural network model is used as the preset ampoule bottle quantity statistical model.

4. The method for counting the number of ampoules according to claim 1, characterized in that: The step of obtaining the second ampoule quantity interval according to the gravity data comprises: The target drug solution is matched from the database according to the color and transparency of the drug solution, the total weight of a single ampoule is determined according to the density of the target drug solution and the volume of the ampoule, and the second ampoule quantity interval is determined according to the gravity data and the total weight.

5. The method for counting the number of ampoules according to claim 4, characterized in that: The matching of the target liquid medicine from the database according to the color and transparency of the liquid medicine comprises: Calculating a first similarity between the color of the liquid medicine and each color in the database, and calculating a second similarity between the transparency of the liquid medicine and each transparency in the database; The total similarity of the to-be-matched liquids in the database is obtained by weighted summing the first similarity and the second similarity, the first to-be-matched liquid is taken as the target liquid, the first to-be-matched liquid and the second to-be-matched liquid are any two liquids in the database, and the total similarity of the first to-be-matched liquid is greater than the similarity of the second to-be-matched liquid.

6. A statistical system for the number of ampoules, characterized in that: It includes acquisition module, image module, gravity module and statistics module, among which: A collection module configured to collect multiple images of the ampoule bottle in the detection area from multiple angles to form an image set, where one angle corresponds to at least one image; An image module configured to perform image processing on the image set, and input the processed image set into a preset ampoule quantity statistical model to obtain a first ampoule quantity interval; A gravity module configured to obtain gravity data of a gravity sensor in the detection area, and obtain a second ampoule quantity interval according to the gravity data; a statistical module configured to determine the number of ampoules in the detection area according to the intersection of the first ampoule number interval and the second ampoule number interval, The step of acquiring multiple images of the ampoule bottle in the detection area from multiple angles to form an image set includes: When there is liquid medicine in the ampoule, the intensity and angle of the light in the detection area are adjusted according to the transparency and color of the liquid medicine in the ampoule. The step of adjusting the intensity and angle of light in the detection area according to the transparency and color of the liquid medicine in the ampoule bottle comprises: Acquire the color of the liquid medicine in the ampoule via a color sensor, acquire the first light intensity of light passing through the empty ampoule via a first light intensity sensor, and acquire the second light intensity of light passing through the liquid medicine in the ampoule via a second light intensity sensor, and determine the transparency of the liquid medicine according to the first light intensity and the second light intensity; Inputting the color and transparency of the liquid medicine into a preset light adjustment model to obtain light parameters, wherein the light parameters include light intensity, light angle and light time, and the preset light adjustment model stores the corresponding relationship between the color and transparency of the liquid medicine and the light parameters; The light source of the detection area is adjusted according to the illumination parameter.

7. An electronic device, characterized in that: It includes a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are both used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device executes the method as described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed, the method according to any one of claims 1 to 5 is performed.

Citation Information

Patent Citations

  • Method, apparatus and device for determining number of objects, and computer readable medium

    CN111754450A

  • Object recognition method and system and electronic equipment

    CN112184751A