CN107609446B - Code pattern recognition method, terminal and computer readable storage medium - Google Patents

Code pattern recognition method, terminal and computer readable storage medium Download PDF

Info

Publication number
CN107609446B
CN107609446B CN201710638928.6A CN201710638928A CN107609446B CN 107609446 B CN107609446 B CN 107609446B CN 201710638928 A CN201710638928 A CN 201710638928A CN 107609446 B CN107609446 B CN 107609446B
Authority
CN
China
Prior art keywords
code pattern
code
preset
image
overexposed
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.)
Active
Application number
CN201710638928.6A
Other languages
Chinese (zh)
Other versions
CN107609446A (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.)
Nubia Technology Co Ltd
Original Assignee
Nubia Technology 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 Nubia Technology Co Ltd filed Critical Nubia Technology Co Ltd
Priority to CN201710638928.6A priority Critical patent/CN107609446B/en
Publication of CN107609446A publication Critical patent/CN107609446A/en
Application granted granted Critical
Publication of CN107609446B publication Critical patent/CN107609446B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Studio Devices (AREA)

Abstract

The invention discloses a code pattern recognition method, a terminal and a computer readable storage medium, aiming at the problems of low code pattern recognition rate and low recognition speed caused by overexposure in the existing code pattern recognition, the invention acquires an image of a code pattern to be recognized through a preset recognition area of a camera shooting module, determines the exposure level of the code pattern, and acquires the code pattern to be recognized again through other recognition areas which are not overlapped with the preset recognition area when the exposure level of the code pattern is overexposure, so that the code pattern recognition is carried out through a plurality of recognition areas, the recognition area which can be actually applied by the terminal shooting module is successfully utilized instead of only utilizing the preset recognition area, and the speed and the accuracy of code pattern recognition are improved.

Description

Code pattern recognition method, terminal and computer readable storage medium
Technical Field
The present invention relates to the field of terminal technologies, and in particular, to a code pattern recognition method, a terminal, and a computer-readable storage medium.
Background
With the development of mobile intelligent terminals, people rely on the mobile terminals more and more, and in the use scenes of the mobile terminals, code scanning scenes are more and more, so that the mobile intelligent terminals are generally applied to use scenes of payment, account transfer, bicycle sharing, friend adding and the like. In the actual code scanning process, since the external light is too bright, or when light is compensated by a flash lamp, overexposure of the code image may be caused, please refer to fig. 1, fig. 1 shows a display schematic diagram of overexposure of the two-dimensional code, and a default identification area in the diagram is an identification area adopted by various system applications or third-party applications, since the identification area is fixed and the overexposure of the code image under strong light is caused, the identification process of the two-dimensional code is long or direct identification fails, a user needs to spend more time to adjust the angle of the terminal to realize the change of the light input amount, the adjustment process is more complicated when the environment is worse, and the user experience is worse.
Disclosure of Invention
The technical problem to be solved by the present invention is how to avoid the influence of overexposure of a code pattern under strong light on the identification speed and accuracy, and to this technical problem, a code pattern identification method, a terminal and a computer readable storage medium are provided.
In order to solve the above technical problem, the present invention provides a code pattern recognition method, including:
acquiring an image of a code pattern to be identified through a preset identification area of the camera module;
determining the exposure level of the code pattern;
and when the exposure of the code pattern is overexposure, acquiring the code pattern to be identified again through other identification areas which are not overlapped with the preset identification area, wherein the other identification areas comprise at least one.
Optionally, the determining the exposure level of the code pattern includes:
dividing the code graph into at least two parts according to a preset rule;
respectively detecting the exposure of each part of the code pattern;
and when the overexposed part in the code image meets a preset condition, judging that the exposure degree of the code image is overexposed.
Optionally, the dividing the code graph into at least two parts according to a preset rule includes: dividing the code image into nine parts in a nine-square grid mode;
when the overexposed part in the code pattern meets a preset condition, the method comprises the following steps: in the code pattern, the part positioned in the middle is overexposed; and/or the number of the overexposed parts in the code map is more than or equal to a preset value.
Optionally, after the code pattern to be identified is obtained again through the other identification areas where the preset identification areas are not overlapped, if the exposure level of the code pattern is still overexposed, then: and sending a prompt message, wherein the prompt message is used for reminding a user to adjust the light entering amount of the image of the code pattern acquired by the terminal.
Optionally, the other identification areas include two identification areas, and the two identification areas are respectively located at the upper part and the lower part of the preset identification area.
The invention also provides a terminal, which comprises a processor, a memory, a camera module and a communication bus;
the communication bus is used for realizing connection communication between the processor and the memory;
the processor is used for executing the code pattern identification program stored in the memory to realize the following steps:
acquiring an image of a code pattern to be identified through a preset identification area of the camera module;
determining the exposure level of the code pattern;
and when the exposure of the code pattern is overexposure, acquiring the code pattern to be identified again through other identification areas which are not overlapped with the preset identification area, wherein the other identification areas comprise at least one.
Optionally, the determining the exposure level of the code pattern includes:
dividing the code graph into at least two parts according to a preset rule;
respectively detecting the exposure of each part of the code pattern;
and when the overexposed part in the code image meets a preset condition, judging that the exposure degree of the code image is overexposed.
Optionally, the dividing the code graph into at least two parts according to a preset rule includes: dividing the code image into nine parts in a nine-square grid mode;
when the overexposed part in the code pattern meets a preset condition, the method comprises the following steps: in the code pattern, the part positioned in the middle is overexposed; and/or the number of the overexposed parts in the code map is more than or equal to a preset value.
Optionally, after the code pattern to be identified is obtained again through the other identification areas where the preset identification areas are not overlapped, if the exposure level of the code pattern is still overexposed, then: and sending a prompt message, wherein the prompt message is used for reminding a user to adjust the light entering amount of the image of the code pattern acquired by the terminal.
The present invention also provides a computer readable storage medium storing one or more programs, the one or more programs being executable by one or more processors to implement the steps of the code pattern recognition method described above.
Advantageous effects
The invention provides a code pattern recognition method, a terminal and a computer readable storage medium, aiming at the problems of low code pattern recognition rate and low recognition speed caused by overexposure in the existing code pattern recognition, the invention acquires an image of a code pattern to be recognized through a preset recognition area of a camera shooting module, determines the exposure level of the code pattern, and acquires the code pattern to be recognized again through other recognition areas which are not overlapped with the preset recognition area when the exposure level of the code pattern is overexposure, so that the code pattern recognition is carried out through a plurality of recognition areas, the recognition area which can be actually applied by the terminal shooting module is successfully utilized instead of only utilizing the preset recognition area, and the speed and the accuracy of code pattern recognition are improved.
Drawings
The invention will be further described with reference to the accompanying drawings and examples, in which:
FIG. 1 is a schematic diagram of two-dimension code identification overexposure in the prior art;
fig. 2 is a schematic diagram of a hardware structure of an alternative mobile terminal for implementing various embodiments of the present invention;
FIG. 3 is a basic flowchart of a code pattern recognition method according to a first embodiment of the present invention;
fig. 4 is a schematic diagram of a preset identification area on a display panel of a terminal according to various embodiments of the present invention;
FIG. 5 is a schematic diagram of identification regions provided by embodiments of the present invention;
FIG. 6 is a schematic diagram of a division manner of a code pattern squared figure provided by each embodiment of the present invention;
FIG. 7 is a flowchart illustrating a code pattern recognition method according to a second embodiment of the present invention;
FIG. 8 is a flowchart illustrating a method for determining exposure of a code pattern according to a second embodiment of the present invention;
fig. 9 is a schematic structural diagram of a terminal according to a third embodiment of the present invention.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
In the following description, suffixes such as "module", "component", or "unit" used to denote elements are used only for facilitating the explanation of the present invention, and have no specific meaning in itself. Thus, "module", "component" or "unit" may be used mixedly.
The terminal may be implemented in various forms. For example, the terminal described in the present invention may include a mobile terminal such as a mobile phone, a tablet computer, a notebook computer, a palmtop computer, a Personal Digital Assistant (PDA), a Portable Media Player (PMP), a navigation device, a wearable device, a smart band, a pedometer, and the like, and a fixed terminal such as a Digital TV, a desktop computer, and the like.
The following description will be given by way of example of a mobile terminal, and it will be understood by those skilled in the art that the construction according to the embodiment of the present invention can be applied to a fixed type terminal, in addition to elements particularly used for mobile purposes.
Referring to fig. 2, which is a schematic diagram of a hardware structure of a mobile terminal for implementing various embodiments of the present invention, the mobile terminal 100 may include: RF (Radio Frequency) unit 101, WiFi module 102, audio output unit 103, a/V (audio/video) input unit 104, sensor 105, display unit 106, user input unit 107, interface unit 108, memory 109, processor 110, and power supply 111. Those skilled in the art will appreciate that the mobile terminal architecture shown in fig. 2 is not intended to be limiting of mobile terminals, and that a mobile terminal may include more or fewer components than shown, or some components may be combined, or a different arrangement of components.
The following describes each component of the mobile terminal in detail with reference to fig. 2:
the Radio Frequency unit 101 may be configured to receive and transmit signals during a message transmission or call, specifically, receive downlink information of a base station and then process the received downlink information to the processor 110, and transmit uplink data to the base station, in General, the Radio Frequency unit 101 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, and the like, and in addition, the Radio Frequency unit 101 may further communicate with a network and other devices through wireless communication, and the wireless communication may use any communication standard or protocol, including, but not limited to, GSM (Global System of Mobile communication), GPRS (General Packet Radio Service), CDMA2000(Code Division Multiple Access 2000), WCDMA (Wideband Code Division Multiple Access ), TD-SCDMA (Synchronous Time Division Multiple Access, Code Division Multiple Access, Time Division Multiple Access, etc., TDD — Time Division Multiple Access, L Time Division Multiple Access, etc.
WiFi belongs to short-distance wireless transmission technology, and the mobile terminal can help a user to receive and send e-mails, browse webpages, access streaming media and the like through the WiFi module 102, and provides wireless broadband internet access for the user. Although fig. 2 shows the WiFi module 102, it is understood that it does not belong to the essential constitution of the mobile terminal, and may be omitted entirely as needed within the scope not changing the essence of the invention.
The audio output unit 103 may convert audio data received by the radio frequency unit 101 or the WiFi module 102 or stored in the memory 109 into an audio signal and output as sound when the mobile terminal 100 is in a call signal reception mode, a call mode, a recording mode, a voice recognition mode, a broadcast reception mode, or the like. Also, the audio output unit 103 may also provide audio output related to a specific function performed by the mobile terminal 100 (e.g., a call signal reception sound, a message reception sound, etc.). The audio output unit 103 may include a speaker, a buzzer, and the like.
The a/V input unit 104 is used to receive audio or video signals. The a/V input Unit 104 may include a Graphics Processing Unit (GPU) 1041 and a microphone 1042, the Graphics processor 1041 Processing image data of still pictures or video obtained by an image capturing device (e.g., a camera) in a video capturing mode or an image capturing mode. The processed image frames may be displayed on the display unit 106. The image frames processed by the graphic processor 1041 may be stored in the memory 109 (or other storage medium) or transmitted via the radio frequency unit 101 or the WiFi module 102. The microphone 1042 may receive sounds (audio data) via the microphone 1042 in a phone call mode, a recording mode, a voice recognition mode, or the like, and may be capable of processing such sounds into audio data. The processed audio (voice) data may be converted into a format output transmittable to a mobile communication base station via the radio frequency unit 101 in case of a phone call mode. The microphone 1042 may implement various types of noise cancellation (or suppression) algorithms to cancel (or suppress) noise or interference generated in the course of receiving and transmitting audio signals.
The mobile terminal 100 also includes at least one sensor 105, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor that can adjust the brightness of the display panel 1061 according to the brightness of ambient light, and a proximity sensor that can turn off the display panel 1061 and/or a backlight when the mobile terminal 100 is moved to the ear. As one of the motion sensors, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when stationary, and can be used for applications of recognizing the posture of a mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured on the mobile phone, further description is omitted here.
The Display unit 106 may include a Display panel 1061, and the Display panel 1061 may be configured in the form of a liquid Crystal Display (L acquired Crystal Display, L CD), an Organic light-Emitting Diode (O L ED), or the like.
The user input unit 107 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the mobile terminal. Specifically, the user input unit 107 may include a touch panel 1071 and other input devices 1072. The touch panel 1071, also referred to as a touch screen, may collect a touch operation performed by a user on or near the touch panel 1071 (e.g., an operation performed by the user on or near the touch panel 1071 using a finger, a stylus, or any other suitable object or accessory), and drive a corresponding connection device according to a predetermined program. The touch panel 1071 may include two parts of a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 110, and can receive and execute commands sent by the processor 110. In addition, the touch panel 1071 may be implemented in various types, such as a resistive type, a capacitive type, an infrared ray, and a surface acoustic wave. In addition to the touch panel 1071, the user input unit 107 may include other input devices 1072. In particular, other input devices 1072 may include, but are not limited to, one or more of a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like, and are not limited to these specific examples.
Further, the touch panel 1071 may cover the display panel 1061, and when the touch panel 1071 detects a touch operation thereon or nearby, the touch panel 1071 transmits the touch operation to the processor 110 to determine the type of the touch event, and then the processor 110 provides a corresponding visual output on the display panel 1061 according to the type of the touch event. Although the touch panel 1071 and the display panel 1061 are shown in fig. 2 as two separate components to implement the input and output functions of the mobile terminal, in some embodiments, the touch panel 1071 and the display panel 1061 may be integrated to implement the input and output functions of the mobile terminal, and is not limited herein.
The interface unit 108 serves as an interface through which at least one external device is connected to the mobile terminal 100. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device having an identification module, an audio input/output (I/O) port, a video I/O port, an earphone port, and the like. The interface unit 108 may be used to receive input (e.g., data information, power, etc.) from external devices and transmit the received input to one or more elements within the mobile terminal 100 or may be used to transmit data between the mobile terminal 100 and external devices.
The memory 109 may be used to store software programs as well as various data. The memory 109 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. Further, the memory 109 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
The processor 110 is a control center of the mobile terminal, connects various parts of the entire mobile terminal using various interfaces and lines, and performs various functions of the mobile terminal and processes data by operating or executing software programs and/or modules stored in the memory 109 and calling data stored in the memory 109, thereby performing overall monitoring of the mobile terminal. Processor 110 may include one or more processing units; preferably, the processor 110 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 110.
The mobile terminal 100 may further include a power supply 111 (e.g., a battery) for supplying power to various components, and preferably, the power supply 111 may be logically connected to the processor 110 via a power management system, so as to manage charging, discharging, and power consumption management functions via the power management system.
Although not shown in fig. 2, the mobile terminal 100 may further include a bluetooth module or the like, which is not described in detail herein.
Based on the hardware structure of the mobile terminal, the invention provides various embodiments of the method.
First embodiment
Fig. 3 is a basic flowchart of a code pattern recognition method provided in this embodiment, where the code pattern recognition method includes:
s301, acquiring an image of a code pattern to be identified through a preset identification area of the camera module;
s302, determining the exposure of the code pattern;
s303, when the exposure of the code pattern is overexposure, acquiring the code pattern to be identified again through other identification areas which are not overlapped with the preset identification area, wherein the other identification areas comprise at least one.
The code map mainly comprises a bar code and a two-dimensional code, specifically, the bar code is an identifier which expresses a group of information by arranging a plurality of black bars and blanks with different widths according to a certain coding rule. Common bar codes are a pattern of parallel lines of black and white bars with widely differing emissivity. The bar code is generally applied to commodity transaction, which can indicate the producing country, manufacturer, commodity name, production date and price of an article, can also be applied to book classification and book classification number, and can also be applied to mail and indicate a lot of information such as starting and stopping places, categories and dates of the mail. The barcode has a simple structure, but since it can store information in only one direction, its storage capacity is very limited, and its storage capacity generally corresponds to information of several tens of characters. The two-dimensional code is an upgrade of the bar code in a certain sense, and records data symbol information by using black and white patterns which are distributed in a certain rule in a two-dimensional direction by using a certain specific set pattern.
The bar code and the two-dimensional code are used as code diagrams and can be identified by the terminal camera module. In the identification process, firstly, the code image is collected and opened through system software or third-party software on the terminal, and then the image of the code image is acquired through a camera on the terminal. Referring to fig. 4, fig. 4 is a schematic diagram illustrating a preset identification area on a display panel of a terminal, which is generally located in the middle of a display screen of the terminal, but images can still be captured at other positions on the display screen of the terminal. In view of this, in the embodiment, other identification areas that do not overlap with the preset identification area are disposed at other positions of the display screen, please refer to fig. 5, where fig. 5 shows that when two other identification areas are included, the specific positions of the other identification areas are respectively located at the upper portion and the lower portion of the preset identification area.
In S302, the exposure level of the code pattern is determined. The exposure level, i.e., the exposure amount, is generally determined by the aperture value of the camera module, the exposure time, and the sensitivity of the photosensitive element, and of course, the influence of the ambient brightness. How to directly cause the specific exposure condition of the code image by the ambient brightness, when the ambient brightness is too bright, the obtained code image is inevitably too high in exposure, that is, overexposure, too high in brightness in the picture, and the image is whitened, so that specific features in the image cannot be identified, and the identification of the code image fails. The specific calculation method of the exposure mainly comprises the following steps:
firstly, the color picture is converted into a Gray picture, that is, the color RGB values are converted into Gray values, and the specific formula of the conversion is (R30 + G59 + B11 +50)/100, wherein Gray represents the Gray value of the pixel, and R, G, B represents the RGB values of the color picture, respectively.
Then, all the pixel values in the gray picture are added and divided by the total number of pixels, so as to obtain the average value of gray, i.e. the exposure. If the mean value of the gray values is larger than a certain value k, the gray values are considered to be overexposed, otherwise, the gray values are not overexposed. The specific k value index is not necessarily the same for different camera modules, but the maximum value is not larger than 255.
Optionally, in this embodiment, determining the exposure level of the code pattern may include: dividing the code graph into at least two parts according to a preset rule; respectively detecting the exposure of each part of the code pattern; and when the overexposed part in the code pattern meets a preset condition, judging that the exposure degree of the code pattern is overexposed. The image of the code pattern is split to a certain degree, the speed of calculating the exposure of the code pattern can be obviously improved, different parts are relatively independent and are mutually associated, the exposure of each part is obtained by splitting the image of the code pattern, and the total exposure of the code pattern is estimated according to the exposure of each part. The code pattern may be considered to be overexposed when the conditions are satisfied.
Specifically, in this embodiment, dividing the code pattern into at least two parts according to a preset dividing rule may include: dividing the code pattern into nine parts in a nine-square grid mode; correspondingly, when the overexposed part in the code pattern meets the preset condition, the method may include: overexposure of the middle part of the code graph; and/or the number of the overexposed parts in the code pattern is more than or equal to a preset value. In this embodiment, the code pattern is preferably divided into nine parts in a manner of a nine-square grid, please refer to fig. 6, and fig. 6 shows a schematic diagram of dividing the code pattern in a manner of a nine-square grid. It is worth mentioning that the areas of each part are not necessarily the same after the nine-square grid division, and the adjustment can be performed according to the characteristics of code pattern recognition, for example, the middle part is set to be larger, and the periphery is relatively smaller; correspondingly, in this dividing manner, the predetermined condition that needs to be satisfied for determining the code pattern overexposure may be that the middle portion is overexposed, and/or that the number of overexposed portions is greater than or equal to a predetermined value. When the middle part is overexposed and the middle part is the main body of the whole code image, if the middle part is overexposed, the possibility of overexposure of each part of the whole code image is high, and at the moment, the overexposure of the whole code image is directly judged; if the number of the overexposed parts is larger than or equal to the preset value, that is, the sum of the overexposed numbers of other parts is larger than or equal to the preset value, it indicates that these parts may be connected, and similarly, it indicates that there is a possibility of having a large overexposed area, and at this time, it can also directly determine the overexposure of the whole code map. In view of this, when calculating the exposure of the code pattern, only the exposure of the middle portion may be calculated first, and when the calculation result of the middle portion is overexposure, the overexposure of the code pattern is directly determined without performing the calculation of other portions; when the calculation result of the middle part is not over-exposed, the exposure of other parts is calculated, and whether the code pattern is over-exposed or not is further confirmed. By adopting the exposure calculation mode, the time for determining the exposure of the code pattern can be obviously saved.
Optionally, in this embodiment, after the code pattern to be identified is obtained again through other identification areas where the preset identification areas are not overlapped, if the exposure level of the code pattern is still overexposed, then: and sending a prompt message, wherein the prompt message is used for reminding a user to adjust the light entering amount of the image of the code image acquired by the terminal. In this embodiment, the identification area for acquiring the image of the code pattern to be identified includes at least one other identification area besides the preset identification area, and the other identification area is not overlapped with the preset identification area and is distributed on the display panel of the terminal together with the preset identification area. The other identification areas are different from the preset identification area in the largest way that the directions of the acquired images are different, and the directions of natural light and the light inlet quantity are also different; particularly, when the image of the code image is acquired, if the flash lamp of the terminal is used for supplementing light, the position between the flash lamp and the camera module is fixed, so that the light entering amount caused by the flash lamp is also fixed, and the flash lamp is close to the camera module, so that the light entering amount of a preset identification area in the middle of a display screen of the terminal is directly larger than that of other areas, although the brightness is higher, the possibility of overexposure is higher; when the image of the code image acquired by the preset identification area is determined to be overexposed, the image can be switched to other identification areas to be acquired; the terminal does not need to be adjusted particularly in the switching process, and the space angle of the terminal only needs to be adjusted in a small range, so that the image of the code pattern is displayed in other identification areas.
In this embodiment, when there is one preset identification region and there are two other identification regions, the preset identification region may be respectively disposed at the upper portion and the lower portion of the preset identification region, and the preset identification region is respectively a first identification region and a second identification region; in the actual process of identifying the code pattern, switching among the three areas according to the identification result in a certain sequence, firstly identifying the code pattern through a preset identification area, directly identifying without overexposure to generate an identification result, switching to an upper identification area I if overexposure is performed, and acquiring an image of the code pattern through the upper identification area I; and then, if the overexposure still exists, switching to a second lower identification area, and acquiring and identifying the image of the code image through the second lower identification area. If all the identification areas are identified as being over-exposed, then a prompt message can be sent at this time, the prompt message is used for prompting a user to adjust the light entering amount of the image of the code image acquired by the terminal, and the user can be prompted in a pop-up window prompting mode, a sound prompting mode, a vibration prompting mode and the like or a combination of the modes, so that the user can adjust the brightness of a flash lamp or adjust the position of the terminal and the like to realize the change of the light entering amount of the terminal, thereby causing the change of the exposure degree of the image of the code image. After the adjustment, the code pattern is obtained and identified again according to the sequence of the preset identification area, the first identification area and the second identification area.
This embodiment provides a code map recognition method, the image of the code map of waiting to discern is acquireed through the predetermined identification area of the module of making a video recording, confirm the exposure level of code map, when the exposure level of code map is overexposure, reacquire the code map of waiting to discern through other identification areas that do not overlap with predetermined identification area, thereby carry out the discernment of code map through a plurality of identification areas, the identification area of the module practical ability of making a video recording of terminal application has been successfully utilized rather than only utilizing predetermined identification area, thereby the speed and the rate of accuracy of code map discernment have been promoted.
Second embodiment
Fig. 7 is a detailed flowchart of a code pattern recognition method according to a second embodiment of the present invention, where the code pattern recognition method includes:
s701, identifying a code image of the current identification area;
the current identification area may be a preset identification area, or other identification areas including any one of the first identification area and the second identification area.
S702, whether the identification is successful? If not, turning to S703, if yes, ending the process;
s703, determining the exposure of the code pattern;
after the identification fails, determining the exposure degree of the code image to be identified, and mainly judging whether the code image belongs to overexposure or not;
s704, determine whether overexposure? If yes, go to S705, otherwise, go to S701;
if the determination is made to belong to overexposure, the image of the code pattern is incomplete due to the overexposure, and then the identification area is prepared to be switched.
S705, judging whether the current identification area is an identification area II; if yes, go to S709, if no, go to S706;
the purpose of judging whether the identification area is the second identification area is that the switching sequence of the identification areas is from the preset identification area to the first identification area and the last identification area to the second identification area, if the identification area is the second identification area, the two previous identification areas are identified as the current identification areas and both the previous identification areas fail, and the identification areas are not suitable to be switched simply; if the current identification area is not the second identification area, the switching of the identification area still has operation space, and if the current identification area is the preset identification area, the switching is performed to the first identification area; and if the current identification area is the first identification area, switching to the second identification area.
S706, prompting a user to switch the current identification area;
and prompting a user to switch the current identification area, so that the terminal moves in a smaller range, and the image of the code image is displayed in the switched identification area.
S707, judging whether the user confirms switching; if yes, go to S708, otherwise, go to S701;
s708, switching is performed according to the sequence of the preset identification area, the identification area I and the identification area II.
And S709, prompting a user to adjust the light inlet quantity of the camera module and switching the current identification area to a preset identification area.
In S703, determining the exposure level of the code pattern, please refer to fig. 8, which specifically includes the following steps:
s801, determining the exposure of the middle part under the nine-square grid division;
the nine-grid division is to divide the image of the code image into nine parts in the form of nine grids, wherein the sizes of the parts are not necessarily the same.
S802, judging whether the middle part is over-exposed; if yes, go to S803, if no, go to S805;
when the middle part is overexposed and the middle part is the main body of the whole code image, if the middle part is overexposed, the probability that each part of the whole code image is overexposed is high, and at this time, the overexposure of the whole code image can be directly judged.
S803, determining the exposure of other parts;
s804, judging whether the number of the overexposed parts in other parts exceeds a preset value or not; if yes, go to S805, otherwise, go to S806;
if the number of the overexposed parts is larger than or equal to the preset value, that is, the sum of the overexposed numbers of other parts is larger than or equal to the preset value, it indicates that the parts may be connected, and similarly, it indicates that there is a large overexposed area, and at this time, it can also directly determine the overexposure of the whole code pattern.
S805, judging the image overexposure of the current code image;
s806, judging that the image of the current code image is not over-exposed.
This embodiment provides a code map recognition method, the image of the code map of waiting to discern is acquireed through the predetermined identification area of the module of making a video recording, confirm the exposure level of code map, when the exposure level of code map is overexposure, reacquire the code map of waiting to discern through other identification areas that do not overlap with predetermined identification area, thereby carry out the discernment of code map through a plurality of identification areas, the identification area of the module practical ability of making a video recording of terminal application has been successfully utilized rather than only utilizing predetermined identification area, thereby the speed and the rate of accuracy of code map discernment have been promoted.
Third embodiment
The present embodiment provides a terminal, as shown in fig. 9, which includes a processor 91, a memory 92, a camera module 93, and a communication bus 94;
the communication bus 94 is used for realizing connection communication between the processor 91 and the memory 92;
the processor 91 is configured to execute the code pattern recognition program stored in the memory 92 to implement the following steps:
acquiring an image of a code pattern to be identified through a preset identification area of the camera module 93;
determining the exposure of the code pattern;
and when the exposure of the code pattern is overexposure, acquiring the code pattern to be identified again through other identification areas which are not overlapped with the preset identification area, wherein the other identification areas comprise at least one.
The bar code and the two-dimensional code are used as code diagrams and can be identified by the terminal camera module. In the identification process, firstly, the code image is collected and opened through system software or third-party software on the terminal, and then the image of the code image is acquired through a camera on the terminal. Referring to fig. 4, fig. 4 is a schematic diagram illustrating a preset identification area on a display panel of a terminal, which is generally located in the middle of a display screen of the terminal, but images can still be captured at other positions on the display screen of the terminal. In view of this, in the embodiment, other identification areas that do not overlap with the preset identification area are disposed at other positions of the display screen, please refer to fig. 5, where fig. 5 shows that when two other identification areas are included, the specific positions of the other identification areas are respectively located at the upper portion and the lower portion of the preset identification area.
In the present embodiment, the exposure level, i.e., the exposure amount, is generally determined by the aperture value of the camera module, the exposure time, and the sensitivity of the photosensitive element, and of course, the influence of the ambient brightness. How to directly cause the specific exposure condition of the code image by the ambient brightness, when the ambient brightness is too bright, the obtained code image is inevitably too high in exposure, that is, overexposure, too high in brightness in the picture, and the image is whitened, so that specific features in the image cannot be identified, and the identification of the code image fails. The specific calculation method of the exposure mainly comprises the following steps:
firstly, the color picture is converted into a Gray picture, that is, the color RGB values are converted into Gray values, and the specific formula of the conversion is (R30 + G59 + B11 +50)/100, wherein Gray represents the Gray value of the pixel, and R, G, B represents the RGB values of the color picture, respectively.
Then, all the pixel values in the gray picture are added and divided by the total number of pixels, so as to obtain the average value of gray, i.e. the exposure. If the mean value of the gray values is larger than a certain value k, the gray values are considered to be overexposed, otherwise, the gray values are not overexposed. The specific k value index is not necessarily the same for different camera modules, but the maximum value is not larger than 255.
Optionally, in this embodiment, determining the exposure level of the code pattern may include: dividing the code graph into at least two parts according to a preset rule; respectively detecting the exposure of each part of the code pattern; and when the overexposed part in the code pattern meets a preset condition, judging that the exposure degree of the code pattern is overexposed. The image of the code pattern is split to a certain degree, the speed of calculating the exposure of the code pattern can be obviously improved, different parts are relatively independent and are mutually associated, the exposure of each part is obtained by splitting the image of the code pattern, and the total exposure of the code pattern is estimated according to the exposure of each part. The code pattern may be considered to be overexposed when the conditions are satisfied.
Specifically, in this embodiment, dividing the code pattern into at least two parts according to a preset dividing rule may include: dividing the code pattern into nine parts in a nine-square grid mode; correspondingly, when the overexposed part in the code pattern meets the preset condition, the method may include: overexposure of the middle part of the code graph; and/or the number of the overexposed parts in the code pattern is more than or equal to a preset value. In this embodiment, the code pattern is preferably divided into nine parts in a manner of a nine-square grid, please refer to fig. 6, and fig. 6 shows a schematic diagram of dividing the code pattern in a manner of a nine-square grid. It is worth mentioning that the areas of each part are not necessarily the same after the nine-square grid division, and the adjustment can be performed according to the characteristics of code pattern recognition, for example, the middle part is set to be larger, and the periphery is relatively smaller; correspondingly, in this dividing manner, the predetermined condition that needs to be satisfied for determining the code pattern overexposure may be that the middle portion is overexposed, and/or that the number of overexposed portions is greater than or equal to a predetermined value. When the middle part is overexposed and the middle part is the main body of the whole code image, if the middle part is overexposed, the possibility of overexposure of each part of the whole code image is high, and at the moment, the overexposure of the whole code image is directly judged; if the number of the overexposed parts is larger than or equal to the preset value, that is, the sum of the overexposed numbers of other parts is larger than or equal to the preset value, it indicates that these parts may be connected, and similarly, it indicates that there is a possibility of having a large overexposed area, and at this time, it can also directly determine the overexposure of the whole code map. In view of this, when calculating the exposure of the code pattern, only the exposure of the middle portion may be calculated first, and when the calculation result of the middle portion is overexposure, the overexposure of the code pattern is directly determined without performing the calculation of other portions; when the calculation result of the middle part is not over-exposed, the exposure of other parts is calculated, and whether the code pattern is over-exposed or not is further confirmed. By adopting the exposure calculation mode, the time for determining the exposure of the code pattern can be obviously saved.
Optionally, in this embodiment, after the code pattern to be identified is obtained again through other identification areas where the preset identification areas are not overlapped, if the exposure level of the code pattern is still overexposed, then: and sending a prompt message, wherein the prompt message is used for reminding a user to adjust the light entering amount of the image of the code image acquired by the terminal. In this embodiment, the identification area for acquiring the image of the code pattern to be identified includes at least one other identification area besides the preset identification area, and the other identification area is not overlapped with the preset identification area and is distributed on the display panel of the terminal together with the preset identification area. The other identification areas are different from the preset identification area in the largest way that the directions of the acquired images are different, and the directions of natural light and the light inlet quantity are also different; particularly, when the image of the code image is acquired, if the flash lamp of the terminal is used for supplementing light, the position between the flash lamp and the camera module is fixed, so that the light entering amount caused by the flash lamp is also fixed, and the flash lamp is close to the camera module, so that the light entering amount of a preset identification area in the middle of a display screen of the terminal is directly larger than that of other areas, although the brightness is higher, the possibility of overexposure is higher; when the image of the code image acquired by the preset identification area is determined to be overexposed, the image can be switched to other identification areas to be acquired; the terminal does not need to be adjusted particularly in the switching process, and the space angle of the terminal only needs to be adjusted in a small range, so that the image of the code pattern is displayed in other identification areas.
In this embodiment, when there is one preset identification region and there are two other identification regions, the preset identification region may be respectively disposed at the upper portion and the lower portion of the preset identification region, and the preset identification region is respectively a first identification region and a second identification region; in the actual process of identifying the code pattern, switching among the three areas according to the identification result in a certain sequence, firstly identifying the code pattern through a preset identification area, directly identifying without overexposure to generate an identification result, switching to an upper identification area I if overexposure is performed, and acquiring an image of the code pattern through the upper identification area I; and then, if the overexposure still exists, switching to a second lower identification area, and acquiring and identifying the image of the code image through the second lower identification area. If all the identification areas are identified as being over-exposed, then a prompt message can be sent at this time, the prompt message is used for prompting a user to adjust the light entering amount of the image of the code image acquired by the terminal, and the user can be prompted in a pop-up window prompting mode, a sound prompting mode, a vibration prompting mode and the like or a combination of the modes, so that the user can adjust the brightness of a flash lamp or adjust the position of the terminal and the like to realize the change of the light entering amount of the terminal, thereby causing the change of the exposure degree of the image of the code image. After the adjustment, the code pattern is obtained and identified again according to the sequence of the preset identification area, the first identification area and the second identification area.
This embodiment provides a terminal, which comprises a processor, a memory, the module and communication bus make a video recording, the image of the code pattern of waiting to discern is acquireed through the predetermined identification area of the module of making a video recording, confirm the exposure level of code pattern, when the exposure level of code pattern is overexposure, reacquire the code pattern of waiting to discern through other identification areas that do not overlap with predetermined identification area, thereby carry out the discernment of code pattern through a plurality of identification areas, the identification area of the module actual ability of making a video recording application of terminal has been successfully utilized rather than only utilizing predetermined identification area, thereby the speed and the rate of accuracy of code pattern discernment have been promoted.
Fourth embodiment
The present embodiment provides a computer-readable storage medium, where one or more programs are stored, and the one or more programs may be executed by one or more processors to implement the steps of the code pattern identification method according to the first embodiment and/or the second embodiment, which are not described herein again.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
While the present invention has been described with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, which are illustrative and not restrictive, and it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the appended claims.

Claims (10)

1. A code pattern recognition method is characterized in that the code pattern recognition method comprises the following steps:
acquiring an image of a code pattern to be identified through a preset identification area of the camera module;
determining the exposure level of the code pattern;
and when the exposure of the code pattern is overexposure, acquiring the code pattern to be identified again through other identification areas which are not overlapped with the preset identification area, wherein the other identification areas comprise at least one.
2. The code pattern recognition method of claim 1, wherein the determining the exposure level of the code pattern comprises:
dividing the code graph into at least two parts according to a preset rule;
respectively detecting the exposure of each part of the code pattern;
and when the overexposed part in the code image meets a preset condition, judging that the exposure degree of the code image is overexposed.
3. The code pattern recognition method of claim 2, wherein the dividing the code pattern into at least two parts according to a preset rule comprises: dividing the code image into nine parts in a nine-square grid mode;
when the overexposed part in the code pattern meets a preset condition, the method comprises the following steps: in the code pattern, the part positioned in the middle is overexposed; and/or the number of the overexposed parts in the code map is more than or equal to a preset value.
4. The code pattern recognition method according to any one of claims 1 to 3, wherein after the code pattern to be recognized is obtained again through other recognition regions where the preset recognition regions do not overlap, if the exposure level of the code pattern is still overexposed, then: and sending a prompt message, wherein the prompt message is used for reminding a user to adjust the light entering amount of the image of the code pattern acquired by the terminal.
5. The code pattern recognition method according to any one of claims 1 to 3, wherein the other recognition areas include two, which are respectively located at an upper portion and a lower portion of the preset recognition area.
6. A terminal is characterized by comprising a processor, a memory, a camera module and a communication bus;
the communication bus is used for realizing connection communication between the processor and the memory;
the processor is used for executing the code pattern identification program stored in the memory to realize the following steps:
acquiring an image of a code pattern to be identified through a preset identification area of the camera module;
determining the exposure level of the code pattern;
and when the exposure of the code pattern is overexposure, acquiring the code pattern to be identified again through other identification areas which are not overlapped with the preset identification area, wherein the other identification areas comprise at least one.
7. The terminal of claim 6, wherein the determining the exposure of the code pattern comprises:
dividing the code graph into at least two parts according to a preset rule;
respectively detecting the exposure of each part of the code pattern;
and when the overexposed part in the code image meets a preset condition, judging that the exposure degree of the code image is overexposed.
8. The terminal of claim 7, wherein the dividing the code pattern into at least two parts according to a preset rule comprises: dividing the code image into nine parts in a nine-square grid mode;
when the overexposed part in the code pattern meets a preset condition, the method comprises the following steps: in the code pattern, the part positioned in the middle is overexposed; and/or the number of the overexposed parts in the code map is more than or equal to a preset value.
9. The terminal according to any of claims 6-8, wherein after the code pattern to be identified is obtained again through other identification regions where the predetermined identification regions do not overlap, if the exposure level of the code pattern is still overexposed, then: and sending a prompt message, wherein the prompt message is used for reminding a user to adjust the light entering amount of the image of the code pattern acquired by the terminal.
10. A computer-readable storage medium, storing one or more programs, the one or more programs being executable by one or more processors to implement the steps of the code pattern recognition method according to any one of claims 1 to 5.
CN201710638928.6A 2017-07-31 2017-07-31 Code pattern recognition method, terminal and computer readable storage medium Active CN107609446B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710638928.6A CN107609446B (en) 2017-07-31 2017-07-31 Code pattern recognition method, terminal and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710638928.6A CN107609446B (en) 2017-07-31 2017-07-31 Code pattern recognition method, terminal and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN107609446A CN107609446A (en) 2018-01-19
CN107609446B true CN107609446B (en) 2020-07-31

Family

ID=61064272

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710638928.6A Active CN107609446B (en) 2017-07-31 2017-07-31 Code pattern recognition method, terminal and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN107609446B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108537085A (en) * 2018-03-07 2018-09-14 阿里巴巴集团控股有限公司 A kind of barcode scanning image-recognizing method, device and equipment
CN113065374B (en) * 2021-04-01 2023-10-27 支付宝(杭州)信息技术有限公司 Two-dimensional code identification method, device and equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102473236A (en) * 2009-07-29 2012-05-23 讯宝科技公司 Method of setting amount of exposure for photodetector array in barcode scanner
CN103218596A (en) * 2013-04-17 2013-07-24 苏州斯普锐智能系统有限公司 Bar-code scanner with dynamic multi-angle illuminating system and bar-code scanning method thereof
CN104781833A (en) * 2012-11-13 2015-07-15 共同印刷株式会社 Two-dimensional code
CN106295443A (en) * 2016-08-03 2017-01-04 浙江华睿科技有限公司 The localization method in a kind of bar code region and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102173123B1 (en) * 2013-11-22 2020-11-02 삼성전자주식회사 Method and apparatus for recognizing object of image in electronic device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102473236A (en) * 2009-07-29 2012-05-23 讯宝科技公司 Method of setting amount of exposure for photodetector array in barcode scanner
CN104781833A (en) * 2012-11-13 2015-07-15 共同印刷株式会社 Two-dimensional code
CN103218596A (en) * 2013-04-17 2013-07-24 苏州斯普锐智能系统有限公司 Bar-code scanner with dynamic multi-angle illuminating system and bar-code scanning method thereof
CN106295443A (en) * 2016-08-03 2017-01-04 浙江华睿科技有限公司 The localization method in a kind of bar code region and device

Also Published As

Publication number Publication date
CN107609446A (en) 2018-01-19

Similar Documents

Publication Publication Date Title
CN109151180B (en) Object identification method and mobile terminal
CN109213732B (en) Method for improving photo album classification, mobile terminal and computer readable storage medium
EP4047922A1 (en) Object tracking method and electronic device
CN108270919B (en) Terminal brightness adjusting method, terminal and computer readable storage medium
CN108491123B (en) Method for adjusting application program icon and mobile terminal
CN107977652B (en) Method for extracting screen display content and mobile terminal
CN107818282B (en) Two-dimensional code identification method, terminal and computer readable storage medium
CN110300267B (en) Photographing method and terminal equipment
CN107730460B (en) Image processing method and mobile terminal
CN110674662A (en) Scanning method and terminal equipment
CN108073458B (en) Memory recovery method, mobile terminal and computer-readable storage medium
CN107153500B (en) Method and equipment for realizing image display
CN110519503B (en) Method for acquiring scanned image and mobile terminal
CN109523253B (en) Payment method and device
CN108174110B (en) Photographing method and flexible screen terminal
CN110837328B (en) Display method and electronic equipment
CN109462732B (en) Image processing method, device and computer readable storage medium
CN107609446B (en) Code pattern recognition method, terminal and computer readable storage medium
CN107729100B (en) Interface display control method and mobile terminal
CN110490583B (en) Payment method and terminal equipment
CN108304744B (en) Scanning frame position determining method and mobile terminal
CN109379531B (en) Shooting method and mobile terminal
CN114064179A (en) Display mode adaptation method, terminal and storage medium
CN110045897B (en) Information display method and terminal equipment
CN110012225B (en) Image processing method and device and mobile terminal

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
GR01 Patent grant