Method and system for counting containers on freight train
By using the box number detection model and character recognition model to identify and verify the box number of freight train cargo containers, the problem of low manual statistical efficiency and inability to distinguish the same cargo containers in the prior art is solved, and accurate and efficient cargo container counting is achieved.
Patent Information
- Application Number
- CN202510178945.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2025-06-10
AI Technical Summary
In the prior art, when freight trains arrive at the freight yard, manual statistics on the number of cargo boxes is inefficient and prone to errors, and the method based on target detection cannot accurately distinguish the same cargo boxes, resulting in the statistical results being greater than the real number.
By obtaining the image frame of the cargo box number of the freight train, using the box number detection model to detect the position of the cargo box number, combining the character recognition model to identify the box number, and verifying the accuracy of the identification results through the verification formula to finally determine the number of cargo boxes.
The accuracy and efficiency of cargo container counting are improved, and a large amount of manpower is not required to participate, avoiding the error of manual statistics and the problem of repetitive area based on target detection.
Smart Images

Figure CN120126145A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure belongs to the technical field of image processing, and particularly relates to a method and system for counting cargo boxes on a freight train. Background Art
[0002] A railway freight yard refers to a production workshop where a railway freight station handles operations such as cargo acceptance, storage, loading and unloading, and delivery. It is also a place where railway freight transportation connects with other freight transportation tools. The freight yard is the starting, transfer, and ending point of the railway freight transportation production process, directly related to various sectors of the national economy, and is a major link in railway freight transportation. Railway freight yard operations include freight information processing, loading and unloading, transportation production, storage, etc. The traditional management method is manual, with drawbacks such as backward management means, difficult cargo tracking, and low efficiency in inbound and outbound statistics.
[0003] Currently, when a freight train arrives at the freight yard, the number of cargo boxes needs to be counted. Currently, the statistics of cargo boxes in the freight yard are all carried out manually on-site as shown in Figure 7 or through surveillance videos as shown in Figure 8 , and the number of inbound cargo boxes is counted by people. In the case of direct manual inspection, when a freight train arrives at the freight yard, workers are reminded to arrive at the scene to count the number of cargo boxes. In the case of video surveillance, a camera is installed at the entrance of the freight yard to save the video of the freight train arriving at the freight yard. Workers need to view the surveillance video to count the number of cargo boxes. In both cases, manual full participation is required, and workers need to be highly concentrated. However, due to the limited energy of workers, the number of cargo boxes is often not counted in time, or there are mistakes in counting the cargo boxes. Currently, some object detection-based methods have also emerged. Since a freight train is very long and a single picture cannot capture the entire freight train, many consecutive frames can only be extracted. There are many overlapping areas between two consecutive frames. Therefore, using the object detection method, identical cargo boxes cannot be distinguished, so the counted number of cargo boxes will be greater than the actual number. Summary of the Invention
[0004] In view of the above problems, the present disclosure provides a method for counting cargo boxes on a freight train, the method including:
[0005] Obtaining an image frame of the cargo box number of the freight train to be measured, traversing all the image frames of the cargo box number in sequence, and performing the following steps on each image frame:
[0006] Detecting the image frame of the cargo box number by using a box number detection model to obtain a detection frame of the cargo box number;
[0007] Identifying the detection frame of the cargo box number by using a character recognition model to obtain an identification result;
[0008] Verifying the box number according to the identification result to obtain a verification result;
[0009] Determine the number of cargo boxes according to the verification result.
[0010] Preferably, obtaining the image frame of the cargo box number of the freight train to be measured includes:
[0011] Formulate a drone flight path according to the parking position of the freight train to be measured;
[0012] Shoot the freight train to be measured according to the drone flight path to obtain the image frame of the cargo box number of the freight train to be measured.
[0013] Preferably, the acquisition of the box number detection model includes:
[0014] Collect the image frame dataset of the cargo box number, and divide the image frame dataset of the cargo box number into training samples and test samples;
[0015] Construct an initial box number detection model;
[0016] Input the training samples into the initial box number detection model, and train the initial box number detection model in combination with the detector to obtain the trained box number detection model;
[0017] Use the test samples to optimize the parameters of the trained box number detection model to obtain the box number detection model.
[0018] Preferably, the cargo box number detection frame includes the box owner code, the box body registration code, and the inspection code.
[0019] Preferably, the acquisition of the character recognition model includes:
[0020] Collect the cargo box number dataset, and divide the cargo box number dataset into training samples and test samples;
[0021] Construct an initial character recognition model;
[0022] Input the training samples into the initial character recognition model, and train the initial character recognition model in combination with the paddle-ocr model and the ocr character dictionary to obtain the trained character recognition model;
[0023] Use the test samples to optimize the parameters of the trained character recognition model to obtain the character recognition model.
[0024] Preferably, verifying the box number according to the recognition result includes:
[0025] Replace the box owner code with the corresponding value;
[0026] Obtain the verification value according to the verification formula, the box owner code, and the box body registration code;
[0027] Compare the verification value with the inspection code to obtain the verification result.
[0028] Preferably, determining the number of cargo boxes according to the verification result includes:
[0029] If the verification result is that the verification value is consistent with the verification code, determine whether the current box number is in the array list;
[0030] If the verification result is that the verification value is inconsistent with the verification code, detect the next cargo box number image frame.
[0031] Preferably, determining whether the current box number is in the array list includes:
[0032] If the current box number is in the array list, detect the next cargo box number image frame;
[0033] If the current box number is not in the array list, store the current box number in the array list and detect the next cargo box number image frame.
[0034] The present disclosure also provides a system for counting cargo boxes on a freight train, the system including:
[0035] An acquisition module for acquiring an image frame of the cargo box number of the freight train to be measured;
[0036] A detection module for detecting the cargo box number image frame by using a box number detection model to obtain a cargo box number detection frame;
[0037] An identification module for identifying the cargo box number detection frame by using a character recognition model to obtain an identification result;
[0038] A verification module for verifying the box number according to the identification result to obtain a verification result;
[0039] A determination module for determining the number of cargo boxes according to the verification result.
[0040] Preferably, the acquisition module for acquiring an image frame of the cargo box number of the freight train to be measured includes:
[0041] The acquisition module is used to formulate a drone flight path according to the parking position of the freight train to be measured;
[0042] Take pictures of the freight train to be measured according to the drone flight path to obtain an image frame of the cargo box number of the freight train to be measured.
[0043] Preferably, the verification module for verifying the box number according to the identification result includes:
[0044] The verification module is used to replace the box owner code with the corresponding value;
[0045] Obtain a verification value according to the verification formula, the box owner code and the box body registration code;
[0046] Compare the verification value with the verification code to obtain the verification result.
[0047] Preferably, a determination module is configured to determine the number of cargo boxes according to the verification result, including:
[0048] If the verification result is accurate, the determination module determines whether the current box number is in the array list;
[0049] If the verification result is inaccurate, the determination module detects the next cargo box number image frame.
[0050] The present disclosure has the following beneficial effects:
[0051] The present disclosure detects the position of the cargo box number through a box number detection model, then identifies the cargo box number of each frame of the video through a character recognition model, and then verifies the accuracy of the box number recognition through a verification formula; if accurate, it is determined that the cargo box number has been detected in the previous frame, and if not, the cargo box number is added to the recognized box number array; finally, an array of cargo box numbers is obtained, and the number of box numbers in the array is obtained, thereby determining the number of cargo boxes, making the counting of cargo boxes accurate and efficient, and not requiring a large amount of manpower to calculate.
[0052] Other features and advantages of the present disclosure will be described in the following specification, and, in part, will be obvious from the specification, or will be understood by implementing the present disclosure. The objectives and other advantages of the present disclosure can be achieved and obtained by the structures pointed out in the specification and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are some embodiments of the present disclosure. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0054] Figure 1 A diagram showing a method for counting cargo boxes on a freight train in an embodiment of the present disclosure;
[0055] Figure 2 A detailed flowchart showing a method for counting cargo boxes on a freight train in an embodiment of the present disclosure;
[0056] Figure 3 A schematic diagram showing the construction of a box number detection model in an embodiment of the present disclosure;
[0057] Figure 4 A schematic diagram showing a box number detection frame in an embodiment of the present disclosure;
[0058] Figure 5Shows a schematic diagram of constructing a character recognition model in an embodiment of the present disclosure;
[0059] Figure 6 Shows a system diagram for counting cargo boxes on a freight train in an embodiment of the present disclosure;
[0060] Figure 7 Shows a schematic diagram of manual on-site statistics in the prior art;
[0061] Figure 8 Shows a schematic diagram of video surveillance statistics in the prior art. Detailed implementation manners
[0062] Now, example embodiments will be described more fully with reference to the accompanying drawings. However, the example embodiments can be implemented in various forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be more thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art. The features, structures, or characteristics described may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of the embodiments of the present disclosure. However, those skilled in the art will realize that the technical solutions of the present disclosure can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be used. In other cases, well-known technical solutions are not shown or described in detail to avoid obscuring the various aspects of the present disclosure.
[0063] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus their repeated description will be omitted. Some of the block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or in one or more hardware units or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0064] The flowcharts shown in the accompanying drawings are only illustrative and do not necessarily include all steps. For example, some steps can be decomposed, and some steps can be combined or partially combined, so the actual execution order may change according to the actual situation.
[0065] The terms "first", "second", etc. in the description and claims of this application and the above accompanying drawings are used to distinguish similar objects and do not necessarily describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in an order different from those illustrated or described herein.
[0066] In addition, the terms "comprising", "having", and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that comprises a series of steps or sub-modules need not be limited to those steps or sub-modules clearly listed, but may include other steps or sub-modules that are not clearly listed or are inherent to these processes, methods, products, or apparatuses.
[0067] In view of the disadvantages of the existing technical solutions, the present disclosure designs and implements a new method for counting the number of cargo boxes after a freight train arrives at a freight yard. This solution is applicable to any cargo box and any scenario in the freight yard, and there are no requirements for the placement of the cargo boxes.
[0068] As Figure 1 shown, the present disclosure proposes a method for counting cargo boxes on a freight train, and the method includes:
[0069] Obtain an image frame of the cargo box number of the freight train to be measured, sequentially traverse all the image frames of the cargo box numbers, and perform the following steps on each image frame:
[0070] Use the box number detection model to detect the image frame of the cargo box number to obtain a detection box for the cargo box number;
[0071] Use the character recognition model to recognize the detection box of the cargo box number to obtain a recognition result;
[0072] Verify the box number according to the recognition result to obtain a verification result;
[0073] Determine the number of cargo boxes according to the verification result.
[0074] The detailed technical solution is as Figure 2 shown, and the specific content is as follows:
[0075] Step 1: Develop a UAV flight path;
[0076] In this embodiment, the UAV flight path is developed according to the parking position of the freight train to be measured, and the flight path mainly captures the left side, right side, and top side of the freight train to be measured.
[0077] Step 2: The UAV takes pictures according to the flight path to obtain multiple image frames of the cargo box numbers.
[0078] Step 3: Read the image frame.
[0079] Step 4: Determine whether the current image frame is the last frame;
[0080] If so, execute Step 5;
[0081] If not, execute Step 10.
[0082] Step 5: Call the box number detection model to obtain a detection box for the box number;
[0083] In this embodiment, the acquisition of the container number detection model is as Figure 3 shown, including:
[0084] Collect the container number image frame dataset, and divide the container number image frame dataset into training samples and test samples;
[0085] Construct an initial container number detection model;
[0086] Input the training samples into the initial container number detection model, and train the initial container number detection model in combination with the detector to obtain the trained container number detection model;
[0087] Use the test samples to optimize the parameters of the trained container number detection model to obtain the container number detection model.
[0088] As Figure 4 shown, the container number detection frame includes the owner code, the container registration code, and the verification code; among them, the first part consists of 4 English letters, which is the owner code. The first three letters represent the owner code specified by the owner himself, and the fourth letter represents the type code, usually represented by U; the second part consists of 6 Arabic numerals, which is called the container registration code and is the unique identifier of a container body; the third part is 1 Arabic numeral, which is the verification code, usually enclosed in a square box on the container body to distinguish it from the container registration code, and it is the basis for detecting whether the owner code and the registration code are accurate.
[0089] Step 6: Call the character recognition model to obtain the container number;
[0090] In this embodiment, the acquisition of the character recognition model is as Figure 5 shown, including:
[0091] Collect the container number dataset, and divide the container number dataset into training samples and test samples;
[0092] Construct an initial character recognition model;
[0093] Input the training samples into the initial character recognition model, and train the initial character recognition model in combination with the paddle-ocr model and the ocr character dictionary to obtain the trained character recognition model;
[0094] Use the test samples to optimize the parameters of the trained character recognition model to obtain the character recognition model.
[0095] Step 7: Verify the accuracy of the container number according to the verification formula;
[0096] In this embodiment, the verification process is as follows:
[0097] Replace the owner code with the corresponding numerical value;
[0098] Obtain a verification value according to the verification formula, the owner code of the container, and the container registration code;
[0099] Compare the verification value with the verification code to obtain a verification result;
[0100] Among them, each letter and value of the owner code of the container has a corresponding value for operation, as shown in Table 1;
[0101] Table 1
[0102] Container Owner Code A B C D E ... Z Corresponding Value 10 11 12 13 14 ... 38
[0103] Take Figure 4 The container number "TBJU3344237" as an example, the corresponding values of the first four letters are: 31, 11, 20, 32. The verification formula is as follows:
[0104]
[0105] In the formula, c represents the verification value.
[0106] Step 8, determine whether the container number is accurate;
[0107] In this embodiment, c obtained in the verification formula is compared with the 11th digit of the container number recognition. If they are the same, it means the verification is successful and the container number recognition is accurate;
[0108] If it is accurate, execute step 9;
[0109] If it is not accurate, execute step 4.
[0110] Step 9, determine whether the current container number exists in the array list;
[0111] If it exists, execute step 4;
[0112] If it does not exist, store the current container number of the freight container in the array list, and then execute step 4.
[0113] Step 10, obtain the number of container numbers in the array list, so as to obtain the number of freight containers.
[0114] As Figure 6 shown, the present disclosure also proposes a system for counting freight containers on a freight train, and the system includes:
[0115] An acquisition module, configured to acquire an image frame of the container number of the freight train to be measured;
[0116] A detection module, configured to detect the image frame of the container number of the freight container by using a container number detection model to obtain a detection frame of the container number of the freight container;
[0117] An identification module, configured to identify the detection frame of the container number by using a character recognition model to obtain an identification result;
[0118] A verification module, configured to verify the container number according to the identification result to obtain a verification result;
[0119] A determination module, configured to determine the number of containers according to the verification result.
[0120] Those of ordinary skill in the art should understand that: Although the present disclosure has been described in detail with reference to the foregoing embodiments, it is still possible to modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements 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 disclosure.
Claims
1. A method for counting cargo boxes on a freight train, characterized in that: The method comprises: Obtain the cargo box number image frame of the freight train to be tested, traverse all cargo box number image frames in sequence, and perform the following steps for each image frame: Use the box number detection model to detect the box number image frame and obtain the box number detection frame; Use the character recognition model to identify the container number detection frame and obtain the recognition result; Verify the box number according to the recognition result to obtain the verification result; Determine the number of containers based on the verification results.
2. The method for counting cargo boxes on a freight train according to claim 1, characterized in that: Obtain the cargo box number image frame of the freight train to be tested, including: Plan the drone route based on the parking location of the freight train to be tested; The freight train to be tested is photographed according to the UAV route to obtain the image frame of the cargo box number of the freight train to be tested.
3. The method for counting cargo boxes on a freight train according to claim 1, characterized in that: Obtaining the box number detection model, including: Collect a cargo box number image frame dataset, and divide the cargo box number image frame dataset into training samples and test samples; Build the initial box number detection model; Input the training samples into the initial box number detection model, and train the initial box number detection model in combination with the detector to obtain a trained box number detection model; The test samples are used to tune the parameters of the trained box number detection model to obtain the box number detection model.
4. The method for counting cargo boxes on a freight train according to claim 1, characterized in that: The cargo box number detection box includes the box owner code, box registration code and inspection code.
5. The method for counting cargo boxes on a freight train according to claim 1, characterized in that: Acquisition of character recognition model, including: Collect a container number data set, and divide the container number data set into training samples and test samples; Build an initial character recognition model; Input the training samples into the initial character recognition model, and train the initial character recognition model by combining the paddle-ocr model and the ocr character dictionary to obtain the trained character recognition model; The test samples are used to tune the parameters of the trained character recognition model to obtain the character recognition model.
6. The method for counting cargo boxes on a freight train according to claim 4, characterized in that: Verify the box number based on the identification result, including: Replace the box owner code with the corresponding value; The verification value is obtained according to the verification formula, the box owner code and the box registration code; Compare the check value with the check code to obtain the verification result.
7. The method for counting cargo boxes on a freight train according to claim 1, characterized in that: Determine the number of containers based on the verification results, including: If the verification result is that the check value is consistent with the check code, then determine whether the current box number is in the array list; If the verification result is that the check value is inconsistent with the check code, the next container number image frame is detected.
8. The method for counting cargo boxes on a freight train according to claim 7, characterized in that: Determine whether the current box number is in the array list, including: If the current container number is in the array list, detect the next container number image frame; If the current container number is not in the array list, the current container number is stored in the array list and the next container number image frame is detected.
9. A system for counting cargo boxes on a freight train, characterized in that: The system comprises: An acquisition module is used to acquire a cargo box number image frame of the freight train to be tested; A detection module is used to detect the container number image frame using the container number detection model to obtain the container number detection frame; A recognition module is used to recognize the container number detection frame using a character recognition model to obtain a recognition result; A verification module is used to verify the box number according to the recognition result to obtain a verification result; The determination module is used to determine the number of cargo boxes based on the verification results.
10. The system for counting cargo boxes on a freight train according to claim 9, characterized in that: The acquisition module is used to obtain the cargo box number image frame of the freight train to be tested, including: The acquisition module is used to formulate the UAV route according to the parking position of the freight train to be tested; The freight train to be tested is photographed according to the UAV route to obtain the image frame of the cargo box number of the freight train to be tested.
11. The system for counting cargo boxes on a freight train according to claim 9, characterized in that: The verification module is used to verify the box number according to the recognition result, including: The verification module is used to replace the box owner code with the corresponding value; The verification value is obtained according to the verification formula, the box owner code and the box registration code; Compare the check value with the check code to obtain the verification result.
12. The system for counting cargo boxes on a freight train according to claim 9, characterized in that: The determination module is used to determine the number of containers according to the verification results, including: If the verification result is accurate, the determination module determines whether the current box number is in the array list; If the verification result is inaccurate, the determination module detects the next container number image frame.