Code reader data transmission system
By introducing a dynamic bandwidth allocation mechanism for the scanning thread and video thread in the barcode reader system, combined with deep learning and fuzzy control, the problems of scanning delay and uneven video frame rate in the barcode reader system are solved, the scanning delay and stable transmission of the video stream are achieved, and the overall performance and stability of the system are improved.
Patent Information
- Application Number
- CN202510490737.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-18
- Publication Date
- 2025-09-12
AI Technical Summary
When processing QR code data, existing barcode reader systems fail to effectively balance scanning latency and video frame rate, resulting in uneven bandwidth demand, affecting system performance and stability, and failing to meet the needs of efficient and stable data transmission.
The scanning thread and video thread are used to process data separately. Through the dynamic bandwidth allocation mechanism of the control channel and video channel, combined with the deep learning model and fuzzy control theory, the bandwidth allocation strategy is dynamically adjusted to ensure that the scanning delay is lower than the threshold and the video frame rate meets the preset standard.
The coordinated optimization of code scanning tasks and video transmission in complex network environments is achieved. The code scanning delay is stably maintained within an acceptable range, and the video stream transmission quality is dynamically adjusted, avoiding increased code scanning delays or video freezes caused by unreasonable bandwidth allocation.
Smart Images

Figure CN120640041A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a code reader data transmission system. Background Art
[0002] The software system of the code reader usually prioritizes barcode recognition tasks and does not reserve a transmission channel for real-time video streams. During the debugging process, if the scan results and the original image need to be transmitted simultaneously, it may cause communication bandwidth overload or increased delay, affecting the stability of the core functions. In the existing technology, when processing QR code data, the code reader often only focuses on decoding efficiency and accuracy, while ignoring the real-time transmission requirements of video data. This single data processing mode is prone to uneven distribution of system resources when facing complex application scenarios, thereby affecting overall performance. Especially in scenarios where code scanning and video monitoring are required at the same time, the existing system finds it difficult to effectively balance the bandwidth requirements between the two, resulting in increased scanning delays or decreased video frame rates, and unable to meet users' needs for efficient and stable data transmission. In addition, the existing technology lacks an intelligent bandwidth allocation mechanism and cannot dynamically adjust resource allocation according to the real-time system status, further exacerbating the bottleneck problem of system performance. In response to the above problems, the existing technology is in urgent need of improvement. Summary of the Invention
[0003] In view of this, the purpose of the embodiments of the present application is to provide a barcode reader data transmission system that can improve the problem that the existing system is difficult to effectively balance the bandwidth requirements between the two, resulting in increased scanning delay or decreased video frame rate, and cannot meet users' needs for efficient and stable data transmission.
[0004] To achieve the above technical objectives, the technical solutions adopted in this application are as follows:
[0005] The present invention provides a barcode reader data transmission system, including:
[0006] A code scanning thread is configured to receive the QR code data collected by the code reader, decode the QR code data, and generate text data;
[0007] A video thread is configured to receive raw video stream data captured by a camera of a code reader, encode the raw video stream data, and generate processed video stream data;
[0008] a control channel configured to transmit the text data;
[0009] a video channel configured to transmit the processed video stream data;
[0010] The bandwidth allocation module is configured to allocate bandwidth to the control channel and the video channel according to the bandwidth allocation strategy, so that the scanning delay of the barcode reader is lower than a first preset delay threshold and / or the video frame rate of the processed video stream data is greater than a preset frame rate.
[0011] Furthermore, the bandwidth allocation module is further configured to: collect first current state parameters, the first current state parameters including current code scanning delay, code scanning queue backlog, control channel bandwidth occupancy, video frame rate of the processed video stream data, video bit rate of the processed video stream data, video packet loss rate of the processed video stream data, total available bandwidth, and network round-trip delay;
[0012] Inputting the current state parameter into a deep learning model, wherein the deep learning model outputs a first bandwidth allocation weight for the control channel or the video channel based on the current state parameter;
[0013] Based on the first bandwidth allocation weight, a bandwidth is allocated to the control channel and a bandwidth is allocated to the video channel.
[0014] Furthermore, a training module for training the deep learning model is included, and the training module is configured as follows:
[0015] Receive multiple historical first current state parameters;
[0016] Based on all the historical first current state parameters and the reward function, the deep learning model is trained using a reinforcement learning algorithm, so that after the deep learning model is executed to output a first bandwidth allocation weight for the control channel or the video channel based on the current state parameters, and the bandwidth allocated to the control channel and the bandwidth allocated to the video channel based on the first bandwidth allocation weight, the barcode reader's scanning delay is lower than a first preset delay threshold, and / or the video frame rate of the processed video stream data is greater than a preset frame rate;
[0017] The reward function is:
[0018]
[0019] Among them, R t Represents the reward at the current moment;
[0020] D scan Indicates the current scanning delay;
[0021] T delay represents a first preset delay threshold;
[0022] F video Indicates the current video frame rate;
[0023] Fmin Indicates the preset frame rate;
[0024] is an indicator function. When the conditions are met, When the conditions are not met,
[0025] ω1, ω2, ω3, and ω4 are the reward weights for the current code scanning delay meeting the standard, the reward weights for the current video frame rate meeting the standard, the penalty weights for the current code scanning delay exceeding the standard, and the penalty weights for the current video frame rate being insufficient.
[0026] Furthermore, the bandwidth allocation module is further configured to: collect a second current state parameter, the second current state parameter including a current code scanning delay, a code scanning queue backlog, and a video frame rate of the processed video stream data;
[0027] Obtaining an ambiguity set based on the second current state parameter and a preset membership function;
[0028] Obtaining a second bandwidth allocation weight according to the fuzziness set and a preset fuzzy rule base;
[0029] Bandwidth is allocated to the control channel and the video channel based on the second bandwidth allocation weight.
[0030] Furthermore, the video thread is further configured to adjust the resolution of the processed video stream data based on the bandwidth of the video channel allocated by the bandwidth allocation module.
[0031] Furthermore, the video thread is further configured as follows:
[0032] Based on a preset resolution table, an initial resolution is obtained according to the bandwidth of the video channel, wherein the preset resolution table includes a mapping relationship between the bandwidth of a plurality of video channels and the initial resolution;
[0033] Obtain the current scanning delay of the scanning thread;
[0034] Based on the current scanning delay, the initial resolution is corrected to obtain a final resolution;
[0035] The resolution of the processed video stream data is adjusted to the final resolution.
[0036] Furthermore, the video thread is further configured as follows:
[0037] When the current scanning delay is greater than a second preset scanning delay threshold, the initial resolution is reduced by one level to obtain the final resolution;
[0038] When the current code scanning delay is less than a third preset code scanning delay threshold, the initial resolution is increased by one level of resolution to obtain the final resolution.
[0039] Furthermore, it also includes:
[0040] a first buffer area configured to store the text data;
[0041] The second buffer area is configured to store the processed video stream data.
[0042] Furthermore, it also includes:
[0043] A decoding module configured to decode the processed video stream data
[0044] The display terminal is configured to display the decoded processed video stream data.
[0045] The invention adopting the above technical solution has the following advantages:
[0046] In the technical solution provided in this application, data is processed separately by the scanning thread and the video thread, and the dynamic bandwidth allocation mechanism of the control channel and the video channel is combined to effectively solve the problem of the inability to balance the scanning delay and the video frame rate in the existing technology. It has the advantage of ensuring the stability of the scanning function and the smoothness of the real-time video through intelligent adjustment. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The present application may be further illustrated by the non-limiting embodiments provided in the accompanying drawings. It should be understood that the following drawings illustrate only certain embodiments of the present application and are therefore not to be construed as limiting the scope of the present application. It is understood that a person skilled in the art can derive other relevant drawings from these drawings without inventive effort.
[0048] Figure 1 This is a structural block diagram provided for an embodiment of the present application.
[0049] Figure 2 The structural diagram provided in the embodiment of the present application is relative to Figure 1 Added training module.
[0050] Figure 3 The structural diagram provided in the embodiment of the present application is relative to Figure 2 A decoding module and display terminal 800 are added.
[0051] Icons: 100-scanning thread; 200-video thread; 300-control channel; 400-video channel; 500-bandwidth allocation module; 600-training module; 700-decoding module; 800-display terminal. DETAILED DESCRIPTION
[0052] The technical solutions of this application will be described clearly and completely below, in conjunction with the accompanying drawings. It should be understood that the described embodiments represent only a portion of the embodiments of this application, and not all of them. The components of this application, generally described and illustrated in the drawings herein, may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of this application provided in the drawings is not intended to limit the scope of the claimed application, but rather merely represents selected embodiments of this application. All other embodiments derived by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application. It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings. Furthermore, in the description of this application, the terms "first," "second," etc., are used solely to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0053] In existing technologies, the software system of a barcode reader usually prioritizes barcode recognition tasks and does not reserve a transmission channel for real-time video streams. In industrial automation scenarios, debuggers need to observe both the scanning results and the device operation screen to verify the system status. When traditional methods mix and transmit the two data streams, because the barcode recognition task must prioritize low latency, video stream transmission is susceptible to bandwidth limitations, resulting in screen freezes or increased delays in critical data. For example, on a high-speed sorting line, when the barcode reader needs to upload the QR code recognition results in real time and simultaneously transmit the camera image, the mixed data stream is prone to bandwidth competition, causing the scanning response time to exceed the system tolerance threshold or the video frame rate to drop to an unusable level.
[0054] To address these issues, researchers discovered that the core problem was the irrational allocation of bandwidth resources. Early attempts to allocate bandwidth using a fixed ratio proved difficult to adapt to the dynamic fluctuations in the load of code scanning tasks and video streaming requirements in real-time applications. Further research revealed the need for a dynamic adjustment mechanism that would allow the two data streams to compete for bandwidth resources based on real-time conditions. By separating the control channel from the video channel and introducing a bandwidth allocation strategy, dynamic priority switching can be achieved. For example, when the code scanning delay approaches a threshold, priority is given to the control channel bandwidth; when the video frame rate is insufficient, the proportion of video channel resources is temporarily increased.
[0055] Therefore, if Figure 1 As shown, this embodiment proposes a barcode reader data transmission system, including a barcode scanning thread 100, a video thread 200, a control channel 300, a video channel 400 and a bandwidth allocation module 500.
[0056] The code scanning thread 100 is configured to receive the QR code data collected by the code reader, decode the QR code data, and generate text data. The video thread 200 is configured to receive the raw video stream data collected by the camera of the code reader, encode the raw video stream data, and generate processed video stream data.
[0057] In this embodiment, a barcode reader is used to identify a barcode (such as a QR code or DataMatrix) in real time. After receiving the barcode, the barcode scanning thread 100 extracts the text data in the barcode using a barcode recognition algorithm and generates a scan result. The barcode scanning thread 100 has the highest priority.
[0058] The barcode reader is equipped with a surveillance camera for viewing the recognition results and device status in real time. After the video thread 200 receives the original video stream data collected by the surveillance camera, it encodes and processes the original video stream data to generate processed video stream data.
[0059] The control channel 300 is configured to transmit text data.
[0060] The video channel 400 is configured to independently transmit a video stream.
[0061] In this embodiment, the control channel 300 is used to transmit the scanning results, which has the characteristics of small data volume and high priority information. The video channel 400 is used to transmit the processed video stream data, which has the characteristics of large data volume and low real-time information.
[0062] The bandwidth allocation module 500 is configured to allocate bandwidth to the control channel and the video channel according to the bandwidth allocation strategy, so that the scanning delay of the code reader is lower than the first preset delay threshold, and / or the video frame rate of the processed video stream data is greater than the preset frame rate.
[0063] The bandwidth allocation module 500 dynamically adjusts the bandwidth proportions of the control channel 300 and the video channel 400 based on real-time status parameters to ensure that the code scanning delay is lower than the set threshold or the video frame rate reaches the minimum available standard.
[0064] Among them, the code scanning thread refers to an independent processing unit that performs the QR code decoding task. Specifically, it can be implemented by a dedicated computing core in a multi-core processor. By isolating the computing resources of the code scanning task, it can avoid interference from video processing operations. The video thread refers to a parallel processing unit that performs video encoding. Specifically, it can be implemented by a hardware encoder, such as an integrated H.264 encoding chip, which converts the original video stream into a compressed format with lower bandwidth occupancy. The control channel refers to a data transmission path with high priority, which can be implemented through the Quality of Service (QoS) marking in the network protocol, such as adding a DSCP priority tag to a text data packet. The video channel refers to an independent link dedicated to video stream transmission, which can be specifically established using the RTP protocol to establish a dedicated transmission session. The bandwidth allocation module refers to a decision-making unit that dynamically adjusts the allocation of network resources. Specifically, an algorithm model based on reinforcement learning can be used to calculate the optimal bandwidth ratio of the two channels in real time.
[0065] Specifically, the code scanning thread 100 continuously receives the QR code image captured by the code reader, converts it into text information through a decoding algorithm, and stores it in the first buffer area. The video thread 200 synchronously obtains the original video stream of the camera, and stores it in the second buffer area after resolution adjustment and encoding compression. The control channel 300 periodically extracts text data from the first buffer area and sends it to the back-end system in a low-latency transmission mode. The video channel 400 obtains the encoded video stream from the second buffer area and transmits it using adaptive bit rate technology. The bandwidth allocation module 500 monitors the code scanning delay and video frame rate in real time. When the code scanning delay approaches the threshold, the video channel bandwidth is immediately reduced and the released resources are allocated to the control channel. If the video frame rate is lower than the preset value, the bandwidth ratio is adjusted in the opposite direction. Through dual-channel isolated transmission and dynamic resource allocation, the core code scanning function is always maintained in an available state, and the video stream quality is adaptively adjusted according to the remaining bandwidth.
[0066] Compared with existing technologies, traditional solutions use a single data channel to transmit mixed data types, which can easily lead to a decline in key business performance due to resource competition. This embodiment fundamentally eliminates mutual interference between data streams by physically isolating the control channel 300 from the video channel 400. The dynamic bandwidth allocation mechanism breaks through the limitations of the fixed-ratio allocation mode. For example, when the code scanning task is idle, more than 90% of the bandwidth can be allocated to the video channel to improve the smoothness of the picture; and during the peak scanning period, the video channel bandwidth is automatically compressed to the level required to maintain the minimum frame rate, giving priority to ensuring that the scanning delay meets the standard.
[0067] This embodiment effectively reduces the fluctuation in code scanning latency in industrial field debugging scenarios, ensuring that the transmission delay of QR code recognition results remains stable within the system's tolerance range. Furthermore, the video stream transmission frame rate dynamically adjusts based on available bandwidth, prioritizing basic image continuity when bandwidth is limited and automatically increasing to higher definition when bandwidth is sufficient. This dual-channel architecture prevents code scanning tasks from competing with video transmission for network resources, fundamentally resolving the performance degradation caused by mixed data transmission.
[0068] In this embodiment, the bandwidth allocation module 500 is further configured to: collect first current state parameters, the first current state parameters including the current code scanning delay, the code scanning queue backlog, the control channel bandwidth occupancy rate, the video frame rate of the processed video stream data, the video bit rate of the processed video stream data, the video packet loss rate of the processed video stream data, the total available bandwidth, and the network round-trip delay; input the current state parameters into the deep learning model, and the deep learning model outputs the first bandwidth allocation weight of the control channel or the video channel based on the current state parameters, and based on the first bandwidth allocation weight, the allocated bandwidth of the control channel and the allocated bandwidth of the video channel are obtained.
[0069] The current scanning latency refers to the time interval between the scanning thread receiving the QR code data and generating the text data. This can be achieved using timestamp difference calculation and is used to evaluate the efficiency of the scanning task. The scanning queue backlog refers to the amount of QR code data to be processed accumulated in the scanning thread cache. This can be obtained in real time through the queue length monitoring module and reflects the processing pressure on the scanning thread. The control channel bandwidth utilization rate refers to the ratio of the actual bandwidth used when transmitting text data to the total available bandwidth. This can be measured using network traffic statistics tools and is used to determine the load on the control channel. A deep learning model refers to a neural network structure trained through supervised learning or reinforcement learning. It can be implemented using a deep Q-network or policy gradient algorithm and is used to generate an optimal bandwidth allocation strategy based on multi-dimensional state parameters. The reward function is a quantitative metric used to evaluate the effectiveness of bandwidth allocation. It can be derived through a weighted calculation of the reward for meeting the target and the penalty for failing to meet the target, and is used to guide the deep learning model's optimization decisions.
[0070] Specifically, in the process of the code scanning thread processing the QR code data and the video thread processing the video stream data, the bandwidth allocation module 500 continuously collects eight state parameters including code scanning delay, queue backlog, bandwidth occupancy rate, etc. These parameters are integrated into a real-time state vector and input into the pre-trained deep learning model. The model performs inference operations based on the state vector and the preset reward function, where the reward function takes whether the code scanning delay is lower than the first preset threshold and whether the video frame rate is higher than the preset frame rate as the core judgment conditions. The inference result is output as the bandwidth allocation weight of the control channel and the video channel. For example, when the code scanning delay approaches the threshold, the model automatically increases the weight of the control channel. The final bandwidth allocation module dynamically adjusts the bandwidth ratio of the two channels based on the weight calculation results to ensure that the code scanning task prioritizes meeting the delay requirements while maintaining the basic transmission quality of the video stream.
[0071] Exemplarily, the method for dynamically allocating bandwidth implemented by the bandwidth allocation module 500 includes the following steps:
[0072] ① Collect the first current state parameter S t1 , S t1 =[Q scan 、D scan 、U control 、F vedio 、R loss 、B vedio 、B total 、T RTT ].
[0073] Among them, Q scan Indicates the backlog of the code scanning queue;
[0074] D scan Indicates the current scanning delay;
[0075] U control Indicates the current bandwidth occupancy of the control channel;
[0076] F vedio Indicates the video frame rate of the processed video stream data;
[0077] R loss Indicates the video packet loss rate of the processed video stream data;
[0078] B vidio Indicates the video bitrate of the processed video stream data;
[0079] B total Indicates the total bandwidth;
[0080] T RTT Indicates the network round-trip delay.
[0081] ②S t1Input into the preset deep learning model, the deep learning model is based on S t1 , output the bandwidth allocation weight α, and then implement the bandwidth allocation of the control channel 300 and the video channel 400 based on the following formula.
[0082] B control =B min-control +α·(B total -B min-control -B min-vidio )
[0083] B vidio =B total -B control
[0084] Among them, B min-control Indicates the minimum guaranteed bandwidth of the control channel;
[0085] B min-vidio Indicates the minimum guaranteed bandwidth of the video channel.
[0086] like Figure 2 As shown, in at least one embodiment, a training module 600 is further included for training the deep learning model, which is configured to receive multiple historical first current state parameters; based on all the historical first current state parameters and the reward function, the deep learning model is trained through a reinforcement learning algorithm, so that the deep learning model is executed based on the current state parameters to output the first bandwidth allocation weight of the control channel or the video channel, and after the step of allocating bandwidth for the control channel and the video channel based on the first bandwidth allocation weight, the scanning delay of the barcode reader is lower than the first preset delay threshold, and / or the video frame rate of the processed video stream data is greater than the preset frame rate.
[0087] For example, the preset deep learning model adopts the ACTOR network model, and the process in the training phase can be:
[0088] Collect multiple first current state parameters S of the history t1-history ,
[0089] The ACTOR network is based on the current strategy and each S t1-history , generating α t ;
[0090] According to α t , get the result of bandwidth allocation;
[0091] According to the results of bandwidth allocation, the simulation results show that D scan , F video , based on the following reward function, we get the current reward R t ;
[0092]
[0093] Among them, R t Represents the reward at the current moment;
[0094] D scan Indicates the current scanning delay;
[0095] T delay represents a first preset delay threshold;
[0096] F video Indicates the current video frame rate;
[0097] F min Indicates the preset frame rate;
[0098] is an indicator function. When the conditions are met, When the conditions are not met,
[0099] ω1, ω2, ω3, and ω4 are the reward weights for meeting the current scanning delay standard, the reward weights for meeting the current video frame rate standard, the penalty weights for exceeding the current scanning delay standard, and the penalty weights for insufficient current video frame rate, respectively.
[0100] After bandwidth allocation, the next state S is obtained t1+1 ;
[0101] Based on the greedy strategy, that is, maximizing the reward as the premise, the current strategy is continuously updated.
[0102] The current strategy can be divided into three stages, in which α is randomly selected in the initial stage. t , which will cause large fluctuations in scanning delay and frequent video freezes; in the middle stage, we learned that "α needs to be increased when the delay is high", but the adjustment range is unstable; in the later stage, α is accurately selected to balance video smoothness and scanning delay.
[0103] Compared with existing technologies, traditional methods use fixed-ratio bandwidth allocation or simple threshold-based adjustments, which cannot cope with the dynamic changes in scanning tasks and video streaming transmission requirements. This solution uses a deep learning model to jointly analyze multi-dimensional state parameters, capturing the nonlinear relationship between parameters such as scanning latency and network round-trip delay, and achieving more accurate dynamic bandwidth allocation. For example, when the backlog in the scanning queue increases suddenly and the network round-trip delay is large, the model can automatically increase the control channel bandwidth weight to accelerate data processing, while traditional methods may only make adjustment decisions based on a single parameter.
[0104] Through the above technical solution, this application effectively solves the problem of mismatch between bandwidth resource allocation and real-time task requirements. By combining multi-dimensional status monitoring with deep learning decision-making, it is possible to maximize the transmission frame rate of the video stream while ensuring that the scanning delay does not exceed the threshold. This solution is particularly suitable for scenarios such as industrial inspection that require the simultaneous acquisition of scanning results and on-site video, avoiding scanning response delays or video freezes due to unreasonable bandwidth allocation.
[0105] The indicative function in the reward function described herein refers to a function that returns a binary value based on preset conditions. Specifically, it can be implemented using a threshold comparator to determine whether the current scanning delay or video frame rate meets the preset standard. The reward weight for the current scanning delay meeting the standard refers to the positive incentive parameter given when the scanning delay is lower than the threshold. Specifically, it can be implemented using a fixed coefficient or a dynamically adjusted coefficient to strengthen the system's preference for low-latency states. The reward weight for the current video frame rate meeting the standard refers to the positive incentive parameter given when the video frame rate is higher than the threshold. Specifically, it can be implemented using a fixed coefficient or a dynamically adjusted coefficient to strengthen the system's preference for high-frame-rate states. The penalty weight for the current scanning delay exceeding the standard refers to the negative penalty parameter applied when the scanning delay exceeds the threshold. Specifically, it can be implemented using a fixed coefficient or a dynamically adjusted coefficient to suppress the system's tolerance for high-latency states. The penalty weight for the current video frame rate insufficient refers to the negative penalty parameter applied when the video frame rate is lower than the threshold. Specifically, it can be implemented using a fixed coefficient or a dynamically adjusted coefficient to suppress the system's tolerance for low-frame-rate states.
[0106] Specifically, in the training process of the preset deep learning model, according to the current strategy based on S t1-history Get α t After that, bandwidth is allocated to the control channel 300 and the video channel 400 in the simulation environment. After allocation, the current scanning delay and video frame rate are collected in the simulation environment and compared with the preset threshold. When the scanning delay is lower than the first preset delay threshold, the indicator function triggers a positive reward, and the reward value at the current moment is calculated in combination with the corresponding weight coefficient; when the video frame rate is higher than the preset frame rate, a positive reward is also triggered. On the contrary, if the scanning delay or the video frame rate does not meet the standard, a negative reward is calculated by the penalty weight. The reward function is input into the deep learning model to drive the model to learn the optimal bandwidth allocation strategy that prioritizes scanning delay and video frame rate in a dynamic network environment. For example, when the backlog of the scanning queue suddenly increases, the system can reduce the bandwidth occupancy of the video channel by increasing the bandwidth allocation weight of the control channel, thereby avoiding the scanning delay exceeding the threshold.
[0107] Compared with existing technologies, traditional methods typically use fixed bandwidth allocation strategies or dynamic adjustments based on simple rules, which cannot simultaneously balance the scanning delay and video frame rate. However, this application introduces a multi-dimensional reward function to convert the compliance status of scanning delay and video frame rate into quantifiable reward and punishment signals, enabling the deep learning model to automatically adjust bandwidth allocation priorities based on real-time network status, avoiding system performance imbalances caused by single-metric optimization.
[0108] Through the above technical solution, this application can achieve coordinated optimization of code scanning tasks and video transmission in a complex network environment, ensuring that the code scanning delay is always maintained within an acceptable range, while ensuring the real-time transmission quality of the video stream, and solving the problem of increased code scanning delay or video freeze caused by unreasonable bandwidth allocation in traditional systems.
[0109] In at least one embodiment, the bandwidth allocation module 500 can also be configured to collect second current state parameters, which include the current scanning delay, the scanning queue backlog, and the video frame rate of the processed video stream data; based on the second current state parameters and the preset membership function, a fuzziness set is obtained; based on the fuzziness set and the preset fuzzy rule base, a second bandwidth allocation weight is obtained; based on the second bandwidth allocation weight, bandwidth is allocated to the control channel 300 and the video channel 400.
[0110] The second current state parameter refers to a three-dimensional dynamic indicator set that affects bandwidth allocation decisions. Specifically, it can be achieved by using sensors to collect real-time data on the decoding time, number of packets to be processed, and video frame rate of the scanning device to reflect the real-time load status of the system.
[0111] The preset membership function refers to a mathematical function that maps continuous variables to fuzzy sets. Specifically, it can be implemented using a triangular or trapezoidal membership function to convert code scanning delay, queue backlog, and video frame rate into fuzzy variables.
[0112] A fuzzy set refers to a combination of fuzzy variables processed by a membership function. Specifically, it can be implemented using the "low", "medium", and "high" levels defined in the fuzzy logic system, and is used to represent the fuzzy description of the system state.
[0113] The preset fuzzy rule base refers to a set of conditional statements that define the relationship between input and output variables. Specifically, it can be implemented using an "if-then" rule group established based on expert experience to convert the fuzzy state into a bandwidth allocation strategy.
[0114] The second bandwidth allocation weight refers to the channel bandwidth ratio coefficient obtained through fuzzy reasoning, which can be implemented by using the center of gravity method to defuzzify and obtain an accurate value, and is used to determine the specific bandwidth ratio of the control channel and the video channel.
[0115] Specifically, the system periodically collects state parameter sets, including the scan delay time, the length of the queue for pending data, and the actual frame rate of the video stream. These three parameters are input into the fuzzy processing unit and converted into corresponding fuzzy sets using a predefined membership function. For example, the scan delay parameter is divided into three fuzzy levels: "normal," "critical," and "overlimit," each corresponding to a different triangular membership function. The fuzzy inference engine calls upon a stored rule base, which contains conditional rules such as "When the scan delay is high and the queue backlog is high, increase the control channel bandwidth weight." The inference process utilizes the Mamdani method, generating a fuzzy output of the bandwidth weight through fuzzy logic operations. This output is then defuzzified to obtain the precise allocation coefficient. Ultimately, the bandwidth allocation of the two channels is dynamically adjusted based on this coefficient, prioritizing the control channel's transmission needs during peak scan times.
[0116] Compared with existing technologies, traditional bandwidth allocation methods often use fixed priority strategies or simple threshold-based switching mechanisms, which are difficult to cope with complex and changing field conditions. For example, some systems only switch bandwidth based on a single metric, which can easily cause frequent channel oscillation. By introducing fuzzy control theory, this solution can effectively handle the nonlinear relationship between code scanning delay, queue backlog, and video frame rate. Especially when the parameters are in a critical state, the smooth transition of the membership function achieves gradual adjustment of bandwidth allocation, avoiding the sudden change in allocation strategy caused by the rigid threshold of traditional methods.
[0117] Through the above technical solution, this application can automatically balance the bandwidth requirements of code scanning data transmission and video streaming transmission under different working conditions. When the code scanning task load increases and delays increase, the system automatically increases the control channel bandwidth to ensure core functions; when the video frame rate is insufficient, the bandwidth allocation is dynamically adjusted to maintain video smoothness. This dynamic allocation mechanism based on fuzzy logic effectively solves the problem that fixed strategies cannot adapt to load fluctuations, ensuring the real-time performance of code scanning while optimizing video transmission quality.
[0118] Illustratively, according to the above technical solution, the bandwidth allocation module 500 of this embodiment can implement bandwidth allocation according to the following process.
[0119] Collect the second current state parameter and convert the current code scanning delay, queue backlog, and video frame rate into fuzzy variables. The fuzziness set can be:
[0120] Current scan delay (D_scan): {medium};
[0121] Scan queue backlog (Q_scan): {medium};
[0122] Video packet loss rate (R_loss): {low};
[0123] Then, the second bandwidth allocation weight is obtained according to the preset fuzzy rule base, which may be:
[0124] rule Output α Video bitrate action IFD_scan = High ANDQ_scan = High ANDR_loss = Low α=1.0 Reduce bitrate to 10Mbps IFD_scan = low ANDQ_scan = low ANDR_loss = high α=0.6 Reduce bitrate to 20Mbps IFD_scan = Medium ANDQ_scan = Medium ANDR_loss = Medium α=0.8 Maintain current bitrate
[0125] Then, bandwidth allocation is completed based on the following formula.
[0126] B control =B min-control +α·(B total -B min-control -B min-vidio )
[0127] B vidio =B total -B control
[0128] In this embodiment, the video thread 100 is further configured to adjust the resolution of the processed video stream data based on the bandwidth of the video channel allocated by the bandwidth allocation module.
[0129] Among them, the bandwidth of the video channel allocated by the bandwidth allocation module refers to the network transmission resources that the video channel is currently allowed to use, which can be achieved through a dynamic allocation algorithm, for example, adjusting the bandwidth ratio according to the real-time network status. Adjusting the resolution of the processed video stream data refers to scaling or compressing the video data, which can be achieved by image processing algorithms or encoding parameter configurations, such as reducing the resolution by changing the number of pixels in the video frame. The preset resolution table refers to a preset correspondence table between bandwidth and resolution, which can be achieved by a two-dimensional mapping table or a functional relationship, such as dividing the bandwidth into multiple intervals and specifying a corresponding resolution level for each interval. The current scanning delay refers to the processing time of the scanning thread from receiving the QR code data to generating the text data, which can be obtained by calculating the timestamp difference. The final resolution refers to the resolution value actually applied to the video stream after correction, which can be achieved by increasing or decreasing the resolution level, such as fine-tuning according to the delay indicator based on the preset resolution table.
[0130] Specifically, the video thread queries the corresponding initial resolution value from the preset resolution table based on the current available bandwidth allocated to the video channel by the bandwidth allocation module. Subsequently, the real-time scanning delay data of the scanning thread is obtained, and the initial resolution is corrected based on the delay data. For example, when the scanning delay exceeds the preset threshold, it indicates that the scanning task is under great pressure. At this time, the initial resolution is reduced by one level to reduce the amount of video stream data, thereby releasing more bandwidth resources for the scanning task. On the contrary, if the scanning delay is lower than another threshold, the initial resolution is allowed to be increased by one level to improve the video picture quality. By dynamically adjusting the resolution, the system can achieve a resource balance between the scanning task and video transmission.
[0131] Compared to existing technologies, existing barcode reader software typically transmits video streams at a fixed resolution. This resolution is maintained even when bandwidth is insufficient or scanning workloads are high, leading to network congestion and increased scanning latency. This solution, by dynamically adjusting resolution, flexibly optimizes video data volume based on real-time bandwidth and scanning workload, preventing the core scanning function from being impacted by excessive video stream resources.
[0132] Through the above technical solution, this application can prioritize the processing efficiency of the scanning task under limited network bandwidth conditions, and dynamically adjust the video resolution according to the actual resource margin, thereby taking into account the dual requirements of low latency in scanning and smooth video transmission, and improving the overall stability of the system.
[0133] The video thread 100 is configured to obtain an initial resolution according to the bandwidth of the video channel based on a preset resolution table, wherein the preset resolution table includes a mapping relationship between the bandwidth of multiple frequency channels and the initial resolution; obtain the current scanning delay of the scanning thread; correct the initial resolution based on the current scanning delay to obtain the final resolution; and adjust the resolution of the processed video stream data to the final resolution.
[0134] Among them, the preset resolution table refers to a table that stores the correspondence between bandwidth and resolution. It can be implemented in an array or hash table structure, and the initial resolution corresponding to the current bandwidth can be quickly matched by table lookup. The current scanning delay refers to the time difference between the scanning thread receiving the QR code data and generating the text data. It can be implemented in a timestamp recording method to measure whether the scanning performance meets the standard. Correcting the initial resolution refers to dynamically adjusting the initial resolution according to the current scanning delay. It can be implemented in a conditional judgment logic. For example, when the delay exceeds a threshold, the resolution is lowered to reduce bandwidth usage. The final resolution refers to the adjusted target resolution, which can be achieved by modifying the video encoding parameters to ensure that the video stream remains available when the bandwidth is limited.
[0135] Specifically, the video thread 100 is configured to query the preset resolution table according to the real-time bandwidth of the video channel and determine the initial resolution as a benchmark value. Subsequently, the current scanning delay of the scanning thread is monitored in real time and fed back to the video thread. If the current scanning delay exceeds the preset threshold, it indicates that the scanning performance may be affected by bandwidth competition. At this time, the initial resolution is reduced by one level to reduce the bandwidth occupied by the video stream; conversely, if the current scanning delay is lower than another preset threshold, it indicates that the bandwidth resources are sufficient, and the initial resolution is increased by one level to improve the video quality. By dynamically adjusting the resolution, a balance is achieved between the video stream bandwidth consumption and the scanning performance requirements.
[0136] Compared to existing technologies, traditional solutions often use fixed video stream resolution or adjust based solely on bandwidth, without considering the performance of the scanning thread. For example, in debugging scenarios, when scanning latency increases due to insufficient bandwidth, existing technologies maintain high-resolution video streaming, resulting in reduced stability in the core scanning function. This solution introduces scanning latency as a correction factor, allowing video resolution to adjust simultaneously to bandwidth changes and scanning performance, avoiding the limitations of single-factor decision-making.
[0137] Through the above technical solution, this embodiment prioritizes the low latency requirements of the code scanning thread when bandwidth resources are limited, while dynamically optimizing the video stream resolution based on the actual operating status. For example, when the code scanning delay suddenly increases due to network fluctuations, the video stream resolution is automatically reduced to free up bandwidth resources and ensure that the code scanning task is completed in a timely manner; when network conditions improve and the code scanning delay is within a safe range, the resolution is increased to provide a clearer debugging screen. This two-way adjustment mechanism effectively solves the system stability problem caused by bandwidth competition.
[0138] This application further proposes a technical means for reducing the initial resolution by one level to obtain the final resolution when the current scanning delay is greater than the second preset scanning delay threshold, and increasing the initial resolution by one level to obtain the final resolution when the current scanning delay is less than the third preset scanning delay threshold.
[0139] Among them, the current scanning delay refers to the processing time from the acquisition of QR code data by the code reader to the generation of text data, which can be implemented specifically by the timestamp difference calculation method to reflect the real-time processing capability of the system. The second preset scanning delay threshold refers to the critical value that triggers the resolution degradation operation, which can be a set value in the range of 200 milliseconds to 500 milliseconds. When the delay exceeds the threshold, it indicates that the system processing capability is insufficient. The third preset scanning delay threshold refers to the critical value that triggers the resolution upgrade operation, which can be a set value in the range of 50 milliseconds to 150 milliseconds. When the delay is lower than the threshold, it indicates that there is bandwidth redundancy. Lowering or increasing the resolution by one level refers to making discrete adjustments according to the preset resolution level table, such as adjusting the resolution from 1920×1080 to 1280×720 step by step or vice versa, avoiding frequent fluctuations through quantitative adjustments.
[0140] Specifically, during the video stream encoding process, the scanning delay data is continuously monitored. When it is detected that the current delay exceeds the second preset threshold, the resolution downgrade operation is immediately performed, and bandwidth resources are released to prioritize the operation of the scanning thread. When it is detected that the current delay is lower than the third preset threshold, the resolution upgrade operation is performed, and the idle bandwidth is used to improve the video quality. This dynamic adjustment mechanism achieves precise control through a preset discrete resolution level table. For example, when the initial resolution is set to 1280×720 and the delay is detected to exceed the standard, it can automatically switch to the next level of 854×480 resolution.
[0141] Compared with existing technologies, traditional solutions only consider bandwidth headroom when adjusting video resolution, ignoring core service latency metrics, which can easily lead to reduced scanning performance. This solution establishes a quantitative balance between video quality and core service performance by establishing a linkage mechanism between scanning latency and video resolution, thus resolving system stability issues caused by bandwidth resource competition.
[0142] Through the above technical solutions, this application achieves a dynamic balance between video transmission quality and code scanning processing efficiency, maximizing the use of available bandwidth resources while ensuring real-time QR code recognition. When the code scanning thread load is too high, the video resolution is automatically reduced to free up bandwidth, avoiding further deterioration of code scanning delays due to resource preemption; when the system processing power is sufficient, the video resolution is increased to ensure that the monitoring image clarity meets debugging requirements.
[0143] The transmission system in this embodiment further includes a first buffer area and a second buffer area. The first buffer area is configured to store text data; the second buffer area is configured to store processed video stream data.
[0144] The first cache area refers to a storage area used to temporarily store decoded text data. This can be implemented using a memory block or database table structure, and its capacity can be set to a dynamic adjustment mode to match the data throughput in different scenarios. The second cache area refers to a buffer area dedicated to storing encoded video stream data. This can be implemented using a circular queue or a sliced storage structure, and its storage space allocation strategy can be dynamically adapted based on the video resolution and bit rate. The first and second cache areas are isolated from each other on the physical storage medium, and data access operations are achieved through independent memory access channels.
[0145] Specifically, after the scanning thread completes the decoding of the QR code, it stores the generated text data in the first buffer area, and the control channel extracts data from the buffer area for transmission as needed according to the network conditions. After the video thread completes the encoding process of the original video stream, it writes the data packets sequentially into the second buffer area, and the video channel reads data from the buffer area according to the scheduling instructions of the bandwidth allocation module. The two buffer areas use an asynchronous read and write mechanism. The scanning thread and the video thread access their respective buffer areas through independent interfaces to avoid resource competition caused by data access operations. When the control channel transmission rate is lower than the text data generation rate, the first buffer area automatically expands the storage space to buffer the data to be transmitted; when the video channel bandwidth is limited, the second buffer area starts the data packet priority marking mechanism to ensure the complete transmission of key frame data.
[0146] This solution completely separates the access paths for text data and video streams by establishing physically isolated dedicated caches, eliminating transmission jitter caused by data access contention. Furthermore, the independent management of the dual caches enables differentiated buffering strategies tailored to the transmission characteristics of different data types, more effectively balancing the differences between data production and transmission rates compared to a single cache structure.
[0147] Through the above technical solution, this application effectively solves the resource competition problem during the mixed transmission of multiple data types, ensuring that the text data generated by the code scanning thread can be transmitted in a timely manner without being affected by fluctuations in the video stream data volume. The setting of an independent buffer area ensures that the burst data generated during the video stream transmission will not squeeze the storage resources required for text data transmission, maintaining the response speed stability of the core code scanning function. At the same time, the asynchronous management mechanism of the dual buffer area reduces the probability of access conflicts to shared storage resources and improves the overall data transmission efficiency of the system.
[0148] In at least one embodiment, a decoding module 700 and a display terminal 800 are further included. The decoding module is configured to decode the processed video stream data, and the display terminal is configured to display the decoded processed video stream data.
[0149] The decoding module is the hardware or software unit that converts the video stream data format. It can be implemented using a hardware decoding chip or a software decoding library based on FFmpeg. Its function is to restore the compressed and encoded video stream into displayable original image data. The display terminal is the device used to present the video image. It can be implemented using an industrial-grade LCD screen or an embedded touch screen. Its function is to provide a real-time video monitoring interface for debuggers.
[0150] Specifically, after the encoded video stream transmitted by the video channel is received by the decoding module, it uses a preset decoding algorithm to parse the data packets frame by frame, converting the compressed data in H.264 or H.265 format into raw pixel data in YUV or RGB format. The decoded video frames are fed into the display terminal's graphics buffer, where the display driver circuit controls the timing according to the screen refresh rate, ultimately presenting a continuous dynamic image on the display panel. This process runs independently from the code scanning thread, and the computing resources required for video decoding are isolated by a dedicated hardware acceleration module.
[0151] In some specific implementations, the decoding module may implement hard decoding using an embedded processor with an integrated VPU, such as the H.265 decoding unit of the HiSilicon Hi3559 chip; the display terminal may use an IPS LCD screen with a resolution of 1280×720 and receive decoded data through an LVDS interface.
[0152] Compared to existing technologies, traditional barcode readers transmit text data over a single communication link, requiring video stream processing to be performed by an external device for secondary parsing, increasing system latency and consuming additional bandwidth. This solution, by integrating a decoding module and display terminal locally, achieves end-to-end closed-loop processing of the video stream, avoiding the impact of network jitter associated with cross-device data transmission.
[0153] Through the above technical solution, this application builds a complete video processing link while maintaining the stable operation of the code scanning thread and the control channel, so that debugging personnel can observe the code scanning area in real time, accurately identify QR code positioning deviations or light interference problems, and avoid the situation where video stream transmission and code scanning data compete for network bandwidth.
[0154] The present application further proposes a code reader data transmission system including a decoding module and a display terminal, wherein the decoding module is used to decode the processed video stream data, and the display terminal is used to display the decoded processed video stream data.
[0155] The decoding module is the hardware or software unit that converts encoded and compressed video data into a displayable format. This can be implemented using an H.264 or H.265 decoder, reducing the bandwidth required for video transmission while restoring the original image quality. The display terminal is the device used to visualize video content. This can be implemented using an LCD screen or touch screen, providing real-time image monitoring for debuggers.
[0156] Specifically, the encoded video stream data generated by the video thread is transmitted via the video channel to the decoding module. The decoding module restores the compressed data to the original video format and outputs it to the display terminal. The processed video stream data is presented in a readable form on the display terminal, allowing the scanning environment and decoding results to be observed simultaneously during debugging. For example, when the video thread adjusts the resolution under the control of the bandwidth allocation module, the decoding module can adapt to the decoding requirements of data with different resolutions to ensure a complete display of the picture.
[0157] Compared to existing technologies, traditional barcode reader systems lack integrated video decoding and display capabilities, requiring external devices to process the video stream during debugging, resulting in increased latency and complex operations. This solution utilizes a built-in decoding module and display terminal to directly restore and display video data within the system, reducing external dependencies and optimizing the data processing chain.
[0158] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, various modifications and variations of the present application are possible. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A code reader data transmission system, characterized in that: include: A code scanning thread is configured to receive the QR code data collected by the code reader, decode the QR code data, and generate text data; A video thread is configured to receive raw video stream data captured by a camera of a code reader, encode the raw video stream data, and generate processed video stream data; a control channel configured to transmit the text data; a video channel configured to transmit the processed video stream data; The bandwidth allocation module is configured to allocate bandwidth to the control channel and the video channel according to the bandwidth allocation strategy, so that the scanning delay of the barcode reader is lower than a first preset delay threshold and / or the video frame rate of the processed video stream data is greater than a preset frame rate.
2. The code reader data transmission system according to claim 1, characterized in that: The bandwidth allocation module is further configured to: collect first current state parameters, the first current state parameters including current code scanning delay, code scanning queue backlog, control channel bandwidth occupancy, video frame rate of the processed video stream data, video bit rate of the processed video stream data, video packet loss rate of the processed video stream data, total available bandwidth, and network round-trip delay; Inputting the current state parameter into a deep learning model, wherein the deep learning model outputs a first bandwidth allocation weight for the control channel or the video channel based on the current state parameter; Bandwidth is allocated to the control channel and the video channel based on the first bandwidth allocation weight.
3. The code reader data transmission system according to claim 2, characterized in that: It also includes a training module for training the deep learning model, wherein the training module is configured as follows: Receive multiple historical first current state parameters; Based on all the historical first current state parameters and the reward function, the deep learning model is trained using a reinforcement learning algorithm, so that after the deep learning model is executed to output a first bandwidth allocation weight for the control channel or the video channel based on the current state parameters, and bandwidth is allocated to the control channel and the video channel based on the first bandwidth allocation weight, the barcode reader's scanning delay is lower than a first preset delay threshold, and / or the video frame rate of the processed video stream data is greater than a preset frame rate; The reward function is: Among them, R t Represents the reward at the current moment; D scan Indicates the current scanning delay; T delay represents a first preset delay threshold; F video Indicates the current video frame rate; F min Indicates the preset frame rate; is an indicator function. When the conditions are met, When the conditions are not met, ω1, ω2, ω3, and ω4 are the reward weights for the current code scanning delay meeting the standard, the reward weights for the current video frame rate meeting the standard, the penalty weights for the current code scanning delay exceeding the standard, and the penalty weights for the current video frame rate being insufficient.
4. The code reader data transmission system according to claim 1, characterized in that: The bandwidth allocation module is further configured to: collect a second current state parameter, the second current state parameter including a current code scanning delay, a code scanning queue backlog, and a video frame rate of the processed video stream data; Obtaining an ambiguity set based on the second current state parameter and a preset membership function; Obtaining a second bandwidth allocation weight according to the fuzziness set and a preset fuzzy rule base; Bandwidth is allocated to the control channel and the video channel based on the second bandwidth allocation weight.
5. The code reader data transmission system according to claim 1, characterized in that: The video thread is further configured to adjust the resolution of the processed video stream data based on the bandwidth of the video channel allocated by the bandwidth allocation module.
6. The code reader data transmission system according to claim 5, characterized in that: The video thread is also configured as follows: Based on a preset resolution table, an initial resolution is obtained according to the bandwidth of the video channel, wherein the preset resolution table includes a mapping relationship between the bandwidth of a plurality of video channels and the initial resolution; Obtain the current scanning delay of the scanning thread; Based on the current scanning delay, the initial resolution is corrected to obtain a final resolution; The resolution of the processed video stream data is adjusted to the final resolution.
7. The code reader data transmission system according to claim 6, characterized in that: The video thread is also configured as follows: When the current scanning delay is greater than a second preset scanning delay threshold, the initial resolution is reduced by one level to obtain the final resolution; When the current code scanning delay is less than a third preset code scanning delay threshold, the initial resolution is increased by one level of resolution to obtain the final resolution.
8. The code reader data transmission system according to claim 1, characterized in that: Also includes: a first buffer area configured to store the text data; The second buffer area is configured to store the processed video stream data.
9. The code reader data transmission system according to claim 1, characterized in that: Also includes: a decoding module, configured to decode the processed video stream data; The display terminal is configured to display the decoded processed video stream data.