Bar detection counting method, system and equipment and storage medium
By acquiring continuous images of the sawn area and the detection coordinates of the detection line, the movement direction of the target bar can be identified, solving the problem of inaccurate bar counting after sawing, and achieving accurate detection of bar quantity and reduction of equipment cost.
Patent Information
- Application Number
- CN202510861115.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-25
- Publication Date
- 2025-10-31
AI Technical Summary
Existing technologies for image recognition processing of sawn bars suffer from problems such as inaccurate counting, high equipment costs, and large data processing volumes. In particular, accurate recognition is difficult to achieve when the bars are irregularly arranged, moving in the opposite direction, or stopped.
By acquiring continuous images of the sawn area and the detection coordinates of the detection line, the movement direction of the target bar is identified, and the number of bars crossing the detection line is calculated. The image acquisition and processing equipment is used to accurately identify the movement state of the bar, avoiding counting errors caused by abnormal movement.
It enables accurate detection of the number of bars, avoids counting errors caused by abnormal movement of bars, and reduces equipment costs and data processing volume.
Smart Images

Figure CN120876368A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing, and more particularly to a method, system, device, and storage medium for detecting and counting rods. Background Technology
[0002] In the steel production process, hot-rolled bars are sawn into fixed-length bars, and their accurate counting and position tracking are crucial for subsequent quality control, logistics management, and production scheduling. However, existing technologies have various problems in identifying and processing the point counting and tracking of sawn bars based on images.
[0003] First, during the bar sawing process, waste and head / tail materials are generated, or due to human intervention (such as random inspection and rejection of defective products), the actual number of bars leaving the saw does not match the theoretical number. In addition, during the conveying process, the bars are prone to irregular arrangement (such as parallel or non-straight passage), small gaps between bars, and overlapping, which leads to identification errors during bar tracking and inaccurate counting results.
[0004] Secondly, since the post-saw roller conveyor is usually quite long, if continuous tracking of each bar is to be achieved from the saw machine exit to the designated collection area, a large number of cameras need to be deployed along the roller conveyor to ensure coverage. This not only significantly increases the equipment cost of the identification system, but also results in a huge amount of data processing for the system.
[0005] Third, during the conveying process, due to the shape of the bars, complex scenarios may occur on the conveyor line, such as reverse movement, temporary pauses, or small-range reciprocating movements. In such cases, it is impossible to accurately identify and judge the bars that are in such situations. With the accumulation of multiple errors, the final counting result is likely to have a large error compared with the actual number of bars. Summary of the Invention
[0006] The present invention provides a bar detection and counting method, system, device and storage medium, which can solve at least one of the above problems.
[0007] In a first aspect, embodiments of the present invention provide a bar detection and counting method. This method is used to detect the number of bars in the sawn area of a roller conveyor after sawing. The bar detection and counting method includes: acquiring a continuous image of the sawn area and detection coordinate values of a detection line set in the continuous image; acquiring the pre-crossing coordinate value and post-crossing coordinate value of each target bar based on the pre-crossing and post-crossing images of the target bars in the sawn area before and after crossing the detection line; determining the crossing movement direction of the target bar when crossing the detection line based on the detection coordinate values, the pre-crossing coordinate values, and the post-crossing coordinate values; and calculating the number of bars crossing the detection line based on the crossing movement direction of each target bar, generating a bar quantity detection result for the sawn area.
[0008] The bar detection and counting method provided in this invention can accurately identify the coordinates of each target bar before and after crossing the detection line, thereby determining the direction of movement of the target bar, and then confirming whether the corresponding target bar has reversed movement, temporarily stopped, or moved back and forth in a small range, thus achieving accurate detection of the number of bars and avoiding counting errors caused by abnormal movement of bars.
[0009] Optionally, the bar detection and counting method further includes: obtaining the first frame coordinate value and the second frame coordinate value of the target bar based on two adjacent frames of the sawn area; and filtering the target bar from the images of the sawn area based on the first frame coordinate value and the second frame coordinate value.
[0010] Optionally, the step of obtaining the first frame coordinate value and the second frame coordinate value of the target bar based on two adjacent frames of the sawn area includes: obtaining the initial moving speed of the target bar; obtaining the first frame coordinate value of the first frame of the target bar and the adjacent frame time between the first frame and the second frame based on two adjacent frames of the sawn area; and calculating the second frame coordinate value of each target bar based on the initial moving speed and the adjacent frame time.
[0011] Optionally, the step of selecting target bars from the image of the sawn area based on the coordinate values of the first frame and the second frame includes: generating a recognition region centered on the coordinate values of the second frame in the image of the sawn area; matching the candidate bars closest to the coordinate values of the second frame from all bars in the recognition region; calculating the current moving speed of the candidate bars based on the coordinate values of the second frame, the coordinate values of the first frame, and the time of adjacent frames; calculating the instantaneous speed difference of the candidate bars based on the current moving speed and the initial moving speed; determining whether the candidate bars are mismatched based on the instantaneous speed difference and a preset speed difference threshold; if the instantaneous speed difference is less than the preset speed difference threshold, the candidate bar is taken as the target bar; otherwise, an alarm is issued.
[0012] Optionally, before the step of obtaining the coordinate values before and after crossing the detection line of each target bar based on the images before and after crossing the detection line of the target bar in the sawed area, the method further includes: calculating the current direction component of the target bar based on the coordinate values of the first frame and the second frame; generating a first motion direction result of the target bar based on the current direction component and a preset oscillation threshold; obtaining the coordinate values of the target bar in at least two frames of images based on continuous images; calculating the motion trend slope of the target bar based on the coordinate values of the target bar in at least two frames of images; generating a second motion direction result of the target bar based on the motion trend slope and a preset trend threshold; and obtaining the current motion direction of the target bar based on the first motion direction result and the second motion direction result.
[0013] Optionally, the step of determining the crossing motion direction of the target bar when crossing the detection line based on the detection coordinate values, the pre-crossing coordinate values, and the post-crossing coordinate values includes: acquiring the pre-crossing coordinate values of at least one frame of the target bar before crossing the detection line and the post-crossing coordinate values of at least one frame of the target bar after crossing the detection line based on continuous images; calculating the crossing direction component of the target bar when crossing the detection line based on the pre-crossing coordinate values, the post-crossing coordinate values, and the detection coordinate values; and obtaining the crossing motion direction of the target bar based on the crossing direction component.
[0014] Optionally, the step of calculating the number of bars passing through the detection line based on the crossing movement direction of each target bar and generating the bar quantity detection result of the sawn area includes: starting detection when the first bar appears in the sawn area based on a continuous image of the sawn area, and ending detection when no bar passes through the detection line after a preset timeout threshold; at the start of detection, calculating the number of bars passing through the detection line based on the crossing movement direction of each target bar; and at the end of detection, generating the bar quantity detection result of the current batch based on the number of bars passing through the detection line.
[0015] Optionally, the step of calculating the number of bars passing through the detection line includes: if the direction of the target bar's crossing movement is positive, then increase the number of bars by one; if the direction of the target bar's crossing movement is negative, then keep the number of bars unchanged until the detection ends.
[0016] Optionally, the bar detection counting method further includes: if the number of times the target bar is detected to cross the detection line within a preset oscillation time reaches a preset number of oscillations, and the maximum distance between the target bar and the detection line within the preset oscillation time is within a preset oscillation range, then the number of bars remains unchanged until the target bar crosses the detection line in the forward direction and leaves the preset oscillation range.
[0017] Secondly, embodiments of the present invention provide a bar detection and counting system for detecting the number of bars in the sawn area of a roller conveyor after sawing. The system includes: an image acquisition device for acquiring continuous images of the sawn area and detection coordinate values of a detection line set in the continuous images; and an image processing device communicatively connected to the image acquisition device, for acquiring the pre-crossing coordinate values and post-crossing coordinate values of each target bar based on pre-crossing and post-crossing images of the target bars in the sawn area before and after crossing the detection line; determining the crossing direction of the target bar when crossing the detection line based on the detection coordinate values, pre-crossing coordinate values, and post-crossing coordinate values; calculating the number of bars crossing the detection line based on the crossing direction of each target bar, and generating a bar quantity detection result for the sawn area.
[0018] The image acquisition device of the bar detection and counting system provided in this embodiment of the invention can accurately identify the coordinates of each target bar before and after crossing the detection line, thereby enabling the image processing device to determine the movement direction of the target bar, and then confirm whether the corresponding target bar has reversed movement, temporary pause, or small-range reciprocating movement, etc., to achieve accurate detection of the number of bars and avoid counting errors caused by abnormal movement of bars.
[0019] Thirdly, embodiments of the present invention provide a bar detection and counting device, comprising: a processor and a memory, wherein the memory stores instructions; the processor invokes the instructions in the memory to cause the processor to execute the bar detection and counting method of any of the foregoing embodiments of the first aspect of the present invention.
[0020] The processor of the bar detection and counting device provided in this embodiment of the invention executes the bar detection and counting method of any of the foregoing embodiments of the first aspect of the invention by calling instructions in the memory. It can accurately identify the coordinates of each target bar before and after crossing the detection line, thereby determining the movement direction of the target bar, and then confirming whether the corresponding target bar has reversed movement, temporary pause, or small-range reciprocating movement, etc., so as to achieve accurate detection of the number of bars and avoid counting errors caused by abnormal movement of bars.
[0021] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing instructions that, when executed by a processor, implement the bar detection and counting method of any of the foregoing embodiments of the first aspect of the present invention.
[0022] The instructions stored in the computer-readable storage medium provided in the embodiments of the present invention can be called by a processor and executed by the bar detection and counting method of any of the foregoing embodiments of the first aspect of the present invention. The method accurately identifies the coordinates of each target bar before and after crossing the detection line, thereby determining the movement direction of the target bar, and then confirming whether the corresponding target bar has reversed movement, temporary pause, or small-range reciprocating movement, etc., so as to achieve accurate detection of the number of bars and avoid counting errors caused by abnormal movement of bars. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.
[0024] Figure 1 This is a flowchart of one embodiment of the bar detection and counting method of the present invention; Figure 2 This is a flowchart of step S110 in the first embodiment of the bar detection and counting method of the present invention; Figure 3 This is a flowchart of step S111 in one embodiment of the bar detection and counting method of the present invention; Figure 4 This is a flowchart of step S112 in one embodiment of the bar detection and counting method of the present invention; Figure 5 This is a flowchart of step S110 in the second embodiment of the bar detection and counting method of the present invention; Figure 6 This is a flowchart of step S130 in one embodiment of the bar detection and counting method of the present invention; Figure 7 This is a flowchart of step S140 in one embodiment of the bar detection and counting method of the present invention; Figure 8 This is a structural block diagram of one embodiment of the bar detection and counting system of the present invention; Figure 9 This is a schematic diagram of the structure of the bar located in the post-sawing area; Figure 10 This is a schematic diagram of the structure of the image acquisition device acquiring continuous images of the sawn area in one embodiment of the bar detection and counting system of the present invention; Figure 11 This is a schematic diagram of another angle showing the structure of the image acquisition device acquiring continuous images of the sawn area in one embodiment of the bar detection and counting system of the present invention; Figure 12 This is a structural block diagram of one embodiment of the bar detection and counting device of the present invention.
[0025] Explanation of icon numbers: 110 - Image acquisition device; 120 - Image processing device; 130 - Data transmission device; 140 - Data storage device; 201-Sawing equipment; 202-Short-length equipment; 203-Roller conveyor; A1-Post-sawing area; B1-Target bar stock; 301 - Processor; 302 - Memory; 303 - Communication interface; 304 - Bus. Detailed Implementation
[0026] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0027] It should be noted that all directional indications in the embodiments of the present invention, such as up, down, left, right, front, back, etc., are only used to explain the relative positional relationship and movement of the components in a specific posture as shown in the attached figure. If the specific posture changes, the directional indication will also change accordingly.
[0028] Furthermore, the use of terms such as "first" and "second" in this invention is for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first" or "second" may explicitly or implicitly include at least one of that feature. Additionally, the technical solutions of the various embodiments can be combined with each other, but only on the basis of being achievable by those skilled in the art. When the combination of technical solutions is contradictory or impossible to implement, such a combination of technical solutions should be considered non-existent and not within the scope of protection claimed by this invention.
[0029] For ease of understanding, the bar detection and counting method of the present invention is described below. The bar detection and counting method of the present invention is used to detect the number of bars in the sawn area of the roller conveyor after sawing.
[0030] like Figure 1 As shown, the bar detection and counting method in this embodiment of the invention includes steps S110 to S140.
[0031] In step S110, continuous images of the sawn area and the detection coordinates of detection lines set in the continuous images are acquired. The detection lines are one or more virtual reference lines set in each continuous image of the sawn area. Their positions can be perpendicular to the movement direction of the rod. By comparing the coordinates of the target rod with the detection coordinates of the detection lines, it can be determined whether the target rod has crossed the detection lines and the movement direction of the target rod, thereby enabling the counting of the target rods.
[0032] like Figure 2 As shown, in some optional embodiments, the bar detection and counting method further includes steps S111 to S112.
[0033] In step S111, the first frame coordinate value and the second frame coordinate value of the target bar are obtained based on two adjacent frames of images of the sawn area.
[0034] In step S112, target bars are selected from the image of the sawn area based on the coordinate values of the first frame and the second frame.
[0035] In this embodiment, when acquiring continuous images of the sawn area, when a bar appears in the image, it is tracked and a corresponding tracking mark is assigned to each newly appearing bar to form a target bar. In subsequent continuous images, each target bar is tracked, and the number of bars is counted based on the tracking mark of each target bar.
[0036] Specifically, the steps for obtaining the first frame coordinate values and the second frame coordinate values of the target bar are as follows: Figure 3 As shown, step S111 includes steps S1111 to S1113.
[0037] In step S1111, the initial moving speed of the target bar is obtained.
[0038] In step S1112, based on two adjacent frames of the sawn area, the first frame coordinate value of the first frame image of the target bar and the adjacent frame time between the first frame image and the second frame image are obtained.
[0039] In step S1113, the second frame coordinate value of each target bar is calculated based on the initial moving speed and the adjacent frame time.
[0040] In this embodiment, the movement of the target bar on the roller conveyor can be regarded as uniform motion. When the target bar is first acquired, the speed of the previous frame is the preset initial moving speed. If the target bar does not exhibit abnormalities such as reverse movement, temporary pause, or small-range reciprocating motion, the target bar will move uniformly on the roller conveyor at the preset initial speed.
[0041] In the tracking step for each target bar, the first step is to base the tracking on the position of the target bar in the previous frame. and the speed of the previous frame Calculate its predicted position in the current frame. , can be represented as: ; ; in, and The speed of the previous frame (i.e., the initial movement speed). The time between the previous frame and the current frame is the time between the adjacent frames.
[0042] like Figure 4 As shown, step S112 further includes steps S1121 to S1125.
[0043] In step S1121, based on the coordinate values of the second frame, a recognition region centered on the coordinate values of the second frame is generated in the image of the sawn region.
[0044] In step S1122, the candidate bar that is closest to the coordinate value of the second frame is matched from all the bars in the identification area.
[0045] In step S1123, the current moving speed of the candidate bar is calculated based on the coordinate values of the second frame, the coordinate values of the first frame, and the time of the adjacent frames.
[0046] In step S1124, the instantaneous velocity difference of the candidate bar is calculated based on the current moving speed and the initial moving speed.
[0047] In step S1125, based on the instantaneous speed difference and the preset speed difference threshold, it is determined whether the candidate bar is mismatched. If the instantaneous speed difference is less than the preset speed difference threshold, the candidate bar is used as the target bar; otherwise, an alarm is issued.
[0048] In this embodiment, after calculating the predicted second frame coordinates of the target bar, a search area with a radius of a preset value is generated, centered on the second frame coordinates. Within the identification area, the target rods detected in the current frame are matched with the tracked target rods in the previous frame. The rod with the closest distance to the coordinates in the second frame is selected as the tracked target rod. The distance between the target rod and the coordinates in the second frame is calculated using the following formula:
[0049] in, and The X-axis and Y-axis coordinates of the target bar used for screening. This represents the distance between the target bar and the coordinates of the second frame.
[0050] Specifically, preset search values Calculated based on the following formula: ; in, For the empirical coefficients obtained in advance, The speed of the previous frame.
[0051] Based on the calculated position of the target bar in the previous frame and the predicted position of the current frame That is, the coordinate values of the first frame and the coordinate values of the second frame. The corresponding target bar is selected from all candidate bars in the recognition area, the current position of the matching target bar is determined, and the movement tracking of the target bar is realized.
[0052] Furthermore, for the target bar that has been matched, in steps S1123 to S1125, the instantaneous velocity difference between the velocity of the target bar in the current frame and the velocity in the previous frame is checked based on the following formula to determine whether a mismatch has occurred: ; in, To preset the speed difference threshold, To match the velocity of the current frame of the determined target bar, To match the speed of the target bar in the previous frame.
[0053] Since the bar material generally moves at a constant speed on the roller conveyor, the instantaneous speed... With preceding velocity The variation range will remain within a certain range and will not be too large, therefore the preset speed difference threshold is set. It can be set to a positive number greater than 0 and less than 1. If the instantaneous speed difference is equal to or greater than the preset speed difference threshold, it is determined that a mismatch or abnormal bar movement has occurred. If the instantaneous speed difference is less than the preset speed difference threshold, it is determined that the candidate bar is the target bar.
[0054] like Figure 5 As shown, in some optional embodiments, after step S112 and before step S120, the bar detection and counting method further includes steps S113 to S118.
[0055] In step S113, the current directional component of the target bar is calculated based on the coordinate values of the first frame and the second frame.
[0056] In step S114, the first motion direction result of the target bar is generated based on the current direction component and the preset oscillation threshold.
[0057] In step S115, the coordinate values of the target bar in at least two frames of images are obtained based on the continuous images.
[0058] In step S116, the slope of the motion trend of the target rod is calculated based on the coordinate values of the target rod in at least two frames of images.
[0059] In step S117, the second motion direction result of the target bar is generated based on the motion trend slope and the preset trend threshold.
[0060] In step S118, the current motion direction of the target bar is obtained based on the first motion direction result and the second motion direction result.
[0061] In this embodiment, the coordinates of the target rod are based on its center, and the X-coordinate changes of the target rod are compared between two or more consecutive frames. Determine the current directional component of the target bar. Among them, , The X coordinate of the target bar in the current frame. The X coordinate of the target bar in the previous frame.
[0062] Based on the principal components of the displacement vector, usually the X-direction component... To determine the direction of movement.
[0063] Specifically, the direction of motion of the target rod is determined by calculating the displacement vector of the target rod between consecutive frames. To complete: ; like If it is positive motion; if If the target bar crosses the detection line, the movement is reversed. A count is performed when the target bar crosses the detection line, and the time, position, and direction of the crossover are recorded simultaneously.
[0064] like If this occurs, it is determined that the target bar is moving in the opposite direction. This is a preset sensitivity threshold used to determine direction. Based on the current direction component and the preset oscillation threshold, the first motion direction of the target bar is determined.
[0065] During the movement of the bar stock on the roller conveyor, a small-range reciprocating motion occurs, resulting in oscillation. To avoid misjudging the direction of motion due to oscillation, linear regression calculation is performed based on the coordinate values of the target bar stock in at least two frames of images to obtain the slope of the target bar stock's motion trend. .
[0066] like This confirms that the target bar is moving in the opposite direction. A preset trend threshold is set. Based on the motion trend slope and the preset trend threshold, the second motion direction result of the target bar is generated.
[0067] Setting a preset trend threshold is to avoid misjudgment due to recognition error. Therefore, the trend threshold is related to the accuracy of the device or model used for recognition. In this application, the preset trend threshold is set to be slightly larger than the error value of the device or model used for recognition.
[0068] Based on the results of the first and second motion directions, if both results indicate that the direction of the rod's motion is reversed, then it is confirmed that the rod has moved in the opposite direction. The corresponding reverse count is increased, and the tracking flag of the target rod with the reverse motion is marked, thus setting it as a reverse motion.
[0069] In step S120, based on the images of the target bar in the sawed area before and after crossing the detection line, the coordinate values before and after crossing each target bar are obtained.
[0070] In this embodiment, the X-axis coordinate of the detection line is set to The position of the center point of the bar is determined by comparing the positions of the center points in two consecutive frames. and With the testing line The positional relationship is used to identify whether the target bar has passed through the detection line. During the movement of the target bar, when the following conditions are met... or When the condition is met (i.e., the center point of the target bar is located on one side of the detection line in the previous frame image and on the other side of the detection line in the current frame image), it is determined that the target bar has crossed the detection line.
[0071] At this point, based on the images of the target bar before and after crossing the detection line, the coordinate values of each target bar before and after crossing are obtained.
[0072] In step S130, the direction of the target bar's movement when crossing the detection line is determined based on the detected coordinate values, the coordinate values before crossing, and the coordinate values after crossing.
[0073] like Figure 6 As shown, in some optional embodiments, step S130 includes steps S131 to S133.
[0074] In step S131, based on continuous images, the coordinate values of the target bar before crossing the detection line and the coordinate values of the target bar after crossing the detection line are obtained in at least one frame of images before crossing the detection line and in at least one frame of images after crossing the detection line.
[0075] In step S132, the crossing direction component of the target bar when crossing the detection line is calculated based on the coordinate values before crossing, the coordinate values after crossing, and the detection coordinate values.
[0076] In step S133, the crossing motion direction of the target bar is obtained based on the crossing direction component.
[0077] In this embodiment, after determining the coordinate values of the target bar before and after crossing the detection line, the crossing direction component of the target bar when crossing the detection line is calculated based on the coordinate values before and after crossing and the detection coordinate values, according to the following formula: ; ; in, The directional component after crossing. This represents the direction component before crossing.
[0078] When satisfied When the condition is met (i.e., the center point of the target bar is located on the side before the crossing detection line in the previous frame image and on the side after the crossing detection line in the current frame image), it is determined that the target bar is crossing the detection line in the forward direction.
[0079] When satisfied When the condition is met (i.e., the center point of the target bar is located on the side after the crossing detection line in the previous frame image, and on the side before the crossing detection line in the current frame image), it is determined that the target bar is crossing the detection line in the reverse direction.
[0080] In step S140, based on the crossing movement direction of each target bar, the number of bars crossing the detection line is calculated, and the bar quantity detection result of the sawn area is generated.
[0081] like Figure 7 As shown, in some optional embodiments, step S140 includes steps S141 to S142.
[0082] In step S141, based on the continuous image of the sawn area, detection begins when the first bar appears in the sawn area, and ends when no bar crosses the detection line after a preset timeout threshold. The preset timeout threshold can be 2s, 3s, 3.5s, etc., and is not limited in this application. That is, after counting the last target bar, if no new target bar is detected crossing the detection line after the same time as the preset timeout threshold, the detection ends.
[0083] In step S142, at the start of detection, the number of bars passing through the detection line is calculated based on the crossing movement direction of each target bar.
[0084] The step of calculating the number of rods passing through the detection line includes: if the target rod moves in the positive direction, the number of rods is increased by one; if the target rod moves in the negative direction, the number of rods remains unchanged until the detection ends.
[0085] In step S143, at the end of the inspection, the number of bars in the current batch is generated based on the number of bars that have passed through the inspection line.
[0086] In this embodiment, the number of rods passing through the detection line is counted according to the direction of movement of each target rod. Each time a target rod passes through in the forward direction, the count is increased by one, and each time a target rod passes through in the reverse direction, the count is decreased by one.
[0087] In some optional embodiments, before generating the bar count result for the sawn area, the bar count method further includes: if the number of times the target bar crosses the detection line within a preset oscillation time reaches a preset number of oscillations, and the maximum distance between the target bar and the detection line within the preset oscillation time is within a preset oscillation range, then the bar count is kept unchanged until the target bar crosses the detection line in the forward direction and leaves the preset oscillation range.
[0088] In this embodiment, the preset number of oscillations can be 5 times, 6 times, etc., and the preset oscillation time can be 10s, 20s, 35s, etc., which are not limited in this application.
[0089] Specifically, if the target bar crosses the detection line and then returns to the detection line, the displacement of the bar during this process is: ,like This confirms that the target bar has oscillated. The preset oscillation region range can be selected based on the resolution of the acquired image. For example, if the image resolution is 1920×1080, the preset oscillation region range can be selected. The value is set to 20 pixels. If the round-trip displacement of the bar near the detection line is less than the preset oscillation range, the target bar is considered to have oscillated. In this case, no count update is triggered, or a hysteresis comparison is used until the target bar crosses the detection line in the forward direction and leaves the preset oscillation range to avoid counting errors.
[0090] In some optional embodiments, the rod detection and counting method further includes: detecting whether the target rod in the continuous image is occluded; if occlusion occurs, predicting its possible position at the current moment using a Kalman filter. And the state covariance for estimating the uncertainty of the predicted location Its state transition equation is: ; in, This refers to the position coordinates and velocity of the rod in the X-axis direction in the previous frame. The Y-axis coordinate of the bar is generally a constant value and does not change with time. This is the state transition matrix, which describes how the state of the bar evolves from the previous frame to the current frame.
[0091] Because the bar moves at nearly a uniform speed on the roller conveyor, therefore ,in, The time between adjacent frames of two images; Process noise represents the error in the model used to identify the bar stock or random disturbances during the identification process.
[0092] For example, if, starting from a certain frame, the roller conveyor or camera lens used to transport the bar is obstructed by a foreign object, causing the bar to disappear from the image's field of view, then the location of the target bar in the next frame can be predicted using the Kalman filter, i.e.: .
[0093] In subsequent frames, if the target rod is detected again near the predicted location, the observations in the image where the target rod is detected again are used as the basis for the calculation. Update the Kalman filter state to obtain: To achieve re-tracking of the target bar.
[0094] in, H It is the observation matrix, used to map the predicted state to the observation space. It is the residual between the observed value and the predicted value.
[0095] Due to the observed values It also has its own errors, therefore the Kalman gain of the Kalman filter is... Predicted state With new observations To improve the accuracy of observations, data are merged.
[0096] In the actual tracking process, the observed values The position coordinates of the identified target bar are shown below. According to the Kalman gain calculation formula in the standard Kalman filtering process: ,in, The prediction error covariance represents the variance of the predicted state without considering the current observations. Uncertainty The noise covariance is used to represent the degree of confidence in the observed values. and The settings can be adjusted according to the level of confidence in the observed and predicted values; this application does not impose any limitations on them.
[0097] The bar detection and counting method provided in this embodiment of the invention includes: acquiring a continuous image of the sawn area and the detection coordinate values of a detection line set in the continuous image; acquiring the pre-crossing coordinate value and post-crossing coordinate value of each target bar based on the pre-crossing and post-crossing images of the target bars in the sawn area before and after crossing the detection line; determining the crossing movement direction of the target bar when crossing the detection line based on the detection coordinate values, pre-crossing coordinate values, and post-crossing coordinate values; calculating the number of bars crossing the detection line based on the crossing movement direction of each target bar, and generating a bar quantity detection result for the sawn area.
[0098] The bar detection and counting method provided in this invention can accurately identify the coordinates of each target bar before and after crossing the detection line, thereby determining the direction of movement of the target bar, and then confirming whether the corresponding target bar has reversed movement, temporarily stopped, or moved back and forth in a small range, thus achieving accurate detection of the number of bars and avoiding counting errors caused by abnormal movement of bars.
[0099] In addition to the above method embodiments, the present invention also provides, for example, Figure 8 The bar detection and counting system shown is used to detect the number of bars in the sawn area A1 of the roller conveyor 203 after sawing. The bar detection and counting system includes an image acquisition device 110 and an image processing device 120.
[0100] like Figures 9 to 11 As shown, the image acquisition device 110 is used to acquire continuous images of the sawn region A1 and the detection coordinate values of the detection lines set in the continuous images. The image acquisition device 110 can be a camera or a LiDAR. When the image acquisition device 110 is a camera, the continuous images of the sawn region A1 are visual images generated by the camera; when the image acquisition device 110 is a LiDAR, the continuous images of the sawn region A1 are point cloud images generated by the LiDAR.
[0101] Image processing device 120 is communicatively connected to image acquisition device 110. Image processing device 120 is used to acquire the coordinate values before and after crossing the detection line of each target bar B1 in the sawn area A1; based on the images before and after crossing the detection line, the image processing device 120 determines the crossing direction of the target bar B1; based on the crossing direction of each target bar B1, the image processing device 120 calculates the number of bars crossing the detection line and generates the bar quantity detection result of the sawn area A1.
[0102] In this embodiment, the target bar B1 is conveyed on the roller conveyor 203. The position for setting the image acquisition device 110 in the sawing area A1 is located after the sawing device 201 and the length setting device 202. Taking the image acquisition device 110 as a camera, corresponding image acquisition devices 110 can be set at multiple positions in the sawing area A1 to obtain continuous images of the bar at that position.
[0103] The image processing device 120 is used to process continuous images at each location in real time, so as to realize the identification, tracking and counting of target bar B1 at different locations.
[0104] The bar counting and inspection system also includes a data storage device 140 and a data transmission device 130. The data storage device 140 is communicatively connected to the image acquisition device 110 and the image processing device 120, and is used to store continuous images from the image acquisition device 110 at each location, as well as the processed data and bar quantity detection results from the image processing device 120. The data transmission device 130 is communicatively connected to the image processing device 120, and is used to communicate with external devices, receive instructions from external devices and transmit them to the image processing device 120, and send the data stored in the data storage device 140 to external devices.
[0105] The bar detection and counting system of this application, by implementing the bar detection and counting method of the above embodiments, can allow for continuous maximum prediction frames. The target rod B1 is continuously tracked, with the maximum prediction frame being the number of frames required for the rod to pass through half of the detection range. When a target rod B1 is lost due to occlusion, the image processing device 120 searches for a newly appearing unmatched rod within the predicted area near the last observed position of the lost target rod B1, based on its last velocity, over the next few frames. If an unmatched rod appears whose trajectory is consistent with the lost target rod B1 in terms of time, space, and kinematic characteristics, i.e., it appears within the search radius... Within this range, tracking resumes, maintaining the original tracking marker. This search radius... It can be calculated based on the loss time and final velocity of the target bar B1, that is: .
[0106] in, This indicates the velocity of the target bar B1 in the last frame before it was lost. The time when target bar B1 is lost. These are preset empirical coefficients.
[0107] When tracking target bar B1, based on time consistency verification, it is required that a detected target must be within the minimum consecutive detection frames. A stable occurrence means that the target bar B1 is detected in several consecutive frames (e.g., 3, 4, 5 frames) before it is confirmed as a valid bar, thus filtering out interference or misidentification in the identification process.
[0108] The image acquisition device 110 of the bar detection and counting system provided in this embodiment of the invention can accurately identify the coordinates of each target bar B1 before and after crossing the detection line, thereby enabling the image processing device 120 to determine the movement direction of the target bar B1, and then confirm whether the corresponding target bar B1 has reversed movement, temporarily stopped, or reciprocated in a small range, etc., so as to achieve accurate detection of the number of bars and avoid counting errors caused by abnormal movement of bars.
[0109] In addition to the above method embodiments, the present invention also provides, for example, Figure 12 The bar detection and counting device shown includes a processor 301 and a memory 302, wherein the memory 302 stores instructions; the processor 301 calls the instructions in the memory 302 to cause the processor 301 to execute the bar detection and counting method of any of the foregoing embodiments of the present invention.
[0110] The bar detection and counting method provided in the above embodiments of the present invention includes: acquiring a continuous image of the sawn area and the detection coordinate values of a detection line set in the continuous image; acquiring the pre-crossing coordinate value and post-crossing coordinate value of each target bar based on the pre-crossing and post-crossing images of the target bars in the sawn area before and after crossing the detection line; determining the crossing movement direction of the target bar when crossing the detection line based on the detection coordinate values, the pre-crossing coordinate values, and the post-crossing coordinate values; calculating the number of bars crossing the detection line based on the crossing movement direction of each target bar, and generating a bar quantity detection result for the sawn area.
[0111] The bar detection and counting device provided in this embodiment of the invention can accurately identify the coordinates of each target bar before and after crossing the detection line by implementing the above-mentioned bar detection and counting method, thereby determining the movement direction of the target bar, and then confirming whether the corresponding target bar has reversed movement, temporary pause, or small-range reciprocating movement, etc., so as to achieve accurate detection of the number of bars and avoid counting errors caused by abnormal movement of bars.
[0112] Furthermore, the bar detection and counting device provided in this embodiment of the invention may also include a communication interface 303 and a bus 304, with the processor 301, memory 302 and communication interface 303 electrically connected via the bus 304.
[0113] The memory 302 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 303 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc. The bus 304 can be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 12 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0114] Processor 301 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 301 or by instructions in software form. Processor 301 can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a readily available storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 302. The processor 301 reads the information from memory 302 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.
[0115] This invention also provides a computer-readable storage medium, which can be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. The computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the steps of the above-described bar detection and counting method.
[0116] The computer-readable storage medium provided in this embodiment of the invention stores data and computer-executable instructions for the above-described bar detection and counting method. The bar detection and counting method includes: acquiring a continuous image of the sawn area and the detection coordinate values of a detection line set in the continuous image; acquiring the pre-crossing coordinate value and post-crossing coordinate value of each target bar based on the pre-crossing and post-crossing images of the target bars in the sawn area before and after crossing the detection line; determining the crossing movement direction of the target bar when crossing the detection line based on the detection coordinate values, the pre-crossing coordinate values, and the post-crossing coordinate values; calculating the number of bars crossing the detection line based on the crossing movement direction of each target bar, and generating a bar quantity detection result for the sawn area.
[0117] The computer-readable storage medium provided in this embodiment of the invention can accurately identify the coordinates of each target bar before and after crossing the detection line by implementing the above method, thereby determining the direction of movement of the target bar, and then confirming whether the corresponding target bar has reversed movement, temporarily stopped, or reciprocated in a small range, thereby achieving accurate detection of the number of bars and avoiding counting errors caused by abnormal movement of bars.
[0118] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0119] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, 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. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0120] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting and counting bars, characterized in that, The method is used to detect the number of bars in the sawn area of the roller conveyor after sawing. The method includes: Acquire continuous images of the sawn area and the detection coordinate values of the detection lines set in the continuous images; Based on the images of the target bar in the sawed area before and after crossing the detection line, the coordinate values before and after crossing each target bar are obtained. Based on the detected coordinate values, the coordinate values before crossing, and the coordinate values after crossing, the crossing direction of the target bar when crossing the detection line is determined; Based on the crossing movement direction of each target bar, the number of bars crossing the detection line is calculated, and the bar quantity detection result of the sawn area is generated.
2. The bar detection and counting method according to claim 1, characterized in that, The method further includes: Based on two adjacent frames of the sawed area, the first frame coordinate value and the second frame coordinate value of the target bar are obtained. Based on the coordinate values of the first frame and the second frame, the target bar is selected from the image of the sawn area.
3. The bar detection and counting method according to claim 2, characterized in that, The step of obtaining the first frame coordinate value and the second frame coordinate value of the target bar based on two adjacent frames of the sawn region includes: Obtain the initial moving speed of the target bar; Based on two adjacent frames of the sawed area, the first frame coordinate value of the first frame image of the target bar and the adjacent frame time between the first frame image and the second frame image are obtained. Based on the initial moving speed and the adjacent frame time, the second frame coordinate value of each target bar is calculated.
4. The bar detection and counting method according to claim 3, characterized in that, The step of selecting the target bar from the image of the sawn area based on the first frame coordinate value and the second frame coordinate value includes: Based on the second frame coordinate value, a recognition region centered on the second frame coordinate value is generated in the image of the sawn area; From all the bars in the identified area, match the candidate bar whose distance is closest to the coordinate value of the second frame; Based on the coordinate values of the second frame, the coordinate values of the first frame, and the time of the adjacent frames, the current moving speed of the candidate bar is calculated; Based on the current moving speed and the initial moving speed, calculate the instantaneous velocity difference of the candidate bar; Based on the instantaneous speed difference and the preset speed difference threshold, it is determined whether the candidate bar is mismatched. If the instantaneous speed difference is less than the preset speed difference threshold, the candidate bar is used as the target bar; otherwise, an alarm is issued.
5. The bar detection and counting method according to claim 2, characterized in that, Before the step of obtaining the pre-crossing coordinate values and post-crossing coordinate values of each target bar based on the pre-crossing and post-crossing images of the target bar in the sawed area before and after crossing the detection line, the method further includes: Based on the coordinate values of the first frame and the coordinate values of the second frame, calculate the current directional component of the target bar. Based on the current direction component and the preset oscillation threshold, the first motion direction result of the target bar is generated; Based on the continuous images, the coordinate values of the target bar in at least two frames of images are obtained; Based on the coordinate values of the target rod in at least two frames of images, calculate the slope of the motion trend of the target rod; Based on the slope of the motion trend and the preset trend threshold, a second motion direction result of the target bar is generated; Based on the first motion direction result and the second motion direction result, the current motion direction of the target bar is obtained.
6. The bar detection and counting method according to claim 1, characterized in that, The step of determining the direction of movement of the target bar when crossing the detection line based on the detected coordinate values, the coordinate values before crossing, and the coordinate values after crossing includes: Based on the continuous images, obtain the coordinate values before crossing the detection line of at least one frame of the target bar and the coordinate values after crossing the detection line of at least one frame of the target bar. Based on the coordinate values before crossing, the coordinate values after crossing, and the detection coordinate values, calculate the crossing direction component of the target bar when crossing the detection line; Based on the crossing direction component, the crossing motion direction of the target bar is obtained.
7. The bar detection and counting method according to claim 1, characterized in that, The step of calculating the number of bars passing through the detection line based on the crossing movement direction of each target bar, and generating the bar quantity detection result for the sawn area, includes: Based on the continuous images of the sawn area, detection begins when the first bar appears in the sawn area and ends when no bar passes through the detection line after a preset timeout threshold. At the start of the inspection, the number of bars that pass through the inspection line is calculated based on the crossing movement direction of each target bar; At the end of the inspection, the number of bars in the current batch is measured based on the number of bars that have passed through the inspection line.
8. The bar detection and counting method according to claim 7, characterized in that, The step of calculating the number of bars passing through the detection line includes: if the direction of the target bar's crossing movement is positive, then increase the number of bars by one; if the direction of the target bar's crossing movement is negative, then keep the number of bars unchanged until the detection ends.
9. The bar detection and counting method according to claim 1, characterized in that, The method further includes: If the number of times the target bar is detected to cross the detection line within a preset oscillation time reaches a preset number of oscillations, and the maximum distance between the target bar and the detection line within the preset oscillation time is within a preset oscillation range, then the number of bars remains unchanged until the target bar crosses the detection line in the forward direction and leaves the preset oscillation range.
10. A bar detection and counting system, characterized in that, The bar detection and counting system is used to detect the number of bars in the sawn area of the roller conveyor after sawing, including: An image acquisition device, wherein the image acquisition device is used to acquire continuous images of the sawn area and detection coordinate values of detection lines set in the continuous images; An image processing device, communicatively connected to the image acquisition device, is used to acquire the pre-crossing coordinate values and post-crossing coordinate values of each target bar based on pre-crossing and post-crossing images of the target bars in the sawn region before and after crossing the detection line; determine the crossing direction of the target bar when crossing the detection line based on the detection coordinate values, the pre-crossing coordinate values, and the post-crossing coordinate values; calculate the number of bars crossing the detection line based on the crossing direction of each target bar, and generate a bar quantity detection result for the sawn region.
11. A bar counting and testing device, characterized in that, The bar detection and counting device includes a processor and a memory, wherein the memory stores instructions. The processor invokes the instructions in the memory to cause the bar detection and counting device to implement the bar detection and counting method as described in any one of claims 1 to 9.
12. A computer-readable storage medium storing instructions thereon, characterized in that, When the instruction is executed by the processor, it implements the bar detection and counting method as described in any one of claims 1 to 9.