CN113935352A - Method, device and equipment for scanning and decoding riding two-dimensional code and storage medium - Google Patents

Method, device and equipment for scanning and decoding riding two-dimensional code and storage medium Download PDF

Info

Publication number
CN113935352A
CN113935352A CN202010604246.5A CN202010604246A CN113935352A CN 113935352 A CN113935352 A CN 113935352A CN 202010604246 A CN202010604246 A CN 202010604246A CN 113935352 A CN113935352 A CN 113935352A
Authority
CN
China
Prior art keywords
image frame
decoding
decoded
frame
identifiable
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010604246.5A
Other languages
Chinese (zh)
Other versions
CN113935352B (en
Inventor
蒋鑫
郭振敏
雷美佳
李锋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
BYD Co Ltd
Original Assignee
BYD Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by BYD Co Ltd filed Critical BYD Co Ltd
Priority to CN202010604246.5A priority Critical patent/CN113935352B/en
Publication of CN113935352A publication Critical patent/CN113935352A/en
Application granted granted Critical
Publication of CN113935352B publication Critical patent/CN113935352B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • G06K7/14172D bar codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K17/00Methods or arrangements for effecting co-operative working between equipments covered by two or more of main groups G06K1/00 - G06K15/00, e.g. automatic card files incorporating conveying and reading operations
    • G06K17/0022Methods or arrangements for effecting co-operative working between equipments covered by two or more of main groups G06K1/00 - G06K15/00, e.g. automatic card files incorporating conveying and reading operations arrangements or provisions for transferring data to distant stations, e.g. from a sensing device
    • G06K17/0025Methods or arrangements for effecting co-operative working between equipments covered by two or more of main groups G06K1/00 - G06K15/00, e.g. automatic card files incorporating conveying and reading operations arrangements or provisions for transferring data to distant stations, e.g. from a sensing device the arrangement consisting of a wireless interrogation device in combination with a device for optically marking the record carrier
    • GPHYSICS
    • G07CHECKING-DEVICES
    • G07GREGISTERING THE RECEIPT OF CASH, VALUABLES, OR TOKENS
    • G07G1/00Cash registers
    • G07G1/12Cash registers electronically operated

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Electromagnetism (AREA)
  • General Health & Medical Sciences (AREA)
  • Toxicology (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The invention provides a scanning and decoding method of a riding two-dimensional code, which comprises the following steps: acquiring an image frame according to a preset sampling frequency through a camera; judging whether the image frame is an identifiable image frame; if the image frame is an identifiable image frame, acquiring an image frame to be decoded according to the decoding state of the last identifiable image frame of the image frame; and executing decoding processing on the image frame to be decoded according to the brightness change value between the image frame to be decoded and the last identifiable image frame. The invention solves the problems that in the prior art, the CPU consumption is high and the operation cannot be carried out for a long time when the two-dimensional code is scanned and decoded on an Android system.

Description

Method, device and equipment for scanning and decoding riding two-dimensional code and storage medium
Technical Field
The invention relates to the technical field of information, in particular to a method, a device, equipment and a storage medium for scanning and decoding a riding two-dimensional code.
Background
The existing public transport POS machine acquires a two-dimensional code image provided by a user side through optical imaging (or laser scanning), converts the two-dimensional code image into a digital signal, performs error correction, graphic processing and decoding operation on the digital signal through an embedded system to obtain resource information contained in the two-dimensional code image, and outputs the resource information to other mobile operating systems, such as an android system, and the mobile operating systems perform transaction and other processing according to the resource information.
However, a two-dimensional code acquisition system constructed by an embedded system is high in cost, and the serial port communication efficiency between the embedded system and the Android system is low, so that the two-dimensional code scanning and decoding efficiency is reduced. If the scanning and decoding process of the two-dimensional code is directly carried out on the Android system, a large number of graphs need to be processed in the scanning and decoding process, and the frame is directly decoded by collecting one frame, so that the CPU consumption is too high; the long-time running in the scene of the bus can cause the temperature of the machine to be overhigh, thereby causing the performance to be reduced and the service life to be shortened.
Disclosure of Invention
The invention provides a scanning and decoding method, a device, equipment and a storage medium of a riding two-dimensional code, and aims to solve the problems that in the prior art, CPU (Central processing Unit) consumption is high and the riding two-dimensional code cannot run for a long time when scanning and decoding are carried out on a two-dimensional code on an Android system.
A scanning and decoding device for a riding two-dimensional code comprises:
acquiring an image frame according to a preset sampling frequency through a camera;
judging whether the image frame is an identifiable image frame;
if the image frame is an identifiable image frame, acquiring an image frame to be decoded according to the decoding state of the last identifiable image frame of the image frame;
and executing decoding processing on the image frame to be decoded according to the brightness change value between the image frame to be decoded and the last identifiable image frame.
Optionally, the determining whether the image frame is a recognizable image frame comprises:
for each image frame collected by a camera, calculating a brightness value of the image frame, and comparing the brightness value with a first brightness threshold value;
when the brightness value of the image frame is greater than or equal to the first brightness threshold value, taking the image frame as an identifiable image frame;
and when the brightness value of the image frame is smaller than the first brightness threshold value, continuously acquiring the next image frame collected by the camera.
Optionally, the acquiring an image frame to be decoded according to a decoding status of a last identifiable image frame of the image frame includes:
for each identifiable image frame, acquiring a decoding status of a last identifiable image frame of the identifiable image frames;
and if the decoding state is that the last identifiable image frame is not decoded, taking the identifiable image frame as an image frame to be decoded.
Optionally, the acquiring an image frame to be decoded according to a decoding status of a last identifiable image frame of the image frame includes:
for each identifiable image frame, acquiring a decoding status of a last identifiable image frame of the identifiable image frames;
if the decoding state is that the last identifiable image frame is successfully decoded, performing dormancy processing on the identifiable image frame and identifiable image frames behind the identifiable image frame;
and when the continuously dormant identifiable image frames reach the first preset frame number, acquiring the next identifiable image frame as the image frame to be decoded.
Optionally, the acquiring an image frame to be decoded according to a decoding status of a last identifiable image frame of the image frame includes:
for each identifiable image frame, acquiring a decoding status of a last identifiable image frame of the identifiable image frames;
if the decoding state is that the decoding of the last identifiable image frame fails, updating the decoding failure frame number;
comparing the decoding failure frame number with a third preset frame number;
if the decoding failure frame number is greater than or equal to a third preset frame number, taking the identifiable image frame as an image frame to be decoded;
and if the decoding failure frame number is less than the third preset frame number, continuously acquiring a next identifiable image frame.
Optionally, the performing, according to the brightness change value between the image frame to be decoded and the last recognizable image frame, a decoding process on the image frame to be decoded includes:
comparing the brightness change value of the image frame to be decoded relative to the last identifiable image frame with a second brightness threshold value;
if the brightness change value is larger than or equal to the second brightness threshold value, decoding the image frame to be decoded;
if the brightness change value is smaller than the second brightness threshold value, updating the number of undecoded frames, and comparing the number of undecoded frames with a second preset number of frames;
if the undecoded frame number is greater than or equal to a second preset frame number, decoding the image frame to be decoded, and if the undecoded frame number is less than the second preset frame number, continuously acquiring a next image frame.
A scanning and decoding device for a riding two-dimensional code, the device comprising:
the acquisition module is used for acquiring image frames according to a preset sampling frequency through the camera;
the judging module is used for judging whether the image frame is an identifiable image frame;
the acquisition module is used for acquiring an image frame to be decoded according to the decoding state of the last identifiable image frame of the image frame if the image frame is the identifiable image frame;
and the decoding module is used for executing decoding processing on the image frame to be decoded according to the brightness change value between the image frame to be decoded and the last identifiable image frame.
Optionally, the decoding module comprises:
the first comparison unit is used for comparing the brightness change value of the image frame to be decoded relative to the last identifiable image frame with a second brightness threshold value;
the first decoding unit is used for decoding the image frame to be decoded if the brightness change value is larger than or equal to the second brightness threshold value;
the second comparison unit is used for updating the undecoded frame number and comparing the undecoded frame number with a second preset frame number if the brightness change value is smaller than the second brightness threshold value;
and the second decoding unit is used for decoding the image frame to be decoded if the undecoded frame number is greater than or equal to a second preset frame number, and continuously acquiring the next image frame if the undecoded frame number is less than the second preset frame number.
A computer device comprises a memory, a processor and a computer program which is stored in the memory and can run on the processor, wherein the processor executes the computer program to realize the scanning and decoding method of the riding two-dimensional code.
A computer-readable storage medium, which stores a computer program, wherein the computer program, when executed by a processor, implements the scanning and decoding method for the two-dimensional bus ride code.
In the embodiment of the invention, the camera still collects the image frames in the two-dimensional code scanning area according to the preset time interval, each image frame collected by the camera is screened out of identifiable image frames, then the image frame to be decoded is screened out according to the decoding state of the last adjacent identifiable image frame of the identifiable image frames, and finally the image frame to be decoded is decoded according to the brightness change value between the image frame to be decoded and the last adjacent identifiable image frame, so that the decoding frequency of an Android system is reduced on the premise of ensuring effective decoding, the consumption of a CPU is reduced, and the bus POS machine can run efficiently for a long time.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart illustrating an implementation of a scanning and decoding method for a riding two-dimensional code according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating an implementation of step S102 in a scanning and decoding method for a riding two-dimensional code according to an embodiment of the present invention;
fig. 3 is a flowchart illustrating an implementation of step S104 in a scanning and decoding method for a riding two-dimensional code according to an embodiment of the present invention;
fig. 4 is a flowchart illustrating an implementation of step S103 in a scanning and decoding method for a riding two-dimensional code according to an embodiment of the present invention;
fig. 5 is a flowchart illustrating an implementation of step S103 in a scanning and decoding method for a riding two-dimensional code according to another embodiment of the present invention;
fig. 6 is a flowchart illustrating an implementation of step S103 in a scanning and decoding method for a riding two-dimensional code according to another embodiment of the present invention;
fig. 7 is a structural diagram of a scanning and decoding device for a riding two-dimensional code according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of a computer device according to an embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The following describes in detail the scanning and decoding method for the riding two-dimensional code provided in this embodiment. In view of the fact that a two-dimensional code acquisition system constructed based on an embedded system in the prior art has high module cost and low communication efficiency, the embodiment of the invention transfers the scanning and decoding process to the Android system so as to perform the scanning and decoding process of the two-dimensional code on the Android system, thereby reducing the cost of the embedded module. Most of the existing two-dimensional code scanning decoding programs running on the Android system directly decode a frame after acquiring the frame, so that the CPU consumption of the Android system is too high, and the link which consumes the CPU processing performance most obtained through testing is the decoding process. Therefore, according to the embodiment, the decoding frequency is reduced by adopting a scheduling control mode aiming at the problem that the CPU is too high in the decoding process of the Android system under the condition of ensuring normal performance, the consumption of the CPU is effectively reduced, and the POS machine of the bus can run efficiently for a long time.
Fig. 1 is a scanning and decoding method for a riding two-dimensional code provided by the present invention, and as shown in fig. 1, the method includes:
in step S101, image frames are acquired by a camera according to a preset sampling frequency.
According to the embodiment of the invention, the camera is carried on the Android system, so that the camera is used for carrying out image acquisition on the two-dimensional code scanning area of the bus POS machine according to the preset sampling frequency. Alternatively, the preset sampling frequency may be 32 image frames/second.
In step S102, it is determined whether the image frame is a recognizable image frame.
In the process of scanning and decoding the two-dimensional code by the Android system, the decoding process consumes most resources, and the code scanning process does not consume too much resources. When the brightness in the environment is too low, even if the acquired image frame comprises the two-dimensional code image, the black and white boundary in the two-dimensional code image is fuzzy and can hardly be identified. Therefore, the embodiment of the invention screens the image frames which cannot be identified by performing brightness detection on the image frames acquired by the camera to obtain the identifiable image frames. The recognizable image frame refers to an image frame with brightness reaching a recognizable standard.
Optionally, as shown in fig. 2, the step S102 includes:
in step S201, for each image frame captured by a camera, a brightness value of the image frame is calculated, and the brightness value is compared with a first brightness threshold.
Here, the first luminance threshold value is an empirically set luminance threshold value. According to the invention, the brightness under different environments is tested, so that a brightness value corresponding to different environments is obtained, and the brightness value is used as the first brightness threshold. The first brightness threshold value is used as a judgment basis for judging whether the brightness of the image frame collected by the camera reaches an identifiable standard.
And calculating the brightness value of an image frame acquired by the camera each time. Specifically, one pixel point in the selected image frame is used as an initial acquisition point, then the next pixel point is acquired at intervals of a preset step length, the sum of the brightness of the acquired pixel points is calculated, and the obtained brightness value is used as the brightness value of the whole image frame. Comparing the brightness value of the image frame to the first brightness threshold to determine whether the brightness of the image frame meets an identifiable criterion.
In step S202, when the brightness value of the image frame is greater than or equal to the first brightness threshold, the image frame is taken as an identifiable image frame.
Here, when the brightness of the image frame is greater than or equal to the first brightness threshold, indicating that the brightness of the image frame is recognizable, the subsequent scan decoding step is continued with the image frame as a recognizable image frame.
In step S203, when the brightness value of the image frame is smaller than the first brightness threshold, a next image frame acquired by a camera is continuously acquired.
And if the brightness value of the image frame is smaller than the first brightness threshold value, indicating that the brightness of the image frame is unidentifiable, returning to the step S101, and continuously acquiring the image frame collected by the camera for brightness detection.
In step S103, if the image frame is an identifiable image frame, the image frame to be decoded is obtained according to the decoding status of the last identifiable image frame of the image frame.
After obtaining the recognizable image frame, the present embodiment determines whether the recognizable image frame is an image frame to be decoded based on the decoding status of the previous recognizable image frame adjacent to the recognizable image frame. The image frame to be decoded refers to the image frame which is screened from the recognizable image frame and can execute decoding judgment. The embodiment determines whether the current recognizable image frame is the image frame to be decoded or acquires the image frame to be decoded in a preset mode according to the decoding state of the last recognizable image frame. The way of acquiring the image frame to be decoded is different for different decoding states.
In step S104, a decoding process is performed on the image frame to be decoded according to the luminance change value between the image frame to be decoded and the last recognizable image frame.
Here, the decoding judgment mentioned in step S104 refers to judgment as to whether or not a decoding operation is performed on the image frame to be decoded. Specifically, in an actual application scenario, when a user provides a two-dimensional code image to a scanning area of a bus POS machine, an image frame acquired by a camera is significantly different in brightness from an image frame acquired last time. Therefore, in the embodiment, whether the camera collects the two-dimensional code image or not and whether the decoding processing is performed on the image to be decoded or not is determined by acquiring the brightness change value between the image frame to be decoded and the last recognizable image frame. Optionally, as shown in fig. 3, the step S104 includes:
in step S301, the brightness variation value of the image frame to be decoded relative to the last recognizable image frame is compared with a second brightness threshold.
Here, the second luminance threshold value is also an empirically set luminance threshold value. According to the invention, the brightness under different environments is tested, so that the brightness change mean value of the two-dimensional code images corresponding to different environments appearing in the scanning area of the bus POS machine is obtained, and the brightness change mean value is used as the second brightness threshold value. And the second brightness threshold value is used as a judgment basis for judging whether the brightness change of the recognizable image frame reaches the decoding standard.
In step S302, if the brightness variation value is greater than or equal to a second brightness threshold, the image frame to be decoded is decoded.
And if the brightness change value is larger than or equal to the second brightness threshold value, the brightness change reaches a decoding standard, the image frame to be decoded is the image frame acquired when the user provides the two-dimensional code image to the scanning area of the bus POS machine, the image frame to be decoded is decoded, and then the step S101 is continuously returned to obtain the next image frame. While initializing the number of undecoded frames.
In step S303, if the brightness variation value is smaller than the second brightness threshold, the un-decoded frame number is updated, and the un-decoded frame number is compared with a second preset frame number.
And if the brightness change value is smaller than a second brightness threshold value, the brightness change does not reach the decoding standard, the image frame to be decoded is not the image frame acquired by the user providing the two-dimensional code image to the scanning area of the bus POS machine, and the number of undecoded frames is updated. Here, the number of undecoded frames refers to the number of continuous undecoded image frames to be decoded; updating the un-decoded frame number means adding 1 to the original un-decoded frame number to record the current un-decoded operation.
Every time when the updating of the undecoded frame number is completed, the undecoded frame number is compared with a second preset frame number. And the second preset frame number is used as a judgment basis for selecting image frames from continuous undecoded image frames to be decoded and executing decoding operation.
In step S304, if the un-decoded frame number is greater than or equal to a second preset frame number, the image frame to be decoded is decoded, and if the un-decoded frame number is less than the second preset frame number, the next image frame is continuously acquired.
If the accumulated number of the un-decoded frames exceeds the second preset number of frames, initializing the un-decoded frames, and decoding the current image frame to be decoded, even though the brightness change of the current image frame to be decoded does not meet the second brightness threshold value, so as to prevent the Android system from not performing decoding operation on the image frame collected by the camera on the POS machine of the bus for a long time. And if the number of the un-decoded frames does not reach the second preset number of frames, not decoding the current image frame to be decoded, and continuously returning to the step S101 to acquire the next image frame.
Through the steps, the bus POS machine does not need to execute decoding immediately after being started, and the decoding is executed only when the brightness change detects that the two-dimensional code image is provided to the scanning area of the bus POS machine, or the decoding is executed when the number of continuous un-decoded frames is larger than the second preset frame number threshold value, so that the decoding frequency is effectively reduced, and the consumption of a CPU (Central processing Unit) is reduced.
As mentioned above, step S103 obtains the image frame to be decoded according to the decoding status of the last identifiable image frame of the image frame, where the decoding status includes un-decoding, decoding success, and decoding failure. The decoding failure refers to that the Android system decodes the image frame to be decoded but does not obtain the resource.
The way of acquiring the image frame to be decoded is different for different decoding states. Optionally, as a preferred example of the present invention, when the decoding status is not decoded, as shown in fig. 4, the step S103 further includes:
in step S401, for each identifiable image frame, the decoding status of the last identifiable image frame of the identifiable image frame is acquired.
In step S402, if the decoding status is that the last recognizable image frame is not decoded, the recognizable image frame is used as an image frame to be decoded.
In the process of starting up the bus POS machine or in the process of running the bus, a user rarely provides a two-dimensional code image to a scanning area of the bus POS machine in a normal case, the Android system does not decode each recognizable image frame (assuming that the image frames all meet recognizable standards) of the scanning area acquired by the camera at once, but the recognizable image frame is used as an image frame to be decoded, so that brightness change judgment is executed in step S104, and decoding is executed when brightness change detection reaches the decoding standard or when the number of continuous un-decoded frames is greater than or equal to a second preset frame number threshold.
For example, when the 1 st recognizable image frame is obtained in step S102, the Android system does not perform the decoding operation because there is no previous image frame, and the number of undecoded frames is updated to 1; and continuously acquiring the 2 nd recognizable image frame, wherein the 1 st recognizable image frame is not decoded, the 2 nd recognizable image frame is taken as an image frame to be decoded, and the brightness change judgment in the step S104 is executed. If the brightness change value of the 2 nd recognizable image frame is smaller than the second brightness threshold value, the Android system does not execute the decoding operation, and the number of undecoded frames is updated to be 2; and continuing to acquire the 3 rd recognizable image frame, wherein the 2 nd recognizable image frame is not decoded, the 3 rd recognizable image frame is used as an image frame to be decoded, the brightness change judgment in the step S104 is executed, and the like is repeated until the number of undecoded frames is greater than or equal to a second preset frame number threshold, and a decoding operation is executed once. During this period, if any recognizable image frame is used as the image frame to be decoded, the decoding operation is performed on the recognizable image frame when the brightness change obtained after the step S104 is performed is greater than or equal to the second brightness threshold. Optionally, the second preset number of frames is preferably 16 frames.
Optionally, as a preferred example of the present invention, when the decoding status is decoding success, as shown in fig. 5, the step S103 includes:
in step S501, for each identifiable image frame, the decoding status of the last identifiable image frame of the identifiable image frame is acquired.
In step S502, if the decoding status is that the last recognizable image frame is successfully decoded, a hibernation process is performed on the recognizable image frame and the recognizable image frames following the recognizable image frame.
The hibernation processing means that the decoding operation is not performed on the acquired recognizable image frame and the acquisition of the next recognizable image frame is continued. The embodiment executes corresponding dormancy processing on the currently acquired recognizable image frame and the recognizable image frame acquired next by the camera according to the decoding state of the last recognizable image frame. And when the decoding state of the last recognizable image frame is decoding success, the bus POS machine is indicated to just acquire the two-dimensional code image provided by the user terminal. Because the two-dimensional code image of the user side leaves the scanning area of the bus POS machine, a time process exists, the two-dimensional code image provided by the next user side cannot be immediately displayed in the scanning area of the bus POS machine, and the recognizable image frame acquired by the bus POS machine through the camera in the process usually does not contain the two-dimensional code image. In view of this, the present embodiment performs a sleep operation on a number of identifiable image frames after the successfully decoded image frame to be decoded, and suspends decoding, so as to reduce consumption of CPU performance.
In step S503, when the consecutive dormant recognizable image frames reach the first preset number of frames, the next recognizable image frame is acquired as an image frame to be decoded.
The first preset frame number can be set empirically according to the time interval between the two user terminals providing the two-dimensional code information to the scanning area of the bus POS machine. Optionally, the first preset number of frames is preferably 5 frames. And when the continuously dormant recognizable image frames reach the first preset frame number and the next user terminal is considered to possibly provide the two-dimensional code information to the scanning area, defaulting the next recognizable image frame as the image frame to be decoded. And continuing to execute the step S104, and executing decoding judgment according to the brightness change value of the image frame to be decoded.
Taking the foregoing example, assuming that the second preset frame number is 16 frames, and the first preset frame number is 5 frames, if the camera is successfully decoding the 16 th recognizable image frame, when the camera acquires the 17 th recognizable image frame, because the 16 th recognizable image frame is successfully decoded, the hibernation processing is performed on the 17 th recognizable image frame and the 18 th, 19 th, 20 th and 21 th recognizable image frames acquired next by the camera, the decoding is suspended, after the recognizable image frames in continuous hibernation reach 5 frames, the 22 th recognizable image frame acquired next by the camera is acquired as the image frame to be decoded, the step S104 is continuously performed, and the decoding determination is performed according to the brightness change value of the image frame to be decoded.
The image frames to be decoded generated due to brightness change in the embodiment of fig. 3 and the image frames to be decoded generated after continuous sleep in the embodiment of fig. 5 are ideally expected to be successfully decoded, but there may be a case where decoding fails. Considering the frequency of the camera acquiring the image frames and the time length of the environmental state change, the adjacent image frames are very similar, if the next image frame is immediately acquired as the image frame to be decoded for decoding, the possibility of failure is high due to the same reason, and further the consumption of a CPU is increased. Accordingly, the decoding frequency is further adjusted in this embodiment.
Optionally, as a preferred example of the present invention, when the decoding status is decoding failure, as shown in fig. 6, the step S103 further includes:
in step S601, for each identifiable image frame, a decoding status of a last identifiable image frame of the identifiable image frames is acquired.
In step S602, if the decoding status is that the decoding of the previous recognizable image frame fails, the decoding failure frame number is updated.
Here, for the image frames to be decoded after the continuous sleep or the image frames to be decoded whose luminance changes satisfy the second luminance threshold, if the decoding fails, the embodiment adjusts the corresponding decoding frequency. The decoding failure frame number is used for recording the continuous frame number of the dormant image frame to be decoded after the decoding failure or the continuous frame number of the image frame to be decoded after the decoding failure, wherein the brightness change of the image frame to be decoded meets a second brightness threshold value.
Illustratively, the first recognizable image frame obtained after the continuous hibernation is decoded according to the logic of the embodiment of fig. 5, and if the decoding fails, the 2 nd recognizable image frame after the continuous hibernation is acquired again. And for the 2 nd recognizable image frame, if the decoding state of the last recognizable image frame is decoding failure, updating the decoding failure frame number, such as updating from 0 to 1, and if the 2 nd recognizable image frame also defaults to decoding failure, acquiring the 3 rd recognizable image frame after continuous dormancy again. And for the 3 rd identifiable image frame, if the decoding state of the last identifiable image frame is decoding failure, updating the decoding failure frame number, such as updating from 1 to 2, wherein the 3 rd identifiable image frame also defaults to decoding failure, and acquiring the 4 th identifiable image frame after continuous dormancy again. For the 4 th identifiable image frame, and so on.
And when the brightness change meets the second brightness threshold value to obtain the image frame to be decoded, decoding the image frame according to the logic of the embodiment of fig. 3, and if the decoding fails, acquiring the 2 nd recognizable image frame after the brightness change again. And for the 2 nd recognizable image frame, if the decoding state of the last recognizable image frame is decoding failure, updating the decoding failure frame number, such as updating from 0 to 1, and if the 2 nd recognizable image frame also defaults to decoding failure, acquiring the 3 rd recognizable image frame after continuous dormancy again. And for the 3 rd identifiable image frame, if the decoding state of the last identifiable image frame is decoding failure, updating the decoding failure frame number, for example, updating from 1 to 2, and if the 3 rd identifiable image frame also defaults to decoding failure, acquiring the 4 th identifiable image frame after brightness change again. For the 4 th identifiable image frame, and so on.
In step S603, the decoding failure frame number is compared with a third preset frame number.
Here, the third preset number of frames is used to decide how long the decoding operation is performed again after the decoding fails for the image frame to be decoded after the continuous sleep or the image frame to be decoded whose luminance variation satisfies the second luminance threshold.
In step S604, if the decoding failure frame number is greater than or equal to a third preset frame number, the recognizable image frame is used as an image frame to be decoded.
Here, if the decoding failure frame number is greater than or equal to a third preset frame number, indicating that sufficient frame number has been suspended for decoding, the decoding operation is performed again, with the current recognizable image frame as the image frame to be decoded. And initializing the decoding failure frame number.
Taking the foregoing example, after the first image frame to be decoded obtained after continuous hibernation fails to be decoded, the decoding failure frame number is updated. When the third preset frame number is 3, updating the decoding failure frame number to be 3 for the 4 th recognizable image frame, and if the decoding failure frame number is equal to the third preset frame number, taking the 4 th recognizable image frame as the image frame to be decoded, and executing the decoding judgment operation in step S104.
Similarly, after the first image frame to be decoded obtained after the brightness change fails to be decoded, the decoding failure frame number is updated. When the third preset frame number is 3, updating the decoding failure frame number to be 3 for the 4 th recognizable image frame, and if the decoding failure frame number is equal to the third preset frame number, taking the 4 th recognizable image frame as the image frame to be decoded, and executing the decoding judgment operation in step S104.
In step S605, if the decoding failure frame number is less than the third preset frame number, the next recognizable image frame is continuously acquired.
Here, if the decoding failure frame number is less than the third preset frame number, indicating that the decoding is not suspended for a sufficient number of frames, the current identifiable image frame is decoded in failure by default, and the next identifiable image frame is continuously acquired.
Through the steps S601 to S603, if the decoding fails, the embodiment adjusts the corresponding decoding frequency for the image frames to be decoded after continuous dormancy or the image frames to be decoded whose luminance change meets the second luminance threshold, thereby avoiding the decoding failure caused by the same reason and further reducing the consumption of the CPU.
In summary, in the present embodiment, for each image frame acquired by a camera, image frames with appropriate brightness are screened out by calculating brightness values of the image frames, and image frames that cannot be decoded are removed to obtain identifiable image frames; monitoring the brightness fluctuation condition of a scanning area by combining the decoding state of the last identifiable image frame, and executing sleep operation or pausing decoding on the identifiable image frame and the identifiable image frame collected by the camera next, thereby effectively reducing the decoding frequency of a CPU; when the recognizable image frame of continuous dormancy reaches the first preset frame number or the decoding failure frame number after continuous dormancy and brightness change reaches the third preset frame number threshold value, the next recognizable image frame is obtained to carry out decoding judgment, on the premise of ensuring the decoding performance of the bus POS machine, the decoding frequency is effectively reduced, and the consumption of a CPU is reduced.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
In an embodiment, a scanning and decoding device for a riding two-dimensional code is provided, and the scanning and decoding device for the riding two-dimensional code corresponds to the scanning and decoding method for the riding two-dimensional code in the above embodiment one to one. As shown in fig. 7, the scanning and decoding device for the riding two-dimensional code includes an acquisition module 71, a determination module 72, an acquisition module 73, and a decoding module 74. The functional modules are explained in detail as follows:
the acquisition module 71 is configured to acquire an image frame according to a preset sampling frequency by using a camera;
a judging module 72, configured to judge whether the image frame is an identifiable image frame;
an obtaining module 73, configured to obtain, if the image frame is an identifiable image frame, an image frame to be decoded according to a decoding state of a last identifiable image frame of the image frame;
and the decoding module 74 is configured to perform decoding processing on the image frame to be decoded according to the brightness change value between the image frame to be decoded and the last recognizable image frame.
Optionally, the decoding module 74 further includes:
the first comparison unit is used for comparing the brightness change value of the image frame to be decoded relative to the last identifiable image frame with a second brightness threshold value;
the first decoding unit is used for decoding the image frame to be decoded if the brightness change value is larger than or equal to the second brightness threshold value;
the second comparison unit is used for updating the undecoded frame number and comparing the undecoded frame number with a second preset frame number if the brightness change value is smaller than the second brightness threshold value;
and the second decoding unit is used for decoding the image frame to be decoded if the undecoded frame number is greater than or equal to a second preset frame number, and continuously acquiring the next image frame if the undecoded frame number is less than the second preset frame number.
Optionally, the determining module 72 further includes:
the brightness comparison unit is used for calculating the brightness value of each image frame collected by the camera and comparing the brightness value with a first brightness threshold value;
an identifiable frame acquisition unit configured to take the image frame as an identifiable image frame when a brightness value of the image frame is greater than or equal to the first brightness threshold;
and the first polling unit is used for continuously acquiring the next image frame collected by the camera when the brightness value of the image frame is smaller than the first brightness threshold value.
Optionally, the obtaining module 73 includes:
the state acquisition unit is used for acquiring the decoding state of the last identifiable image frame of the identifiable image frames for each identifiable image frame;
and the first frame to be decoded acquiring unit is used for taking the identifiable image frame as the image frame to be decoded if the decoding state is that the last identifiable image frame is not decoded.
Optionally, the obtaining module 73 further includes:
the state acquisition unit is used for acquiring the decoding state of the last identifiable image frame of the identifiable image frames for each identifiable image frame;
the dormancy unit is used for executing dormancy processing on the identifiable image frame and the subsequent identifiable image frames if the decoding state is that the last identifiable image frame is successfully decoded;
and the second frame acquiring unit to be decoded is used for acquiring the next recognizable image frame as the image frame to be decoded when the continuously dormant recognizable image frames reach the first preset frame number.
Optionally, the obtaining module 73 further includes:
the state acquisition unit is used for acquiring the decoding state of the last identifiable image frame of the identifiable image frames for each identifiable image frame;
the updating unit is used for updating the decoding failure frame number if the decoding state is that the decoding of the last identifiable image frame fails;
a frame number comparison unit for comparing the decoding failure frame number with a third preset frame number;
a third frame to be decoded obtaining unit, configured to use the identifiable image frame as an image frame to be decoded if the decoding failure frame number is greater than or equal to a third preset frame number;
and the second polling unit is used for continuously acquiring the next identifiable image frame if the decoding failure frame number is less than the third preset frame number.
For specific limitations of the scanning and decoding device for the riding two-dimensional code, reference may be made to the above limitations of the scanning and decoding method for the riding two-dimensional code, which are not described herein again. All or part of each module in the scanning and decoding device for the riding two-dimensional code can be realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 8. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to realize a scanning and decoding method of the riding two-dimensional code.
In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
acquiring an image frame according to a preset sampling frequency through a camera;
judging whether the image frame is an identifiable image frame;
if the image frame is an identifiable image frame, acquiring an image frame to be decoded according to the decoding state of the last identifiable image frame of the image frame;
and executing decoding processing on the image frame to be decoded according to the brightness change value between the image frame to be decoded and the last identifiable image frame.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, databases, or other media used in embodiments provided herein may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1. A scanning and decoding method for a riding two-dimensional code is characterized by comprising the following steps:
acquiring an image frame according to a preset sampling frequency through a camera;
judging whether the image frame is an identifiable image frame;
if the image frame is an identifiable image frame, acquiring an image frame to be decoded according to the decoding state of the last identifiable image frame of the image frame;
and executing decoding processing on the image frame to be decoded according to the brightness change value between the image frame to be decoded and the last identifiable image frame.
2. The scanning and decoding method for the riding two-dimensional code as claimed in claim 1, wherein the determining whether the image frame is a recognizable image frame comprises:
for each image frame collected by a camera, calculating a brightness value of the image frame, and comparing the brightness value with a first brightness threshold value;
when the brightness value of the image frame is greater than or equal to the first brightness threshold value, taking the image frame as an identifiable image frame;
and when the brightness value of the image frame is smaller than the first brightness threshold value, continuously acquiring the next image frame collected by the camera.
3. The scanning and decoding method for the riding two-dimensional code as claimed in claim 2, wherein the obtaining of the image frame to be decoded according to the decoding state of the last recognizable image frame of the image frame comprises:
for each identifiable image frame, acquiring a decoding status of a last identifiable image frame of the identifiable image frames;
and if the decoding state is that the last identifiable image frame is not decoded, taking the identifiable image frame as an image frame to be decoded.
4. The scanning and decoding method for the riding two-dimensional code as claimed in claim 2, wherein the obtaining of the image frame to be decoded according to the decoding state of the last recognizable image frame of the image frame comprises:
for each identifiable image frame, acquiring a decoding status of a last identifiable image frame of the identifiable image frames;
if the decoding state is that the last identifiable image frame is successfully decoded, performing dormancy processing on the identifiable image frame and identifiable image frames behind the identifiable image frame;
and when the continuously dormant identifiable image frames reach the first preset frame number, acquiring the next identifiable image frame as the image frame to be decoded.
5. The scanning and decoding method for the riding two-dimensional code as claimed in claim 2, wherein the obtaining of the image frame to be decoded according to the decoding state of the last recognizable image frame of the image frame comprises:
for each identifiable image frame, acquiring a decoding status of a last identifiable image frame of the identifiable image frames;
if the decoding state is that the decoding of the last identifiable image frame fails, updating the decoding failure frame number;
comparing the decoding failure frame number with a third preset frame number;
if the decoding failure frame number is greater than or equal to a third preset frame number, taking the identifiable image frame as an image frame to be decoded;
and if the decoding failure frame number is less than the third preset frame number, continuously acquiring a next identifiable image frame.
6. The scanning and decoding method for the riding two-dimensional code according to any one of claims 2 to 5, wherein the performing of decoding processing on the image frame to be decoded according to the brightness change value between the image frame to be decoded and the last recognizable image frame comprises:
comparing the brightness change value of the image frame to be decoded relative to the last identifiable image frame with a second brightness threshold value;
if the brightness change value is larger than or equal to the second brightness threshold value, decoding the image frame to be decoded;
if the brightness change value is smaller than the second brightness threshold value, updating the number of undecoded frames, and comparing the number of undecoded frames with a second preset number of frames;
if the undecoded frame number is greater than or equal to a second preset frame number, decoding the image frame to be decoded, and if the undecoded frame number is less than the second preset frame number, continuously acquiring a next image frame.
7. A scanning and decoding device for a riding two-dimensional code is characterized by comprising:
the acquisition module is used for acquiring image frames according to a preset sampling frequency through the camera;
the judging module is used for judging whether the image frame is an identifiable image frame;
the acquisition module is used for acquiring an image frame to be decoded according to the decoding state of the last identifiable image frame of the image frame if the image frame is the identifiable image frame;
and the decoding module is used for executing decoding processing on the image frame to be decoded according to the brightness change value between the image frame to be decoded and the last identifiable image frame.
8. The scanning and decoding device for the riding two-dimensional code as claimed in claim 7, wherein the decoding module comprises:
the first comparison unit is used for comparing the brightness change value of the image frame to be decoded relative to the last identifiable image frame with a second brightness threshold value;
the first decoding unit is used for decoding the image frame to be decoded if the brightness change value is larger than or equal to the second brightness threshold value;
the second comparison unit is used for updating the undecoded frame number and comparing the undecoded frame number with a second preset frame number if the brightness change value is smaller than the second brightness threshold value;
and the second decoding unit is used for decoding the image frame to be decoded if the undecoded frame number is greater than or equal to a second preset frame number, and continuously acquiring the next image frame if the undecoded frame number is less than the second preset frame number.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the scanning and decoding method for a ride two-dimensional code according to any one of claims 1 to 6 when executing the computer program.
10. A computer-readable storage medium storing a computer program, wherein the computer program is executed by a processor to implement the scanning and decoding method for a ride two-dimensional code according to any one of claims 1 to 6.
CN202010604246.5A 2020-06-29 2020-06-29 Scanning decoding method, device and equipment for riding two-dimension code and storage medium Active CN113935352B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010604246.5A CN113935352B (en) 2020-06-29 2020-06-29 Scanning decoding method, device and equipment for riding two-dimension code and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010604246.5A CN113935352B (en) 2020-06-29 2020-06-29 Scanning decoding method, device and equipment for riding two-dimension code and storage medium

Publications (2)

Publication Number Publication Date
CN113935352A true CN113935352A (en) 2022-01-14
CN113935352B CN113935352B (en) 2024-10-11

Family

ID=79272812

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010604246.5A Active CN113935352B (en) 2020-06-29 2020-06-29 Scanning decoding method, device and equipment for riding two-dimension code and storage medium

Country Status (1)

Country Link
CN (1) CN113935352B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116739014A (en) * 2022-09-15 2023-09-12 荣耀终端有限公司 Code scanning method and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004145630A (en) * 2002-10-24 2004-05-20 Denso Wave Inc Optical information reader
CN107018328A (en) * 2017-04-11 2017-08-04 珠海市魅族科技有限公司 A kind of image scan method method and image-scanning device
CN107908998A (en) * 2017-11-28 2018-04-13 百富计算机技术(深圳)有限公司 Quick Response Code coding/decoding method, device, terminal device and computer-readable recording medium
CN108960384A (en) * 2018-06-07 2018-12-07 阿里巴巴集团控股有限公司 A kind of coding/decoding method and client of graphic code

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004145630A (en) * 2002-10-24 2004-05-20 Denso Wave Inc Optical information reader
CN107018328A (en) * 2017-04-11 2017-08-04 珠海市魅族科技有限公司 A kind of image scan method method and image-scanning device
CN107908998A (en) * 2017-11-28 2018-04-13 百富计算机技术(深圳)有限公司 Quick Response Code coding/decoding method, device, terminal device and computer-readable recording medium
CN108960384A (en) * 2018-06-07 2018-12-07 阿里巴巴集团控股有限公司 A kind of coding/decoding method and client of graphic code

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116739014A (en) * 2022-09-15 2023-09-12 荣耀终端有限公司 Code scanning method and electronic equipment
WO2024055817A1 (en) * 2022-09-15 2024-03-21 荣耀终端有限公司 Code scanning method and electronic device
CN116739014B (en) * 2022-09-15 2024-09-17 荣耀终端有限公司 Code scanning method and electronic equipment

Also Published As

Publication number Publication date
CN113935352B (en) 2024-10-11

Similar Documents

Publication Publication Date Title
CN109829859B (en) Image processing method and terminal equipment
CN107948744B (en) Interface detection method, interface detection device, and computer-readable storage medium
KR102528877B1 (en) Video decoding control method, device, electronic device and storage medium
CN110012217B (en) Method and device for determining acquisition resolution and electronic equipment
CN110765847B (en) Font adjustment method, device, equipment and medium based on face recognition
CN110049310B (en) Video image acquisition method and device, video quality detection method and device
US20130055271A1 (en) Apparatus and method for controlling polling
WO2022252877A1 (en) Image processing chip, and abnormality processing method applied to image processing chip
CN110719332A (en) Data transmission method, device, system, computer equipment and storage medium
CN111405273A (en) Camera operation and maintenance method and system
CN113411573A (en) Power grid monitoring system detection method and device, computer equipment and medium
CN113196707B (en) Detection device, detection method, and recording medium
CN110738156B (en) Face recognition system and method based on message middleware
CN111050027B (en) Lens distortion compensation method, device, equipment and storage medium
CN113935352A (en) Method, device and equipment for scanning and decoding riding two-dimensional code and storage medium
WO2019144262A1 (en) Smudge detection method and apparatus and mobile electronic device
CN111833232B (en) Image processing apparatus
CN105827890A (en) Method and apparatus for scanning 2D codes
CN113068050B (en) Method and device for determining sample point adaptive compensation mode of tree-shaped coding block
CN112528115B (en) Website monitoring method and device
CN109819187B (en) Video recording control method and device, mobile terminal and storage medium
KR20110007838A (en) Image processing method and apparatus
CN110971825A (en) Image correction method, electronic device and storage medium
CN110932941B (en) Cloud screen connection state detection method, server and storage medium
CN113296597B (en) Power consumption control method and terminal equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant