Vision-based method, device and readable medium for counting bottles on a filling production line
Through visual recognition and correction distance calculation, accurate counting of inverted bottles on the filling production line is achieved, solving the problem of inefficiency and difficult to identify bottles in traditional methods, and improving the automation and counting accuracy of the production line.
Patent Information
- Application Number
- CN202411066775.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2044-08-06
AI Technical Summary
The traditional invoice counting method is inefficient in filling production lines and is susceptible to environmental interference and human error, especially in the case of identical bottles and stop-and-go production lines.
Using the visual-based counting method, by obtaining the video stream pictures of the filling production line, identifying and marking the bottle inverting coordinates, generating a detection box, calculating the correction distance value, determining the moving distance of the production line, and counting the bottle inverting based on this information to avoid The need to use a unique logo for bottles.
It improves the automation level of the filling production line and the accuracy of counting bottle counting, adapts to different models and production environments, reduces manual intervention, and enhances the work efficiency of the production line and the universality of counting.
Smart Images

Figure CN118587213B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of machine vision, and in particular to a method, a device and a readable medium for counting bottles on a filling production line based on vision. Background Art
[0002] In a filling production line, accurate counting of inverted bottles is a key link to ensure production efficiency and product quality. Traditional methods for counting inverted bottles usually rely on manual observation or simple mechanical sensors, which are not only inefficient but also susceptible to environmental interference and human errors. Chinese patent CN114972188A provides a method, device and electronic device for counting target objects based on image processing, wherein the number of multiple target objects is updated when the distance difference between the center position of a target object located in a set layer in the current image frame and the center point position in the previous image frame is greater than or equal to a preset threshold. However, in a filling production line, the bottles are exactly the same, and it is impossible to mark the bottles with a unique identifier, so that the same bottle in two adjacent frames of images cannot be identified. Furthermore, since the filling production line has a stop-and-go situation, the moving distance of the filling production line in the same time period is different, and it is difficult to identify the same bottle in two adjacent frames of images by setting a fixed moving distance of the bottle according to the moving distance of the filling production line.
[0003] Therefore, it is necessary to develop a vision-based algorithm for counting bottles on the filling production line to solve the problem that the bottles on the filling production line are exactly the same and cannot be counted by setting the moving distance of the bottles on the stop-and-go filling production line, so as to improve the automation level of the production line and the accuracy of the bottle counting. Summary of the invention
[0004] The purpose of this application is to propose a vision-based method, device and readable medium for counting bottles on a filling production line in response to the above-mentioned technical problems.
[0005] In a first aspect, the present invention provides a method for counting bottles on a filling production line based on vision, comprising the following steps:
[0006] Obtain a current frame video stream image of the filling production line, identify and mark the coordinates of all inverted bottles in the current frame video stream image, the coordinates of all inverted bottles constitute an inverted bottle coordinate array, and set a dividing line on the current frame video stream image, the inverted bottles include the first inverted bottle located below the dividing line;
[0007] Traverse the first inverted bottle, generate a detection frame upward based on the first inverted bottle, obtain the coordinates of the second inverted bottle that is located in the detection frame in the previous frame of the video stream and is closest to the coordinates of the first inverted bottle that generates the detection frame, and calculate the corrected distance value between the coordinates of the second inverted bottle and the coordinates of the first inverted bottle corresponding to it;
[0008] Determine the moving distance of the filling production line between the moment of acquiring the current frame video stream image and the moment of acquiring the previous frame video stream image according to all the corrected distance values;
[0009] The inverted bottles are counted according to the coordinates of the first inverted bottle, the coordinates of the second inverted bottle corresponding to the first inverted bottle, the correction distance value and the moving distance of the filling production line.
[0010] Preferably, generating a detection frame based on the first bottle-inverting upward step specifically includes:
[0011] According to the coordinates of the first inverted bottle, a rectangular frame is constructed upward for the first inverted bottle. The width of the rectangular frame is equal to the sum of the width of the circumscribed rectangular frame of the first inverted bottle and the correction parameter. The length of the rectangular frame is less than or equal to the distance from the center of the circumscribed rectangular frame of the first inverted bottle to the top of the current frame video stream image. The rectangular frame is used as the detection frame.
[0012] Preferably, obtaining the coordinates of a second inverted bottle that is located in the detection frame in the previous frame of the video stream and is closest to the coordinates of the first inverted bottle that generates the detection frame, and calculating the correction distance value between the coordinates of the second inverted bottle and the coordinates of the first inverted bottle corresponding to it, specifically includes:
[0013] Get the coordinates of all inverted bottles within the detection frame in the previous frame of the video stream;
[0014] Calculate the distance between the coordinates of all inverted bottles located in the detection frame in the previous frame of the video stream and the coordinates of the first inverted bottle that generates the detection frame, and select the inverted bottle with the smallest distance value as the second inverted bottle;
[0015] Calculate the corrected distance between the coordinates of the second inverted bottle and the coordinates of the first inverted bottle corresponding to it. The calculation formula is as follows:
[0016] ;
[0017] in, Indicates the Y value of the first inverted bottle. represents the coordinate Y value of the second inverted bottle, r represents the error tolerance parameter, and round represents rounding;
[0018] Move the coordinates of the first inverted bottle and the coordinates of the second inverted bottle out of the inverted bottle coordinate array.
[0019] Preferably, the error tolerance parameter r is 5.
[0020] Preferably, determining the moving distance of the filling production line between the time of acquiring the current frame video stream image and the previous frame video stream image according to all the corrected distance values specifically includes:
[0021] According to all the correction distance values, the number of occurrences of each correction distance value is counted. If there is only one correction distance value corresponding to the largest number of occurrences, the correction distance value with the largest number of occurrences will be used as the moving distance of the filling production line between the time when the current frame video stream image is obtained and the previous frame video stream image is obtained. Otherwise, the correction distance value with the largest number of occurrences and the smallest value will be used as the moving distance of the filling production line between the time when the current frame video stream image is obtained and the previous frame video stream image.
[0022] Preferably, counting the inverted bottles is performed according to the coordinates of the first inverted bottle, the coordinates of the second inverted bottle corresponding to the first inverted bottle, the correction distance value and the moving distance of the filling production line, specifically including:
[0023] In response to determining that the coordinates of the second inverted bottle are located above the dividing line, it is determined whether the correction distance value is equal to the moving distance of the filling production line, if so, the inverted bottle count is increased by one, otherwise the first inverted bottle and the second inverted bottle are not the same inverted bottle, and no counting is performed;
[0024] In response to determining that the coordinates of the second inverted bottle are not located above the dividing line, the first inverted bottle and the second inverted bottle have completed the inverted bottle counting and no repeated counting is performed.
[0025] In a second aspect, the present invention provides a vision-based inverted bottle counting device on a filling production line, comprising:
[0026] The inverted bottle coordinate acquisition module is configured to acquire the current frame video stream image of the filling production line, identify and mark the coordinates of all inverted bottles in the current frame video stream image, the coordinates of all inverted bottles constitute an inverted bottle coordinate array, and set a dividing line on the current frame video stream image, the inverted bottles include the first inverted bottle located below the dividing line;
[0027] The associated inverted bottle determination module is configured to traverse the first inverted bottle, generate a detection frame upward based on the first inverted bottle, obtain the coordinates of the second inverted bottle that is located in the detection frame in the previous frame of the video stream image and is closest to the coordinates of the first inverted bottle that generates the detection frame, and calculate the corrected distance value between the coordinates of the second inverted bottle and the coordinates of the first inverted bottle corresponding to it;
[0028] A production line moving distance determination module is configured to determine the moving distance of the filling production line between the time of acquiring the current frame video stream image and the previous frame video stream image according to all the corrected distance values;
[0029] The inverted bottle counting module is configured to count the inverted bottles according to the coordinates of the first inverted bottle, the coordinates of the second inverted bottle corresponding to the first inverted bottle, the correction distance value and the moving distance of the filling production line.
[0030] In a third aspect, the present invention provides an electronic device comprising one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation manner in the first aspect.
[0031] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.
[0032] In a fifth aspect, the present invention provides a computer program product, comprising a computer program, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.
[0033] Compared with the prior art, the present invention has the following beneficial effects:
[0034] (1) The vision-based inverted bottle counting method on the filling production line proposed in the present invention realizes automatic identification and counting of inverted bottles on the filling production line through machine vision technology, avoiding the errors caused by manual counting and mechanical sensors, and solving the problem that bottles that are exactly the same cannot be marked and counted, reducing the need for manual intervention, and improving the degree of automation and counting accuracy of the filling production line.
[0035] (2) The vision-based method for counting upside-down bottles on a filling production line proposed by the present invention solves the correction distance value between the coordinates of the first upside-down bottle and the coordinates of the second upside-down bottle in two adjacent frames of the video stream image, and further determines the moving distance of the filling production line, thereby counting upside-down bottles. There is no need to mark the target objects to be counted with a unique identifier, which solves the problem that it is impossible to mark the bottles on the filling production line with a unique identifier to identify the upside-down bottles, thereby improving the degree of automation of the filling production line.
[0036] (3) The vision-based inverted bottle counting method on the filling production line proposed by the present invention solves the moving distance of the filling production line in the current frame video stream image and the previous frame video stream image. Compared with the counting method of setting the moving distance of the production line before counting, the present invention has stronger versatility and scalability, can adapt to target objects of different models and different production environments, and can adapt to stop-and-go production lines. According to the state changes of the target objects, the correction distance value and the moving distance of the production line are solved to meet the counting requirements of stop-and-go production lines. The present invention has strong adaptability and improves the working efficiency of the production line. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0038] Figure 1 A schematic flow chart of a method for counting bottles on a filling production line based on vision according to an embodiment of the present application;
[0039] Figure 2 A video stream image of a method for counting bottles on a filling production line based on vision according to an embodiment of the present application for identifying and marking bottles that have fallen;
[0040] Figure 3 A schematic diagram of generating a detection frame for the first inverted bottle in a current frame video stream image in a method for counting inverted bottles on a filling production line based on vision according to an embodiment of the present application;
[0041] Figure 4 It is a schematic diagram of the second inverted bottle in the previous frame of the video stream picture of the inverted bottle counting method on the filling production line based on vision according to an embodiment of the present application;
[0042] Figure 5 A schematic diagram of the distance between the coordinates of the second inverted bottle and the coordinates of the first inverted bottle corresponding to the inverted bottle in the vision-based inverted bottle counting method on the filling production line according to an embodiment of the present application;
[0043] Figure 6 A schematic diagram of a bottle counting device based on vision on a filling production line according to an embodiment of the present application;
[0044] Figure 7 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0046] Figure 1 The embodiment of the present application provides a method for counting bottles on a filling production line based on vision, comprising the following steps:
[0047] S1, obtain the current frame video stream image of the filling production line, identify and mark the coordinates of all inverted bottles in the current frame video stream image, the coordinates of all inverted bottles constitute an inverted bottle coordinate array, and set a dividing line on the current frame video stream image, the inverted bottles include the first inverted bottle located below the dividing line.
[0048] Specifically, in order to meet the shooting requirements of various filling production lines in complex environments, a network camera with backlight compensation, strong light suppression, 3D digital noise reduction, large aperture and ultra-low shutter is used to shoot the filling production line in real time to obtain a high-definition video stream, and each frame of the video stream is extracted through image processing technology, such as using VideoCapture in the opencv image processing library to extract each frame of the video stream. Furthermore, the YOLO target detection in the deep learning algorithm is used to identify and locate the bottle in each frame of the video stream, and the position of each inverted bottle is accurately marked to obtain the coordinates of the inverted bottle in each frame of the video stream. Reference Figure 2 The position of the inverted bottle is represented by the coordinates of the center of the rectangular frame of the inverted bottle in the video stream picture, and a horizontal line is set on the video stream picture as the dividing line for the inverted bottle count.
[0049] S2, traverse the first inverted bottle, generate a detection frame upward based on the first inverted bottle, obtain the coordinates of the second inverted bottle that is located in the detection frame in the previous frame of the video stream and is closest to the coordinates of the first inverted bottle that generates the detection frame, and calculate the corrected distance value between the coordinates of the second inverted bottle and the coordinates of the corresponding first inverted bottle.
[0050] In a specific embodiment, generating a detection frame based on the first bottle-upward inversion specifically includes:
[0051] According to the coordinates of the first inverted bottle, a rectangular frame is constructed upward for the first inverted bottle. The width of the rectangular frame is equal to the sum of the width of the circumscribed rectangular frame of the first inverted bottle and the correction parameter. The length of the rectangular frame is less than or equal to the distance from the center of the circumscribed rectangular frame of the first inverted bottle to the top of the current frame video stream image. The rectangular frame is used as the detection frame.
[0052] Specifically, in an ideal state, the outer rectangular frame of the first inverted bottle can be used as the width of the detection frame. However, in the actual production process, when the filling production line moves, the left and right positions of the first inverted bottle in the current frame video stream image and the previous frame video stream image will change. Therefore, when generating the detection frame, the width of the rectangular frame needs to be adjusted according to the stability of the filling production line operation. Figure 3 , the amplitude of the left-right position change of the first inverted bottle is used as a correction parameter, so that the width of the detection frame is equal to the sum of the width of the circumscribed rectangular frame of the first inverted bottle and the correction parameter. In a preferred embodiment, the length of the rectangular frame is equal to the distance from the center of the circumscribed rectangular frame of the first inverted bottle to the top of the current frame video stream picture.
[0053] In a specific embodiment, obtaining the coordinates of a second inverted bottle that is located in a detection frame in a previous frame of a video stream and is closest to the coordinates of a first inverted bottle that generates the detection frame, and calculating a correction distance value between the coordinates of the second inverted bottle and the coordinates of the first inverted bottle corresponding thereto, specifically includes:
[0054] Get the coordinates of all inverted bottles within the detection frame in the previous frame of the video stream;
[0055] Calculate the distance between the coordinates of all inverted bottles located in the detection frame in the previous frame of the video stream and the coordinates of the first inverted bottle that generates the detection frame, and select the inverted bottle with the smallest distance value as the second inverted bottle;
[0056] Calculate the corrected distance between the coordinates of the second inverted bottle and the coordinates of the first inverted bottle corresponding to it. The calculation formula is as follows:
[0057] ;
[0058] in, Indicates the Y value of the first inverted bottle. represents the coordinate Y value of the second inverted bottle, r represents the error tolerance parameter, and round represents rounding;
[0059] Move the coordinates of the first inverted bottle and the coordinates of the second inverted bottle out of the inverted bottle coordinate array.
[0060] In a specific embodiment, the error tolerance parameter r is 5.
[0061] Specifically, refer to Figure 4 and Figure 5 , obtain the coordinates of all inverted bottles in the detection frame in the previous frame of video stream, calculate the distance between the coordinates of all inverted bottles in the detection frame in the previous frame of video stream and the coordinates of the first inverted bottle that generated the detection frame, and select the inverted bottle with the smallest distance value as the second inverted bottle, such as Figure 4 Further, Figure 5 The distance between the coordinates of the second inverted bottle and its corresponding coordinates of the first inverted bottle is shown in indicates that, and .
[0062] Ideally, the moving distance of the bottle on the filling line is the same as the moving distance of the filling line. However, in the actual production process, when the filling line moves, the moving distance of the bottle will not be exactly the same, and the moving distance of the bottle on the filling line measured by the camera will not be exactly the same, and there will be errors. For example, the distance between the coordinates of the second inverted bottle p1 and the coordinates of its corresponding first inverted bottle c1 is 121.5mm, calculate the correction distance value ; The distance between the coordinates of the second inverted bottle p2 and the coordinates of the first inverted bottle c2 is 124.6mm, calculate the correction distance value , and equal. Therefore, in the present application, by setting the error allowable parameter r, the correction distance value between the coordinates of the second inverted bottle and the coordinates of the first inverted bottle corresponding thereto is calculated to solve the error generated when calculating the distance value between the coordinates of the inverted bottle located in the detection frame in the previous frame of the video stream image and the coordinates of the first inverted bottle that generates the detection frame. The correction distance value between the coordinates of the second inverted bottle and the coordinates of the first inverted bottle corresponding thereto is calculated, and the coordinates of the second inverted bottle, the coordinates of the first inverted bottle corresponding thereto, and the correction distance value therebetween are stored separately for use in the inverted bottle counting and reading in step S4, and the coordinates of the second inverted bottle and the coordinates of the first inverted bottle corresponding thereto are removed from the inverted bottle coordinate array.
[0063] S3, determining the moving distance of the filling production line between the time of acquiring the current frame video stream image and the time of acquiring the previous frame video stream image according to all the corrected distance values.
[0064] In a specific embodiment, determining the moving distance of the filling production line between the time of acquiring the current frame video stream image and the previous frame video stream image according to all the corrected distance values specifically includes:
[0065] According to all the correction distance values, the number of occurrences of each correction distance value is counted. If there is only one correction distance value corresponding to the largest number of occurrences, the correction distance value with the largest number of occurrences will be used as the moving distance of the filling production line between the time when the current frame video stream image is obtained and the previous frame video stream image is obtained. Otherwise, the correction distance value with the largest number of occurrences and the smallest value will be used as the moving distance of the filling production line between the time when the current frame video stream image is obtained and the previous frame video stream image.
[0066] S4, counting the inverted bottles according to the coordinates of the first inverted bottle, the coordinates of the second inverted bottle corresponding to the first inverted bottle, the correction distance value and the moving distance of the filling production line.
[0067] In a specific embodiment, counting the inverted bottles is performed according to the coordinates of the first inverted bottle, the coordinates of the second inverted bottle corresponding to the first inverted bottle, the correction distance value and the moving distance of the filling production line, specifically including:
[0068] In response to determining that the coordinates of the second inverted bottle are located above the dividing line, it is determined whether the correction distance value is equal to the moving distance of the filling production line, if so, the inverted bottle count is increased by one, otherwise the first inverted bottle and the second inverted bottle are not the same inverted bottle, and no counting is performed;
[0069] In response to determining that the coordinates of the second inverted bottle are not located above the dividing line, the first inverted bottle and the second inverted bottle have completed the inverted bottle counting and no repeated counting is performed.
[0070] Specifically, in an embodiment of the present application, the inverted bottle count is performed based on the coordinates of the first inverted bottle obtained in step S3, the coordinates of the second inverted bottle corresponding to the first inverted bottle, the correction distance value, and the moving distance of the filling production line, and the inverted bottle counting results are statistically analyzed to generate a inverted bottle data report, which is displayed to the operator in real time through a visual interface so that the operator can promptly understand the operating status of the filling production line and handle the inverted bottle situation. In summary, the vision-based inverted bottle counting method on the filling production line proposed in the present application can effectively solve the efficiency problems existing in the traditional counting method and the problem that it is difficult to identify and count completely identical bottles, improve the automation level and product quality of the filling production line, and has broad application prospects.
[0071] The above steps S1-S4 do not necessarily represent the order between the steps, but are represented by step symbols, and the order between the steps can be adjusted.
[0072] Further references Figure 6 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a device for counting bottles on a filling production line based on vision. Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0073] The embodiment of the present application provides a vision-based inverted bottle counting device on a filling production line, comprising:
[0074] The inverted bottle coordinate acquisition module 1 is configured to acquire a current frame video stream image of the filling production line, identify and mark the coordinates of all inverted bottles in the current frame video stream image, the coordinates of all inverted bottles constitute an inverted bottle coordinate array, and set a dividing line on the current frame video stream image, the inverted bottles include the first inverted bottle located below the dividing line;
[0075] The associated inverted bottle determination module 2 is configured to traverse the first inverted bottle, generate a detection frame upward based on the first inverted bottle, obtain the coordinates of the second inverted bottle that is located in the detection frame in the previous frame of the video stream image and is closest to the coordinates of the first inverted bottle that generates the detection frame, and calculate the corrected distance value between the coordinates of the second inverted bottle and the coordinates of the first inverted bottle corresponding to it;
[0076] The production line moving distance determination module 3 is configured to determine the moving distance of the filling production line between the moment of acquiring the current frame video stream image and the moment of acquiring the previous frame video stream image according to all the corrected distance values;
[0077] The inverted bottle counting module 4 is configured to count the inverted bottles according to the coordinates of the first inverted bottle, the coordinates of the second inverted bottle corresponding to the first inverted bottle, the correction distance value and the moving distance of the filling production line.
[0078] Figure 7 Schematic diagram of the hardware structure of the electronic device provided by the embodiment of the present invention. Figure 7 As shown, the electronic device of this embodiment includes: a processor 701 and a memory 702; wherein the memory 702 is used to store computer-executable instructions; the processor 701 is used to execute the computer-executable instructions stored in the memory to implement the various steps performed by the electronic device in the above embodiment. For details, please refer to the relevant description in the above method embodiment.
[0079] Optionally, the memory 702 may be independent or integrated with the processor 701 .
[0080] When the memory 702 is independently provided, the electronic device further includes a bus 703 for connecting the memory 702 and the processor 701 .
[0081] An embodiment of the present invention further provides a computer storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the above method is implemented.
[0082] An embodiment of the present invention further provides a computer program product, including a computer program. When the computer program is executed by a processor, the above method is implemented.
[0083] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0084] The modules described as separate components may or may not be physically separated, and the components shown as modules 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 modules may be selected according to actual needs to implement the solution of this embodiment.
[0085] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, or each module may exist physically separately, or two or more modules may be integrated into one unit. The above-mentioned module-composed unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0086] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the methods of various embodiments of the present application.
[0087] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
[0088] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0089] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0090] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.
[0091] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic device or a main control device.
[0092] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0093] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for counting bottles on a filling production line based on vision, characterized in that: The following steps are involved: Acquire a current frame video stream image of the filling production line, identify and mark the coordinates of all inverted bottles in the current frame video stream image, the coordinates of all the inverted bottles constitute an inverted bottle coordinate array, and set a dividing line on the current frame video stream image, the inverted bottles include a first inverted bottle located below the dividing line; Traversing the first inverted bottle, generating a detection frame upward based on the first inverted bottle, obtaining the coordinates of the second inverted bottle that is located in the detection frame and is closest to the coordinates of the first inverted bottle that generates the detection frame in the previous frame of the video stream, and calculating the correction distance value between the coordinates of the second inverted bottle and the corresponding coordinates of the first inverted bottle, specifically including: Obtaining the coordinates of all inverted bottles located within the detection frame in the previous frame of the video stream; Calculate the distance between the coordinates of all the inverted bottles located in the detection frame in the previous frame of the video stream and the coordinates of the first inverted bottle that generates the detection frame, and select the inverted bottle with the smallest distance value as the second inverted bottle; The correction distance value between the coordinates of the second inverted bottle and the coordinates of the first inverted bottle corresponding thereto is calculated using the following formula: ; in, Indicates the Y value of the first inverted bottle. represents the coordinate Y value of the second inverted bottle, r represents the error tolerance parameter, and round represents rounding; Move the coordinates of the first inverted bottle and the coordinates of the second inverted bottle out of the inverted bottle coordinate array; Determining the moving distance of the filling production line between the time of acquiring the current frame video stream image and the previous frame video stream image according to all the corrected distance values specifically includes: Count the number of occurrences of each of the correction distance values according to all the correction distance values; if there is only one correction distance value corresponding to the largest number of occurrences, use the correction distance value with the largest number of occurrences as the moving distance of the filling production line between the time when the current frame of the video stream picture is obtained and the time when the previous frame of the video stream picture is obtained; otherwise, use the correction distance value with the largest number of occurrences and the smallest value as the moving distance of the filling production line between the time when the current frame of the video stream picture is obtained and the time when the previous frame of the video stream picture is obtained; The inverted bottles are counted according to the coordinates of the first inverted bottle, the coordinates of the second inverted bottle corresponding to the first inverted bottle, the correction distance value and the moving distance of the filling production line.
2. The method for counting bottles on a filling production line based on vision according to claim 1 is characterized in that: The generating of the detection frame based on the first bottle-upside-down method specifically includes: According to the coordinates of the first inverted bottle, a rectangular frame is constructed upward for the first inverted bottle, the width of the rectangular frame is equal to the sum of the width of the circumscribed rectangular frame of the first inverted bottle and a correction parameter, and the length of the rectangular frame is less than or equal to the distance from the center of the circumscribed rectangular frame of the first inverted bottle to the top of the current frame video stream image, and the rectangular frame is used as a detection frame.
3. The method for counting bottles on a filling production line based on vision according to claim 1 is characterized in that: The error tolerance parameter r is 5.
4. The method for counting bottles on a filling production line based on vision according to claim 1 is characterized in that: The counting of the inverted bottles according to the coordinates of the first inverted bottle, the coordinates of the second inverted bottle corresponding to the first inverted bottle, the correction distance value and the moving distance of the filling production line specifically includes: In response to determining that the coordinates of the second inverted bottle are located above the dividing line, determining whether the corrected distance value is equal to the moving distance of the filling production line, if so, adding one to the inverted bottle count, otherwise the first inverted bottle and the second inverted bottle are not the same inverted bottle, and no counting is performed; In response to determining that the coordinates of the second inverted bottle are not located above the dividing line, the first inverted bottle and the second inverted bottle have completed the inverted bottle counting and no repeated counting is performed.
5. A vision-based bottle counting device on a filling production line, characterized in that: include: A bottle-falling coordinate acquisition module is configured to acquire a current frame video stream image of the filling production line, identify and mark the coordinates of all the bottles-falling in the current frame video stream image, the coordinates of all the bottles-falling in the current frame video stream image constitute a bottle-falling coordinate array, and set a dividing line on the current frame video stream image, wherein the bottles-falling in the current frame video stream image include a first bottle-falling in the current frame below the dividing line; The associated inverted bottle determination module is configured to traverse the first inverted bottle, generate a detection frame upward based on the first inverted bottle, obtain the coordinates of the second inverted bottle that is located in the detection frame in the previous frame of the video stream image and is closest to the coordinates of the first inverted bottle that generates the detection frame, and calculate the correction distance value between the coordinates of the second inverted bottle and the coordinates of the first inverted bottle corresponding to it, specifically including: Obtaining the coordinates of all inverted bottles located within the detection frame in the previous frame of the video stream; Calculate the distance between the coordinates of all the inverted bottles located in the detection frame in the previous frame of the video stream and the coordinates of the first inverted bottle that generates the detection frame, and select the inverted bottle with the smallest distance value as the second inverted bottle; The correction distance value between the coordinates of the second inverted bottle and the coordinates of the first inverted bottle corresponding thereto is calculated using the following formula: ; in, Indicates the Y value of the first inverted bottle. represents the coordinate Y value of the second inverted bottle, r represents the error tolerance parameter, and round represents rounding; Move the coordinates of the first inverted bottle and the coordinates of the second inverted bottle out of the inverted bottle coordinate array; The production line moving distance determination module is configured to determine the moving distance of the filling production line between the time of acquiring the current frame video stream image and the previous frame video stream image according to all the corrected distance values, specifically including: Count the number of occurrences of each of the correction distance values according to all the correction distance values; if there is only one correction distance value corresponding to the largest number of occurrences, use the correction distance value with the largest number of occurrences as the moving distance of the filling production line between the time when the current frame of the video stream picture is obtained and the time when the previous frame of the video stream picture is obtained; otherwise, use the correction distance value with the largest number of occurrences and the smallest value as the moving distance of the filling production line between the time when the current frame of the video stream picture is obtained and the time when the previous frame of the video stream picture is obtained; The inverted bottle counting module is configured to count the inverted bottles according to the coordinates of the first inverted bottle, the coordinates of the second inverted bottle corresponding to the first inverted bottle, the correction distance value and the moving distance of the filling production line.
6. An electronic device comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
8. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
