QR code recognition method and related device
By using a circular QR code design and encryption algorithm, the problems of insufficient aesthetics and security of traditional QR codes are solved, achieving more efficient data storage and secure identification.
Patent Information
- Application Number
- CN202110169337.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-07
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2041-02-07
AI Technical Summary
Traditional square QR codes are aesthetically unappealing, lack universality in decoding and security, and custom QR codes are easily tampered with, affecting user experience.
The design adopts a circular QR code, which includes an encoding area, a first interval area, and a second interval area. The encoding area is divided into a first encoding area and a second encoding area. The distribution of concentric circles and interval areas improves the aesthetics, and the encryption algorithm enhances the security.
It improves both aesthetics and security, while enhancing QR code decoding capabilities and data storage capacity, thereby increasing QR code recognition efficiency and security.
Smart Images

Figure CN114912475B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic technology, and in particular to a two-dimensional code recognition method and related devices. Background Art
[0002] In recent years, as QR code technology has become increasingly mature, more and more manufacturers have begun to invest in the research and commercialization of customized non-standard QR codes, such as WeChat mini-program codes.
[0003] However, the traditional square QR code is not beautiful and has no guidance information. For QR codes that require special guidance, the method of adding surrounding logos to the middle QR code often takes up a large space; or a small trademark is placed in the center of the QR code, covering part of the data area, affecting the recognition of the QR code. In addition, due to the universality of decoding, the square QR code is read out through a standard decoding program, and the confidentiality is relatively poor. The content of the square QR code scanned can be a URL containing unsafe content, such as a link containing a Trojan virus, which has poor security and a general user experience. Summary of the invention
[0004] The embodiments of the present application provide a two-dimensional code recognition method and related devices, which increase the diversity of two-dimensional codes and can realize the recognition of the two-dimensional code.
[0005] In a first aspect, an embodiment of the present application provides a two-dimensional code recognition method, wherein the two-dimensional code includes an image area located in the middle and a circular ring area surrounding the image area, the circular ring area includes a coding area, a first spacing area and a second spacing area, the coding area includes a plurality of code elements, the coding area includes a first coding area and a second coding area, and a first spacing area and a second spacing area are provided between the first coding area and the second coding area; the method includes:
[0006] The electronic device obtains the two-dimensional code to be identified, and determines the values corresponding to the multiple code elements in the coding area of the two-dimensional code to be identified;
[0007] The electronic device identifies the first information corresponding to the two-dimensional code to be identified according to the values corresponding to the multiple code elements in the coding area.
[0008] In an embodiment of the present application, the electronic device obtains a QR code to be identified and identifies the first information corresponding to the QR code to be identified. The coding area, the first spacing area, and the second spacing area in the QR code to be identified just form a circle, and the coding area is divided into a first coding area and a second coding area by the first spacing area and the second spacing area. That is, the embodiment of the present application provides a QR code style that uses a spacing area to disconnect the coding area.
[0009] In combination with the first aspect, in a possible implementation, the first spacing area and the second spacing area are partial circular rings with the same width. The partial circular ring here refers to a part of a complete circular ring.
[0010] In conjunction with the first aspect, in a possible implementation, the first coding region and the second coding region occupy the same area. The first coding region and the second coding region are regions of the same size, and the symmetrical distribution improves the aesthetics.
[0011] In combination with the first aspect, in a possible implementation, the ratio of the width of the image area in the horizontal direction to the width of the QR code in the horizontal direction is 1: 3. The embodiment of the present application does not limit the ratio of the image area.
[0012] In combination with the first aspect, in a possible implementation, multiple code elements in the coding area are distributed on at least two concentric circles, the center of the at least two concentric circles is the center of the two-dimensional code, and the code elements include dot-shaped code elements.
[0013] In combination with the first aspect, in a possible implementation, the arc distance between the centers of adjacent dot-shaped code elements on the same concentric circle of the coding area is (2r+b)*k, k is a positive integer, r is the radius of the dot-shaped code element, and b is a fixed value; the circumference of the same concentric circle is N*(2r+b), and N is a positive integer greater than k. Here, the distance between the centers of the dot-shaped code elements is limited, and the minimum distance between adjacent dot-shaped code elements is 2r+b, so the distance between any two dot-shaped code elements is an integer multiple of 2r+b.
[0014] In a possible implementation, in the same concentric circle of the coding area, the arc distance between the centers of three consecutive dot-shaped code elements is greater than (2r+b)*2. That is to say, for example, there will not be a situation where the distances between three consecutive dot-shaped code elements are all the minimum distance 2r+b, and the aesthetics of the two-dimensional code can be maintained.
[0015] In a possible implementation, there are dot-shaped code elements a and b on two different concentric circles of the two-dimensional code, and the line connecting the centers of the dot-shaped code elements a and b passes through the center of the two-dimensional code. A possible style is provided here, namely a radial style.
[0016] In a possible implementation, the radii of the dot-shaped code elements on different concentric circles in the two-dimensional code are different.
[0017] In a possible implementation, the radius of the dot-shaped code elements in the outer concentric circles of the two-dimensional code is greater than the radius of the dot-shaped code elements in the inner concentric circles.
[0018] In a possible implementation, the code element further includes an arc code element, and the arc length of the arc code element on the concentric circle is (2r+b)*M, where M is a positive integer. Here, it is described that multiple dot-shaped code elements can be connected to form an arc-shaped code element. If the arc-shaped code element is connected by M+1 dot-shaped code elements, the length of the arc-shaped code element is (2r+b)*M.
[0019] In a possible implementation, on the same concentric circle, the arc distance between an arc-shaped code element and its adjacent code element is greater than or equal to (2r+b)*2. Since the arc-shaped code element is formed by connecting continuous dot-shaped code elements, the distance between the arc-shaped code element and its adjacent code element (dot-shaped code element or arc-shaped code element) is at least one dot-shaped code element apart.
[0020] In combination with the first aspect, in a possible implementation, an electronic device obtains a two-dimensional code to be identified, determines the values corresponding to multiple code elements in the coding area of the two-dimensional code to be identified, and identifies the first information corresponding to the two-dimensional code to be identified, including: the electronic device obtains the two-dimensional code to be identified; the electronic device determines the target version of the two-dimensional code to be identified, and the target version indicates the coordinate information of each storage position in the coding area of the two-dimensional code to be identified; the electronic device determines that the storage position occupied by each code element in the coding area of the two-dimensional code to be identified corresponds to the first value based on the coordinate information of each storage position; and identifies the first information corresponding to the two-dimensional code to be identified according to the first value. Here, a specific implementation method for the electronic device to identify the two-dimensional code is described. After the electronic device identifies the target version of the two-dimensional code, it obtains the coding information based on the position coordinates contained in the target version, and implements decoding through decoding rules. In this way, the decoding of the two-dimensional code of the target version of the two-dimensional code structure is completed.
[0021] In a possible implementation, each storage location is in the shape of a dot, and the coordinate information includes center coordinate information and radius information of the storage location.
[0022] In a possible implementation, the electronic device determines the target version of the QR code to be identified, which includes: the electronic device determines the position of the locator in the image to be identified; the electronic device determines the vertex position of the QR code in the image to be identified based on the position of the locator; the electronic device corrects the QR code in the image to be identified based on the vertex position to obtain the QR code to be identified. Here, the process of positioning and correcting the QR code by the electronic device is described.
[0023] In combination with the first aspect, in a possible implementation manner, the type of the first information includes one or more of the following: characters, text, pictures, audio, video, and link addresses.
[0024] In a second aspect, an embodiment of the present application provides a method for generating a two-dimensional code, the method comprising:
[0025] The electronic device acquires first information;
[0026] The electronic device generates a QR code based on the first information, where the QR code indicates the first information;
[0027] The two-dimensional code includes an image area located in the middle and a circular ring area surrounding the image area. The circular ring area includes a coding area, a first spacing area and a second spacing area. The coding area includes multiple code elements. The coding area includes a first coding area and a second coding area. The first spacing area and the second spacing area are arranged between the first coding area and the second coding area.
[0028] In an embodiment of the present application, the electronic device obtains the first information and generates a two-dimensional code based on the first information. The coding area, the first spacing area and the second spacing area in the two-dimensional code just form a circle, and the coding area is divided into the first coding area and the second coding area by the first spacing area and the second spacing area. That is, the embodiment of the present application provides a two-dimensional code style that uses the spacing area to disconnect the coding area.
[0029] In combination with the second aspect, in a possible implementation, multiple code elements in the coding area are distributed on at least two concentric circles, the center of the at least two concentric circles is the center of the two-dimensional code, and the multiple code elements include dot-shaped code elements.
[0030] In conjunction with the second aspect, in a possible implementation, the electronic device generates a two-dimensional code based on the first information, including: the electronic device encodes the first information into a binary string; the electronic device determines the target version of the two-dimensional code to be generated according to the length of the binary string, and the target version indicates the coordinate information of each storage position in the coding area; the electronic device assigns the binary string to the storage position in the coding area according to the coordinate information of each storage position; wherein the storage position includes a first storage position and a second storage position, the first storage position stores the first value in the binary string and the second storage position stores the second value in the binary string; the electronic device draws a first code element based on the coordinate information of the first storage position, and generates a two-dimensional code based on the first code element; the first code element is one of the multiple code elements in the coding area of the two-dimensional code. In this method, the electronic device first obtains the corresponding binary string by biting the first information of the two-dimensional code to be generated; and determines the target version of the two-dimensional code to be generated according to the length of the binary string, wherein different versions can store different amounts of data. After the electronic device determines the target version, it assigns the binary string to each storage position in the coding area of the target version, and then draws the code element,
[0031] In combination with the second aspect, in one possible implementation, the coordinate information of the storage location includes the center coordinate information and radius information of the storage location; the first code element is a dot-shaped code element, which is drawn based on the center coordinate information and radius information of the first storage location.
[0032] In conjunction with the second aspect, in a possible implementation, the number of concentric circles of the coding area in different target versions is different, wherein different numbers of concentric circles can store different amounts of data.
[0033] In conjunction with the second aspect, in a possible implementation, the electronic device draws the first code element at the first storage location based on the coordinate information of the first storage location, including: the electronic device determines the value range of the first code element on the Y axis through the center coordinate information and radius information of the first storage location, the minimum value of the value range of the first code element on the Y axis is the center ordinate in the center coordinate information minus the radius, and the maximum value of the value range is the center ordinate in the center coordinate information plus the radius; the electronic device determines a left end X value and a right end X value for each Y value in the value range through a preset formula, and draws the pixel points between the left end X value and the right end X value as a first color, completing the drawing of the first code element, and all the pixel points of the first code element are the first color. Here, the process of drawing a dot-shaped code element is described, in which not only the Y axis can be used as an independent variable to determine the two X axis endpoints, but also the X axis can be used as an independent variable to determine the two Y axis endpoints.
[0034] In conjunction with the second aspect, in a possible implementation, the method further includes: the first code element further includes an arc code element, the arc code element occupies at least two adjacent first storage positions, and the at least two adjacent first storage positions are located on the same concentric circle. When the preset conditions are met, the arc code element can also be drawn, which increases the diversity and aesthetics of the two-dimensional code.
[0035] In combination with the second aspect, in a possible implementation, the first code element occupies at least two storage locations, wherein the storage locations at the left and right ends of the at least two storage locations are the third storage location and the fourth storage location; the center points of the third storage location and the fourth storage location are both on the same side of the midline of the two-dimensional code, and the midline of the two-dimensional code is a straight line passing through the center point of the two-dimensional code and perpendicular to the X-axis; the electronic device draws the first code element based on the coordinate information of the first storage location, including: the electronic device determines the value range of the first code element on the Y-axis through the center coordinate information and radius information of the third storage location and the fourth storage location, and when the third storage location The ordinate of the center of the first storage position is greater than the ordinate of the center of the fourth storage position, the minimum value of the value range of the first code element on the Y axis is the ordinate of the point at the third storage position that is shortest from the center of the two-dimensional code, and the maximum value of the value range of the first code element on the Y axis is the ordinate of the point at the fourth storage position that is longest from the center of the two-dimensional code; the electronic device determines a left X value and a right X value for each Y value within the value range through a preset formula, and draws the pixel points between the left X value and the right X value as the first color, completing the drawing of the first code element, and all the pixel points of the first code element are the first color. Here, a process of drawing an arc-shaped code element is described.
[0036] In conjunction with the second aspect, in a possible implementation, the first code element occupies at least two storage locations, wherein the storage locations at the left and right ends of the at least two storage locations are the third storage location and the fourth storage location; the center points of the third storage location and the fourth storage location are respectively on both sides of the midline of the two-dimensional code, the midline of the two-dimensional code is a straight line passing through the center point of the two-dimensional code and perpendicular to the X-axis, the part of the first code element on the left side of the midline is the first part, and the part of the first code element on the right side of the midline is the second part; the electronic device draws the first code element based on the coordinate information of the first storage location, including: the electronic device draws the first part and the second part of the first code element respectively; the minimum value of the value range of the first part on the Y axis is the ordinate of the point on the third storage location that is shortest from the center of the two-dimensional code, and the maximum value of the value range on the Y axis is the maximum ordinate in the concentric circle where the third storage location is located; the minimum value of the value range of the second part on the Y axis is the ordinate of the point on the fourth storage location that is shortest from the center of the two-dimensional code, and the maximum value of the value range on the Y axis is the maximum ordinate in the concentric circle where the fourth storage location is located. Here, a process of drawing another arc-shaped code element is described.
[0037] In a third aspect, the present application provides an electronic device comprising: one or more processors, one or more memories; the one or more memories are coupled to one or more processors; the one or more memories are used to store computer program code, and the computer program code includes computer instructions; when the computer instructions run on the processor, the electronic device executes the two-dimensional code recognition method in any possible implementation of the first aspect above.
[0038] In a fourth aspect, the present application provides an electronic device, comprising: one or more processors, one or more memories; the one or more memories are coupled to one or more processors; the one or more memories are used to store computer program code, and the computer program code includes computer instructions; when the computer instructions are run on the processor, the electronic device executes the QR code generation method in any possible implementation of the above-mentioned second aspect.
[0039] In a fifth aspect, an embodiment of the present application provides a computer storage medium, including computer instructions, which, when executed on an electronic device, enable a communication device to perform actions in any possible implementation of any of the above aspects.
[0040] In a sixth aspect, an embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to perform actions in any possible implementation of any of the above aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0042] Figure 2 A software architecture diagram of an electronic device provided in an embodiment of the present application;
[0043] Figure 3A A schematic diagram of the structure of a two-dimensional code provided in an embodiment of the present application;
[0044] Figure 3B A schematic diagram of the structure of the image area and the coding area of a two-dimensional code provided in an embodiment of the present application;
[0045] Figure 3C A schematic diagram of the structure of a main locator of a two-dimensional code provided in an embodiment of the present application;
[0046] Figure 4 A schematic diagram of a process for generating a two-dimensional code provided in an embodiment of the present application;
[0047] FIG. 5A to FIG. 5H A schematic diagram of the structures of different versions of the QR code provided in the embodiments of the present application;
[0048] 6A to 6F A schematic diagram of the structure of a QR code generated based on different versions provided in an embodiment of the present application;
[0049] Fig. 7A A schematic diagram of the structure of a dot-shaped code element provided in an embodiment of the present application;
[0050] Figure 7B A schematic diagram of a method for saving a data stream of a drawing symbol provided in an embodiment of the present application;
[0051] Figure 8 A schematic diagram of the structure of an arc-shaped code element provided in an embodiment of the present application;
[0052] 9A to 9H A schematic diagram of the principle of arc-shaped code elements drawn in different situations provided in the embodiments of the present application;
[0053] FIG. 10A to FIG. 10H A schematic diagram of the principle of arc-shaped code elements drawn in different situations provided in the embodiments of the present application;
[0054] Fig.11 A method flow chart of a two-dimensional code recognition method provided in an embodiment of the present application;
[0055] FIG. 12A to FIG. 12B A schematic diagram of the structure of another QR code provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] The technical solution in the embodiment of the present application will be described below in conjunction with the accompanying drawings. In the description of the embodiment of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiment of the present application, "multiple" means two or more than two.
[0057] In the following, the terms "first" and "second" are used for descriptive purposes only and shall not be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" is two or more. The orientation or positional relationship indicated by the terms "middle", "left", "right", "upper", "lower", etc. is based on the orientation or positional relationship shown in the accompanying drawings, and is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore shall not be understood as a limitation on the present application.
[0058] The embodiment of the present application provides a method for generating a two-dimensional code, which is applied to an electronic device 100. The method can generate a circular two-dimensional code, the coding area of which is composed of at least two concentric circle areas, and the code elements include dot-shaped code elements and arc-shaped code elements. The embodiment of the present application can increase the data storage capacity of the two-dimensional code by increasing the number of circles and the number of code elements in the concentric circle area. In addition, the electronic device 100 encrypts the string during the encoding process, and the decoding needs to adopt a decryption algorithm corresponding to the encryption algorithm to obtain a complete string, thereby improving the security of the two-dimensional code.
[0059] In this method, the electronic device 100 first obtains the corresponding binary string by biting the string of the QR code to be generated; the target version of the QR code to be generated is determined according to the length of the binary string, wherein different versions can store different amounts of data. After the electronic device 100 determines the target version, it distributes the binary string to each concentric circle area in the encoding area of the target version to obtain the QR code information; the mask is used to perform mask superposition processing on the QR code information to adjust the layout of the QR code information, and finally the final QR code is drawn. In this way, the encoding of the QR code that conforms to the QR code structure of the target version can be completed, and the code elements in the generated QR code are evenly distributed and more beautiful.
[0060] The following first introduces the electronic device 100 involved in the embodiment of the present application.
[0061] The present application does not specifically limit the type of the electronic device 100 mentioned. The electronic device 100 may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, as well as a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, a vehicle-mounted device, a smart home device and / or a smart city device. The electronic device 100 may also be a network device such as a cloud server, a virtual server, a background server, a component server, a data processing server, etc. The embodiments of the present application do not specifically limit the specific type of the electronic device.
[0062] See also Figure 1 , Figure 1 A schematic structural diagram of an exemplary electronic device 100 provided in an embodiment of the present application is shown.
[0063] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0064] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0065] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0066] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0067] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0068] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0069] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.
[0070] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0071] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0072] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0073] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0074] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.
[0075] The wireless communication module 160 can provide wireless communication solutions including UWB, wireless local area networks (WLAN) (such as wireless fidelity (WiFi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0076] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).
[0077] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0078] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0079] In some embodiments of the present application, the interface content currently output by the system is displayed on the display screen 194. For example, the interface content is an interface provided by an instant messaging application.
[0080] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0081] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.
[0082] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0083] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
[0084] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0085] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0086] The internal memory 121 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM).
[0087] Random access memory may include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM, for example, the fifth generation DDR SDRAM is generally referred to as DDR5 SDRAM), etc.
[0088] Non-volatile memory may include disk storage devices and flash memory.
[0089] Flash memory can be divided into NOR FLASH, NAND FLASH, 3D NAND FLASH, etc. according to the operating principle; single-level cell (SLC), multi-level cell (MLC), triple-level cell (TLC), quad-level cell (QLC), etc. according to the storage unit potential level; universal flash storage (UFS), embedded multi media card (eMMC), etc. according to the storage specification.
[0090] The random access memory can be directly read and written by the processor 110, and can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data.
[0091] The non-volatile memory may also store executable programs and user and application data, etc., and may be loaded into the random access memory in advance for direct reading and writing by the processor 110 .
[0092] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0093] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0094] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.
[0095] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.
[0096] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.
[0097] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.
[0098] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130 or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0099] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. The gyroscope sensor 180B can be used to determine the motion posture of the electronic device 100. The air pressure sensor 180C is used to measure the air pressure. The magnetic sensor 180D includes a Hall sensor. The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device, and is applied to applications such as horizontal and vertical screen switching, pedometers, etc. The distance sensor 180F is used to measure the distance. The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The ambient light sensor 180L is used to sense the brightness of the ambient light. The fingerprint sensor 180H is used to collect fingerprints. The temperature sensor 180J is used to detect the temperature. The touch sensor 180K is also called a "touch panel". The touch sensor 180K may be disposed on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a “touch screen.” The bone conduction sensor 180M may acquire a vibration signal.
[0100] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100.
[0101] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
[0102] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.
[0103] The SIM card interface 195 is used to connect a SIM card.
[0104] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present invention, the Android system of the layered architecture is taken as an example to exemplify the software structure of the electronic device 100.
[0105] Figure 2 1 is a software structure block diagram of the electronic device 100 according to an embodiment of the present invention.
[0106] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.
[0107] The application layer can include a series of application packages.
[0108] like Figure 2 As shown, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
[0109] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0110] like Figure 2 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
[0111] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0112] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0113] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0114] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.).
[0115] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0116] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0117] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0118] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0119] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0120] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0121] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0122] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0123] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0124] A 2D graphics engine is a drawing engine for 2D drawings.
[0125] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0126] Figure 3A FIG. 2 shows a schematic diagram of the structure of a two-dimensional code 30 provided in an embodiment of the present application. Figure 3A As shown, the two-dimensional code 30 is circular in shape as a whole, and includes an image area 301 located in the middle and a coding area 302 surrounding the image area 301. Figure 3B As shown, the ratio of the width of the image area in the horizontal direction to the width of the two-dimensional code in the horizontal direction can be 1:3. The embodiment of the present application does not limit the position ratio of the image area and the coding area.
[0127] Image area 301 is used to place user-defined images. For example, it can be an official logo image of the application platform using the QR code technology, or an image defined by a user registered on the application platform using the QR code technology, etc. In this way, by placing an image of the application platform user in the middle part of the QR code 30, which is the most important visually sensitive area of the QR code, the recognition of the QR code user can be improved.
[0128] In the embodiment of the present application, the image area in the middle of the two-dimensional code 30 can be a circular area, a rectangular area or other shapes, and the shape of the image area is not specifically limited in this embodiment. In some embodiments, the electronic device 100 will perform circular processing on the input image in the image area 301, that is, when a third-party image is input, the area outside the circle (marginalized part) will be transparent.
[0129] The coding area 302 is formed by the code elements 303 of the two-dimensional code 30, and the code elements 303 are distributed on at least two concentric circles. The code elements 303 are used to record or store codewords. Codewords are bit sequences obtained by encoding the original data. Codewords may include data codes and error correction codes. Common coding methods of two-dimensional codes include digital coding, character coding, etc.
[0130] The concentric circle area of the coding area 302 includes a plurality of positions for storing codewords, wherein the positions occupied by the code element 303 store a first value (e.g., binary 1 or 0), and the positions not occupied by the code element 303 in the concentric circle area store a second value (e.g., binary 0 or 1). The electronic device 100 can obtain a binary string by identifying the coding area 302, and then decode the binary string through a decoding algorithm to obtain corresponding information.
[0131] In the embodiment of the present application, the code element 303 includes arc-shaped code elements and dot-shaped code elements. In some embodiments, the radius of each dot-shaped code element is the same. In some embodiments, each arc-shaped code element includes two or three or more dot-shaped code elements, that is, the arc-shaped code element is composed of two or three or more dot-shaped code elements. The information capacity that the arc-shaped code element can store is an integer multiple of the dot-shaped code element.
[0132] In some embodiments, the radius of each dot-shaped code element in the encoding area of the two-dimensional code may be different, for example Fig. 12A As shown. Fig. 12A In the figure, the radius of the dot-shaped code elements in the same concentric circle area is the same, and the radius of the dot-shaped code elements in different concentric circle areas is different.
[0133] In some embodiments, the coding area of the two-dimensional code may only include dot-shaped code elements, such as Fig. 12B shown.
[0134] In some embodiments, the encoding area of the two-dimensional code may only include arc-shaped code elements.
[0135] In the embodiment of the present application, the number of concentric circle areas included in the coding area 302 can be adjusted according to the size of the QR code data. By expanding the number of concentric circle areas in the coding area 302 and the number of code elements in the concentric circle areas, the information capacity of the QR code can be expanded. Figure 1 In the description, the example in which the coding area 302 of the two-dimensional code includes four concentric circle areas is used for exemplary description. The number of concentric circle areas in the coding area is not specifically limited in this embodiment.
[0136] In some embodiments, each concentric circle area in the coding area 302 can be divided into an upper half area and a lower half area, and a certain distance is separated between the upper half area and the lower half area. In the embodiment of the present application, the upper half area and the lower half area may also be referred to as the first coding area and the second coding area. The interval area between the upper half area and the lower half area is divided into a left interval area and a right interval area, wherein the left interval area and the right interval area may also be referred to as the first interval area and the second interval area.
[0137] For example, FIG. 5A to FIG. 5F Different versions of the QR code provided in the embodiments of the present application are shown as examples. Figure 5A The coding area includes 4 concentric circle areas, each concentric circle area in the coding area is divided into an upper half area and a lower half area, and the upper half area and the lower half area are separated by a diameter distance of 5 dot-shaped code elements. Fig. 5F The coding area includes 13 concentric circle areas, each of which is divided into an upper half area and a lower half area, and the upper half area and the lower half area are separated by a diameter distance of 7 dot-shaped code elements.
[0138] In some embodiments, each concentric circle area in the coding area 302 may not be divided into any parts, that is, in different versions of the two-dimensional code, the dot-shaped code elements in each concentric circle area are evenly distributed at the same interval.
[0139] In addition, the image area 301 and the coding area 302 of the two-dimensional code 30 do not overlap each other, so that the image inserted in the image area 301 will not block the code element 303 in the two-dimensional code coding area 301. There is a first interval between the image area 301 and the coding area 302, and there is a second interval between every two adjacent concentric circle areas in the coding area 302.
[0140] Further, such as Figure 1 As shown, the area other than the image area 301 of the two-dimensional code 30 also includes a locator, which is used to identify the encoding area 302 of the two-dimensional code and filter and select the image to be identified. Figure 3A As shown, the structure of the two-dimensional code 30 includes three main locators 304 and one auxiliary locator 305, and the three main locators 304 and the one auxiliary locator 305 are all circular areas.
[0141] The outer contour of the main locator 304 of the two-dimensional code 30 can be a circle, and each main locator 304 includes a black circular area at the center, a black annular area at the outside, and a white annular area between the black circular area and the black annular area. In this way, even in the case of rotation, distortion, etc., the width of the concentric circles can be kept relatively stable, so that the locator has a relatively stable geometric feature, improves the accuracy of the positioning and recognition of the locator, and ensures that the two-dimensional code can locate the information even when it is tilted.
[0142] In addition, the main locator 304 of the two-dimensional code can adopt a ratio of approximately 1:1:2:1:1, that is, the radius of the black circular area in the main locator 304 and the width of the white circular area and the width of the black circular area maintain a ratio of approximately 1:1:1. Figure 3C As shown, the radius of the black circular area in the main locator is 1, the width of the white circular area is 1, and the width of the black circular area is 1.
[0143] The geometric shape preset in the auxiliary locator 305 can be a relatively unique geometric shape to be distinguished from the geometric shapes in other areas of the two-dimensional code such as the main locator 304. The shape of the auxiliary locator 305 can also be the same as that of the main locator 304, that is, the auxiliary locator 305 can also adopt a ratio of approximately 1:1:2:1:1, but the size of the auxiliary locator 305 and the main locator 304 are different.
[0144] In some embodiments, the auxiliary locator 305 can be a circular area, so that the auxiliary locator 305 has a relatively stable structure. In this way, the overall structure of the two-dimensional code 30 is circular, and the sub-elements therein are also circular. The circle has the characteristic of central symmetry, and it is still symmetrical no matter how it is rotated. The two-dimensional code 30 has a relatively stable geometric structure, and the entire two-dimensional code looks more beautiful. The preset geometric shape in the auxiliary locator 305 can be set by the technician according to whether it is needed, and this embodiment is not specifically limited here.
[0145] The embodiments of the present application do not limit the positions and proportions of the various regions. For example, the image region 301 and the coding region 302 may adopt a 1:1 ratio in the horizontal direction, the spacing between the concentric circles may be the same or different, and the radius of the dot-shaped code elements may be the same or different.
[0146] Based on the structure of the above two-dimensional code, the embodiment of the present application provides a two-dimensional code generation method, such as Figure 4 As shown, Figure 4 A two-dimensional code generation method process is shown, and the specific steps are as follows:
[0147] Step S101, obtaining a character string of a QR code to be generated.
[0148] The electronic device 100 obtains a character string for generating a QR code, which may be a string of numbers, a sentence, a link, etc., such as "abcd", "I love Beijing", "http: / / www.xxxx.xxxx", etc.
[0149] Step S102: According to the acquired character string, a coding mode is selected to perform data encoding on the character string.
[0150] The electronic device 100 selects the most suitable encoding mode according to the acquired character string, and the encoding modes include digital encoding, character encoding, byte encoding, Japanese encoding, etc.
[0151] In some embodiments, the digital encoding may correspond to the decimal digits 0-9; the character encoding may include the decimal digits 0-9, uppercase letters, and characters such as $%, *+-. / : and space; the byte encoding may correspond to the ISO-8859-1 character set; the Japanese encoding may correspond to a double-byte encoding derived from the Shift JIS character set (Japanese coded character set).
[0152] Each encoding mode encodes the text (the string to be generated into a QR code) into a string of binary bits consisting of 0 and 1, but the encoding conversion method used is different. For example, for character encoding, all characters supported by the character encoding can correspond to an index value. For example, in the base_45 table, the numbers 0-9 correspond to index values 0-9, the letters AZ correspond to index values 10-35, the space character corresponds to index value 36, the character "$" corresponds to index value 37, the character "%" corresponds to index value 38, the character "." corresponds to index value 42, the character " / " corresponds to index value 43, and so on.
[0153] The electronic device 100 encodes the string according to the selected encoding mode and adds functional encoding information (including encoding mode indication information, character count information, padding information, etc.). The electronic device 100 converts the string into a corresponding binary string (for example: 1010101111001101) and determines the length of the string after encoding.
[0154] Optionally, in step S103, the binary string is encrypted and compressed.
[0155] The electronic device 100 encrypts and compresses the binary character string by using an encryption algorithm and a compression algorithm, thereby improving the security of the character string and increasing the storage space of the character string.
[0156] Among them, the encryption algorithm includes, for example, MD5 Message-Digest Algorithm, Secure Hash Algorithm (SHA), Hash-based Message Authentication Code (HMAC), Data Encryption Standard (DES), 3DES, Advanced Encryption Standard (AES), RSA algorithm, etc. The compression algorithm includes, for example, storage-based data optimization coding compression algorithm, etc.
[0157] Step S104: Determine the target version of the QR code to be generated according to the length of the binary string.
[0158] Different versions provide different amounts of stored data. The longer the binary string is, the greater the amount of data required for storage. The electronic device 100 determines the target version of the QR code to be generated based on the length of the binary string.
[0159] The following is an exemplary introduction to the six versions of the QR code in the embodiment of the present application. It should be noted that when describing the dot-shaped code elements in the six versions of the QR code below, the dot-shaped code elements here are all storage locations and cannot be equated with the code elements in the generated QR code.
[0160] Version 1: The encoding area of the QR code includes 4 concentric circle areas.
[0161] like Figure 5A As shown, the image area 401 of the QR code 40 indicates the brand type (Harmony OS) of the QR code 40. Figure 5A In FIG. 4 , the image region 401 is circular.
[0162] Taking the center point of the image area 401 as the center, the coding area 402 includes 4 concentric circular areas, each of which is evenly arranged with dot-shaped code elements, and the distance between the centers of two adjacent dot-shaped code elements in each concentric circular area (or the length of the arc formed by the centers of each two adjacent dot-shaped code elements) is the same. Each dot-shaped code element can store information, and the information stored in each dot-shaped code element can be indicated in the form of color. If a dot-shaped code element stores the first information (for example, binary 1), the dot-shaped code element is set to the first color (for example, black), and if a dot-shaped code element stores the second information (for example, binary 0), the dot-shaped code element is set to the second color (for example, white, for example, transparent color) or is not colored.
[0163] There is a first interval between the image area 401 and the coding area 402, and there is a second interval between every two adjacent concentric areas in the coding area 402, wherein each concentric area is composed of an inner ring and an outer ring, and the width of the concentric area is the difference between the radius of the inner ring and the outer ring. The second interval is the interval between the outer ring of the small concentric area and the inner ring of the large concentric area in the two adjacent concentric areas; there is a third interval between two adjacent dot-shaped code elements in each concentric area. For example, Figure 5A In the embodiment, if the diameter of a dot-shaped code element is 1, the radius of the image area 401 is 10, and the interval between the image area 401 and the coding area 402 is 1, that is, the first interval is 1 or the diameter of a dot-shaped code element; the width of each concentric circle area in the coding area 402 is 1, that is, the diameter of a dot-shaped code element; the interval between every two adjacent concentric circle areas in the coding area 402 is 1, that is, the second interval is 1 or the diameter of a dot-shaped code element; the interval between two adjacent dot-shaped code elements in each concentric circle area can be 0, or can be a section of an arc with the same central angle, that is, the third interval can be 0, or can be a section of an arc with the same central angle.
[0164] In some embodiments, the four concentric circular areas are divided into an upper half area and a lower half area, and there is a fourth interval between the upper half area and the lower half area, for example, Figure 5A In the example, if the diameter of a dot-shaped code element is 1, the interval between the upper and lower areas is 5.
[0165] The locator area is within the QR code, for example Figure 5A It includes three main locators 403 and one auxiliary locator 404. The outer contours of the three main locators 403 and one auxiliary locator 404 are all circular. The center of the main locator 403 is in the second to last concentric circle area on the periphery. The diameter of a dot-shaped code element is 1, and the diameter of the three main locators 403 is 5.
[0166] Version 2: The encoding area of the QR code includes 5 concentric circle areas.
[0167] like Figure 5B As shown, the image area 411 of the QR code 41 indicates the brand type (Harmony OS) of the QR code 41. With the center point of the image area 411 as the center, the coding area 412 includes 5 concentric circle areas, each of which is evenly arranged with dot-shaped code elements, and the distance between the centers of two adjacent dot-shaped code elements in each concentric circle area (or the length of the arc formed by the centers of each two adjacent dot-shaped code elements) is the same.
[0168] There is a first interval between the image area 411 and the coding area 412, a second interval between every two adjacent concentric circle areas in the coding area 412, and a third interval between two adjacent dot-shaped code elements in each concentric circle area. Figure 5B In the figure, if the diameter of a dot-shaped code element is 1, the radius of the image area 411 is 10, and the interval between the image area 411 and the coding area 412 is 2, that is, the first interval is 2 or the diameter of two dot-shaped code elements; the interval between every two adjacent concentric circle areas in the coding area 412 is 1, that is, the second interval is 1 or the diameter of a dot-shaped code element; the interval between two adjacent dot-shaped code elements in each concentric circle area can be 0, or can be a section of an arc with the same central angle, that is, the third interval can be 0, or can be a section of an arc with the same central angle.
[0169] In some embodiments, the four concentric circular areas are divided into an upper half area and a lower half area, and there is a fourth interval between the upper half area and the lower half area, for example, Figure 5B In the example, if the diameter of a dot-shaped code element is 1, the interval between the upper and lower areas is 5.
[0170] The locator area is within the QR code, for example Figure 5B It includes three main locators 413 and one auxiliary locator 414. The outer contours of the three main locators 413 and one auxiliary locator 414 are all circular. The center of the main locator 413 is in the second to last concentric circle area on the periphery. The diameter of a dot-shaped code element is 1, and the diameter of the three main locators 413 is 5.
[0171] Version 3: The encoding area of the QR code includes 8 concentric circle areas.
[0172] like Figure 5C As shown, the image area 421 of the QR code 42 indicates the brand type (Harmony OS) of the QR code 42. With the center point of the image area 421 as the center, the coding area 422 includes 8 concentric circle areas, each of which is evenly arranged with dot-shaped code elements, and the distance between the centers of two adjacent dot-shaped code elements in each concentric circle area (or the length of the arc formed by the centers of each two adjacent dot-shaped code elements) is the same.
[0173] There is a first interval between the image area 421 and the coding area 422, a second interval between every two adjacent concentric circle areas in the coding area 422, and a third interval between two adjacent dot-shaped code elements in each concentric circle area. Figure 5CIn the figure, if the diameter of a dot-shaped code element is 1, the radius of the image area 421 is 10, and the interval between the image area 421 and the coding area 422 is 2, that is, the first interval is 2 or the diameter of two dot-shaped code elements; the interval between each two adjacent concentric circle areas in the coding area 422 is less than 1, that is, the second interval can be between 0 and 1; the interval between two adjacent dot-shaped code elements in each concentric circle area can be 0, or can be a section of an arc with the same central angle, that is, the third interval can be 0, or can be a section of an arc with the same central angle.
[0174] In some embodiments, the eight concentric circular areas are divided into an upper half area and a lower half area, and there is a fourth interval between the upper half area and the lower half area, for example, Figure 5C In the example, if the diameter of a dot-shaped code element is 1, the interval between the upper and lower areas is 5.
[0175] The locator area is within the QR code, for example Figure 5C It includes three main locators 423 and one auxiliary locator 424. The outer contours of the three main locators 423 and one auxiliary locator 424 are all circular. The center of the main locator 423 is in the second to last concentric circle area on the periphery. The diameter of a dot-shaped code element is 1, and the diameter of the three main locators 423 is 5.
[0176] Version 4: The encoding area of the QR code includes 10 concentric circle areas.
[0177] like Figure 5D As shown, the image area 431 of the two-dimensional code 43 indicates the brand type (Harmony OS) of the two-dimensional code 43. With the center point of the image area 431 as the center, the coding area 432 includes 10 concentric circle areas, each of which is evenly arranged with dot-shaped code elements, and the distance between the centers of two adjacent dot-shaped code elements in each concentric circle area (or the length of the arc formed by the centers of each two adjacent dot-shaped code elements) is the same.
[0178] There is a first interval between the image area 431 and the coding area 432, a second interval between every two adjacent concentric circle areas in the coding area 432, and a third interval between two adjacent dot-shaped code elements in each concentric circle area. Figure 5DIn the figure, if the diameter of a dot-shaped code element is 1, the radius of the image area 431 is 10, and the interval between the image area 431 and the coding area 432 is 2, that is, the first interval is 2 or the diameter of two dot-shaped code elements; the interval between each two adjacent concentric circle areas in the coding area 432 is less than 1, that is, the second interval can be between 0 and 1; the interval between two adjacent dot-shaped code elements in each concentric circle area can be 0, or can be a section of an arc with the same central angle, that is, the third interval can be 0, or can be a section of an arc with the same central angle.
[0179] In some embodiments, the four concentric circular areas are divided into an upper half area and a lower half area, and there is a fourth interval between the upper half area and the lower half area, for example, Figure 5D In the example, if the diameter of a dot-shaped code element is 1, the interval between the upper and lower areas is 5.
[0180] The locator area is within the QR code, for example Figure 5D It includes three main locators 433 and one auxiliary locator 434. The outer contours of the three main locators 433 and one auxiliary locator 434 are all circular. The center of the main locator 433 is in the second to last concentric circle area on the periphery. The diameter of a dot-shaped code element is 1, and the diameter of the three main locators 433 is 5.
[0181] Version 5: The QR code's encoding area includes 11 concentric circle areas.
[0182] like Figure 5E As shown, the image area 441 of the QR code 44 indicates the brand type (Harmony OS) of the QR code 44. With the center point of the image area 441 as the center, the coding area 442 includes 11 concentric circle areas, each of which is evenly arranged with dot-shaped code elements, and the distance between the centers of two adjacent dot-shaped code elements in each concentric circle area (or the length of the arc formed by the centers of each two adjacent dot-shaped code elements) is the same.
[0183] There is a first interval between the image area 441 and the coding area 442, a second interval between every two adjacent concentric circle areas in the coding area 442, and a third interval between two adjacent dot-shaped code elements in each concentric circle area. Figure 5EIn the figure, if the diameter of a dot-shaped code element is 1, the radius of the image area 441 is 10, and the interval between the image area 441 and the coding area 442 is 1, that is, the first interval is 1 or the diameter of a dot-shaped code element; the interval between each two adjacent concentric circle areas in the coding area 442 is less than 1, that is, the second interval can be between 0 and 1; the interval between two adjacent dot-shaped code elements in each concentric circle area can be 0, or can be a section of an arc with the same central angle, that is, the third interval can be 0, or can be a section of an arc with the same central angle.
[0184] In some embodiments, the 11 concentric circular areas are divided into an upper half area and a lower half area, and there is a fourth interval between the upper half area and the lower half area, for example, Figure 5E In the example, if the diameter of a dot-shaped code element is 1, the interval between the upper and lower areas is 5.
[0185] The locator area is within the QR code, for example Figure 5E It includes three main locators 443 and one auxiliary locator 444. The outer contours of the three main locators 443 and one auxiliary locator 444 are all circular. The center of the main locator 443 is in the second to last concentric circle area on the periphery. The diameter of a dot-shaped code element is 1, and the diameter of the three main locators 443 is 5.
[0186] Version 6, the QR code's encoding area includes 13 concentric circle areas.
[0187] like Fig. 5F As shown, the image area 451 of the QR code 45 indicates the brand type (Harmony OS) of the QR code 45. With the center point of the image area 451 as the center, the coding area 452 includes 13 concentric circle areas, each of which is evenly arranged with dot-shaped code elements, and the distance between the centers of two adjacent dot-shaped code elements in each concentric circle area (or the length of the arc formed by the centers of each two adjacent dot-shaped code elements) is the same.
[0188] There is a first interval between the image area 451 and the coding area 452, a second interval between every two adjacent concentric circle areas in the coding area 452, and a third interval between two adjacent dot-shaped code elements in each concentric circle area. Fig. 5FIn the figure, if the diameter of a dot-shaped code element is 1, the radius of the image area 451 is 13, and the interval between the image area 451 and the coding area 452 is 3, that is, the first interval is 3 or the diameter of three dot-shaped code elements; the interval between every two adjacent concentric circle areas in the coding area 452 is less than 1, that is, the second interval can be between 0 and 1; the interval between two adjacent dot-shaped code elements in each concentric circle area can be 0, or can be a section of an arc with the same central angle, that is, the third interval can be 0, or can be a section of an arc with the same central angle.
[0189] In some embodiments, the four concentric circular areas are divided into an upper half area and a lower half area, and there is a fourth interval between the upper half area and the lower half area, for example, Fig. 5F In the example, if the diameter of a dot-shaped code element is 1, the interval between the upper and lower areas is 7.
[0190] The locator area is within the QR code, for example Fig. 5F It includes three main locators 453 and one auxiliary locator 454. The outer contours of the three main locators 453 and one auxiliary locator 454 are all circular. The center of the main locator 453 is in the second to last concentric circle area on the periphery. The diameter of a dot-shaped code element is 1, and the diameter of the three main locators 453 is 5.
[0191] It is understandable that the more the number of concentric circle areas and the more the number of dot-shaped code elements, the larger the storage data volume of the version. Not limited to the above six versions, the number of concentric circle areas of the QR code and the number of dot-shaped code elements in each concentric circle area can have other configurations, and this application does not limit this.
[0192] For example, this application also provides a QR code version, such as Figure 5G and Figure 5H As shown, it is different from the styles of versions 1 to 6. Figure 5G and Figure 5H The arrangement of the dot-shaped code elements is radiating, and the number of dot-shaped code elements on each concentric circle is the same. Figure 5G The code includes 6 concentric circles. Starting from the center of the QR code, a ray formed by connecting the center of any dot-shaped code element can pass through the center of a dot-shaped code element on the other 5 concentric circles. Figure 5H The QR code includes 7 concentric circles. Similarly, starting from the center of the QR code, the ray formed by connecting the center of any dot-shaped code element can pass through the center of a dot-shaped code element on the other 6 concentric circles.
[0193] After the electronic device 100 determines the target version of the QR code to be generated based on the length of the binary string, it can obtain the center coordinates of the dot-shaped code elements storing information in the target version, the radius information of the dot-shaped code elements, the center coordinates and radius information of the image area, the relevant coordinate information of the locator, and so on.
[0194] Step S105 , according to the positions of the image area, the coding area, and the locator in the target version of the two-dimensional code to be generated, the binary character string is allocated to each concentric circle area in the coding area to obtain the two-dimensional code information.
[0195] The electronic device 100 performs ring processing on the binary string according to the positions of the image area, the coding area, and the locator in the structure of the target version of the QR code to be generated, and distributes the binary string to the dot-shaped code elements in each concentric circle area in the coding area to obtain the QR code information.
[0196] Specifically, according to the number of concentric circle areas in the coding area in the QR code structure and the information capacity of each concentric circle area (positively correlated with the number of dot-shaped code elements), the binary string can be split into sub-strings corresponding to each concentric circle area, and each sub-string can be assigned to the dot-shaped code elements in the corresponding concentric circle area for storage.
[0197] The two-dimensional code information includes information stored corresponding to each dot-shaped code element, for example, the dot-shaped code element at the first position stores the first information, and the dot-shaped code element at the second position stores the second information, wherein the first position and the second position indicate the center coordinates and radius information of the dot-shaped code element. Exemplarily, the first information may be 1 in a binary string, and the second information may be 0 in a binary string.
[0198] In some embodiments, the two-dimensional code information may further include a display form corresponding to each dot-shaped code element, for example, the dot-shaped code element storing the first information is correspondingly set to a first color, and the dot-shaped code element storing the second information is correspondingly set to a second color. Exemplarily, the first color may be black, and the second color may be white, or transparent, or not colored.
[0199] In some embodiments, the electronic device 100 further splits a substring corresponding to a concentric circle area into two substrings, which are respectively stored in the upper and lower halves of the concentric circle area; a substring corresponding to a concentric circle area can also be further split into four substrings, which are respectively stored in the four quadrants of the concentric circle area.
[0200] The electronic device 100 fills the binary string into the dot-shaped code elements in the concentric circle areas of the target version of the QR code. The filling direction may be to fill the innermost concentric circle area first and then slowly fill to the outer concentric circle area; or to fill the outermost concentric circle area first and then slowly fill to the inner concentric circle area; or it may be from left to right, from top to bottom, etc., which is not limited to this in the embodiments of the present application.
[0201] If a reserved area (such as an area reserved for format information, an area reserved for version information) and a functional module area (such as a locator area, a calibration module area, and a time module area) is encountered, the code element there will not be filled until the next idle code element is filled.
[0202] Step S106: Select a mask mode and add mask information.
[0203] Masking is a strategy that changes the value of the code element in the coding area of the QR code according to specific rules. The purpose of using masking is to adjust the display effect of the code element in the QR code (for example, to avoid large blank or black blocks in the QR code, which affect the scanning and recognition), so that the code reader can read the information as easily as possible.
[0204] The mask mode includes, for example, masking all even-numbered concentric circle areas in the two-dimensional code; or, for another example, masking some dot-shaped code elements in each concentric circle area in the two-dimensional code. The electronic device 100 uses the mask mode to perform mask superposition processing on the two-dimensional code information to adjust the layout of the two-dimensional code information so that the distribution of code elements in the two-dimensional code information is more uniform, thereby making the generated two-dimensional code more beautiful.
[0205] Specifically, the mask superposition processing of the two-dimensional code information using the mask can be achieved by performing an XOR operation on the binary string of the two-dimensional code information and the mask.
[0206] In some embodiments, the electronic device 100 fills the two-dimensional code information with added mask information into the encoding area, and the electronic device 100 verifies whether the target version meets the capacity requirement of the two-dimensional code to be generated. If so, the version information is added.
[0207] Step S107: Generate a QR code according to a drawing algorithm.
[0208] In the embodiment of the present application, the electronic device 100 can encode the coding area of the QR code by leaving the unavailable area vacant. After completing the encoding of the QR code coding area to obtain the QR code information, the electronic device 100 uses a drawing algorithm to draw the dot-shaped code elements storing the first information in the coding area as a first color and the dot-shaped code elements storing the second information as a second color based on the QR code information, thereby completing the drawing of the coding area. The electronic device 100 then fills the corresponding image area, locator area and other areas in the target version to obtain a complete QR code image. The unavailable area includes the image area, locator area, and blank areas in the coding area (such as Figure 5A There is a blank area of 5 between the upper and lower areas), and so on.
[0209] In some embodiments, the electronic device 100 connects and draws the dot-shaped code elements that meet the preset conditions into arc-shaped code elements, wherein the preset conditions include that if there are two or more consecutive adjacent dot-shaped code elements in a concentric circle area that store the first information, the two or more adjacent dot-shaped code elements are connected and drawn into an arc-shaped code element, and the arc-shaped code element is drawn in the first color. Optionally, the part of the arc-shaped code element that connects the dot-shaped code element is also filled with the first color, which can enhance the aesthetics of the QR code. Similarly, if there are two or more consecutive adjacent dot-shaped code elements in a concentric circle area that store the second information, the two or more adjacent dot-shaped code elements are connected and drawn into an arc-shaped code element, and the arc-shaped code element is drawn in the second color.
[0210] The following is an exemplary description of the two-dimensional code images generated for the six versions of the two-dimensional code mentioned above.
[0211] When the target version is version 1, the generated exemplary QR code is as follows: Fig. 6A shown. Fig. 6A It includes 4 concentric circle areas, based on version one, in which some dot-shaped code elements are drawn in black, some dot-shaped code elements are drawn in white or transparent color or not colored, and consecutive adjacent dot-shaped code elements drawn in black are connected and drawn as arc-shaped code elements.
[0212] When the target version is version 2, the generated exemplary QR code is as follows: Figure 6B shown. Figure 6B It includes 5 concentric circle areas, based on version 2, in which some dot-shaped code elements are drawn in black, some dot-shaped code elements are drawn in white or transparent color or not colored, and consecutive adjacent dot-shaped code elements drawn in black are connected and drawn as arc-shaped code elements.
[0213] When the target version is version 3, the generated exemplary QR code is as follows: Figure 6Cshown. Figure 6C It includes 8 concentric circle areas, based on version 3, in which some dot-shaped code elements are drawn in black, some dot-shaped code elements are drawn in white or transparent or not colored, and consecutive adjacent dot-shaped code elements drawn in black are connected and drawn as arc-shaped code elements.
[0214] When the target version is version 4, the generated exemplary QR code is as follows Fig.6D shown. Fig.6D It includes 10 concentric circle areas, based on version 4, in which some dot-shaped code elements are drawn in black, some dot-shaped code elements are drawn in white or transparent or not colored, and consecutive adjacent dot-shaped code elements drawn in black are connected and drawn as arc-shaped code elements.
[0215] When the target version is version 5, the generated QR code is as follows: Fig. 6E shown. Fig. 6E It includes 11 concentric circle areas, based on version five, in which some dot-shaped code elements are drawn in black, some dot-shaped code elements are drawn in white or transparent or not colored, and consecutive adjacent dot-shaped code elements drawn in black are connected and drawn as arc-shaped code elements.
[0216] When the target version is version 6, the generated exemplary QR code is as follows: Fig. 6F shown. Fig. 6F The diagram includes 13 concentric circle areas, based on version six, in which some dot-shaped code elements are drawn in black, some dot-shaped code elements are drawn in white or transparent or not colored, and consecutive adjacent dot-shaped code elements drawn in black are connected and drawn as arc-shaped code elements.
[0217] The embodiment of the present application provides a method for generating a two-dimensional code, wherein the electronic device 100 performs bit processing on the character string of the to-be-generated two-dimensional code to obtain a corresponding binary character string; determines the target version according to the length of the binary character string, and distributes the binary character string to each concentric circle area in the coding area of the target version to obtain the two-dimensional code information; uses a mask to perform mask superposition processing on the two-dimensional code information to adjust the layout of the two-dimensional code information, and finally draws the final two-dimensional code. In this way, the encoding of the two-dimensional code that conforms to the two-dimensional code structure of the target version can be completed, and the code elements in the generated two-dimensional code are evenly distributed and more beautiful.
[0218] The version of the QR code provided in the embodiment of the present application is a circular QR code, the coding area is composed of at least two concentric circle areas, and the code elements include dot-shaped code elements and arc-shaped code elements. The embodiment of the present application can increase the data storage capacity of the QR code by increasing the number of circles and the number of code elements in the concentric circle area. In addition, the electronic device 100 encrypts the string during the encoding process, and the decoding needs to adopt a decryption algorithm corresponding to the encryption algorithm to obtain a complete string, thereby improving the security of the QR code.
[0219] The following describes a method for drawing dot-shaped code elements in a two-dimensional code in an embodiment of the present application. In the above step S107, the electronic device 100 draws the dot-shaped code elements storing the first information in the coding area into the first color through a drawing algorithm based on the two-dimensional code information. The two-dimensional code information includes the information stored corresponding to each dot-shaped code element. For example, the dot-shaped code element in the first position stores the first information, wherein the first position indicates the center coordinates (cen_x, cen_y) and radius information 0.5h of the dot-shaped code element. The electronic device 100 draws the dot-shaped code element into the first color, and the position and outline of the dot-shaped code element of the first color can be determined by the center coordinates and radius information. The drawing algorithm is specifically as follows,
[0220] like Fig. 7A As shown, the horizontal right is defined as the positive x direction, and the vertical downward is defined as the positive y direction. Draw from top to bottom, with the y axis as the variable, and at each position y, determine the x_left and x_right (coordinates of the left and right boundaries) of the position through the analytical equation of the circle. Based on the two-dimensional code information, the electronic device 100 draws the dot-shaped code element storing the first information in the first color. The electronic device 100 obtains the coordinates of the center of the dot-shaped code element as (cen_x, cen_y), the diameter is h, and the radius is 0.5h. Among them,
[0221] x_left can be derived based on the analytical equation of the arc on the left, which is:
[0222] (cen_y-0.5h<y<cen_y+0.5h) Formula①
[0223] x_right can be derived based on the analytical equation of the arc on the right, which is:
[0224] (cen_y-0.5h<y<cen_y+0.5h) Formula②
[0225] In some embodiments, the electronic device 100 stores the information of the QR code in an array of 3000 bits. For example, int32 can be used as the basic unit of data storage, that is, 32 bits are used to represent an integer, and x_left and x_right are mapped to corresponding bits in the 32-bit integer to implement image information storage in the bit stream.
[0226] like Figure 7B As shown, in each 32-bit array, there is a corresponding set of x_left and x_right, and the points outside x_left and x_right in the 32-bit are set to zero (such as Figure 7B The white part in the middle), the point between x_left and x_right in the 32bit is set to non-zero (such as Figure 7B In this way, when drawing a dot-shaped code element, each set of x_left and x_right can draw a row of pixels of the first color. From top to bottom, according to the above formulas ① and ②, x_left and x_right can be continuously obtained, thereby drawing a complete dot-shaped code element of the first color.
[0227] In the embodiment of the present application, the drawing direction or order of the code elements is not limited. For example, it can be drawn from left to right, with the x axis as a variable. At each position x, the y_left and y_right (the coordinates of the upper and lower boundaries) of the position are determined by the analytical equation of the circle. Another example is drawing from the inside to the outside (first drawing the innermost concentric circles, and then continuously drawing concentric circles outward), etc.
[0228] The above describes the method of drawing a dot-shaped code element. The following describes the method of drawing an arc-shaped code element in the embodiment of the present application. The arc-shaped code element is formed by connecting two or more dot-shaped code elements through arcs on the basis of the dot-shaped code element. In other words, each arc-shaped code element is formed by connecting two or more dot-shaped code elements. In the embodiment of the present application, each arc-shaped code element can be surrounded by two arcs and two line segments. The two arcs belong to a large circle and a small circle respectively. The large circle and the small circle are concentric circles, and the center coordinates of the concentric circles are O1 (org_x, org_y).
[0229] like Figure 8 As shown, Figure 8The structure of two arc-shaped code elements is shown as an example. The electronic device 100 connects the dot-shaped code elements that meet the preset conditions and draws them into an arc-shaped code element. The embodiment of the present application forms an arc-shaped code element. The dot-shaped code element on the far left is called circle 1. The electronic device 100 obtains the coordinates of the center of circle 1 as (cen_x1, cen_y1) based on the two-dimensional code information; the dot-shaped code element on the far right is called circle 2, and the coordinates of the center of circle 2 are obtained as (cen_x2, cen_y2). h represents the height of the circumscribed square of circle 1 and circle 2 (that is, the diameter of circle 1 and circle 2), and the radius of the arc formed by the centers of circle 1 and circle 2 is radius. Among them, radius can be obtained by calculating the distance between the center coordinates of circle 1 (cen_x1, cen_y1) and O1 (org_x, org_y). θ1 is the angle between the line connecting the centers of circle 1 and the large circle and the x-axis (the value of θ1 is between 0 and π), and θ2 is the angle between the line connecting the centers of circle 2 and the large circle and the x-axis (the value of θ2 is between 0 and π).
[0230] In the embodiment of the present application, the point of circle 1 farthest from O1 is called the vertex of circle 1 (x 1_up ,y 1_up ), the point of circle 1 closest to O1 is called the bottom point of circle 1 (x 1_down ,y 1_down ), similarly, the point on circle 2 that is farthest from O1 is called the vertex of circle 2 (x 2_up ,y 2_up ), the point of circle 2 closest to O1 is called the bottom point of circle 2 (x 2_down ,y 2_down ).
[0231] For example, the coordinates of the vertex and base of circle 1 can be obtained by calculation, that is,
[0232]
[0233] Similarly, the coordinates of the vertex and base of circle 2 can be obtained by calculation, that is,
[0234]
[0235] In some embodiments, it is specified that the horizontal right direction is the positive x direction, and the vertical downward direction is the positive y direction. Draw from top to bottom, with the y axis as the variable, and at each position y, the x_left and x_right (coordinates of the left and right boundaries) of the position are determined by the analytical equation of the circle. The direction of arc drawing is from top to bottom, so it is necessary to consider different analytical equations for the left and right boundaries. Due to the different positions of the arc, the arc has different piecewise analytical equations on the upper left, lower left, upper right, and lower right sides of the center line, which are specifically divided into the following eight cases:
[0236] Case 1: If Fig. 9AAs shown, the arc is on the upper left side of the center line, in the positive direction of the y-axis, the vertex of circle 2 < the base of circle 2 < the vertex of circle 1 < the base of circle 1, that is, y 2_up <y 2_down <y 1_up <y 1_down .
[0237] When the value of y is in the interval [circle 2 vertex, circle 2 bottom point], the left side is the large circle arc, and the right side is the circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the large circle arc on the left, that is:
[0238]
[0239] x_right can be derived based on the analytical equation of the right circle 2 oblique lines, namely:
[0240] y len =(yy 2_up ) / sin(θ2)
[0241] x_right=org x -(radius+0.5hy len )*cos(θ2) formula④
[0242] When the value of y is in the interval [the base of circle 2, the top of circle 1], the left side is the large circle arc, and the right side is the small circle arc. Among them, x_left can be obtained based on the analytical equation of the large circle arc on the left (same as formula ③), that is:
[0243]
[0244] x_right can be obtained based on the analytical equation of the small arc on the right, that is;
[0245]
[0246] When the value of y is in the interval [circle 1 vertex, circle 1 bottom point], the left side is circle 1 oblique line, and the right side is small circle arc. Among them, x_left can be obtained based on the analytical equation of circle 1 oblique line on the left side, that is:
[0247] y len =(yy 1_up ) / sin(θ1)
[0248] x_left=org x -(radius+0.5hy len )*cos(θ1) Formula ⑥
[0249] x_right can be obtained based on the analytical equation of the small arc on the right (same as formula ⑤), that is:
[0250]
[0251] In the embodiment of the present application, based on the above formulas ③④⑤⑥, the electronic device 100 can draw the following Fig. 9A The electronic device 100 determines, based on the two-dimensional code information, that the dot-shaped code elements that meet the preset conditions are connected as arc-shaped code elements, and then determines the dot-shaped code elements (circle 1 and circle 2) at both ends of an arc-shaped code element, obtains the coordinate points of the centers of circle 1 and circle 2, and then determines the y-axis coordinate points of the vertices and bases of circle 1 and circle 2. If in the y-axis direction, the vertex of circle 2 < the base of circle 2 < the vertex of circle 1 < the base of circle 1, it is determined that it belongs to case 1, and then x_left and x_right are determined based on the analytical equation of case 1, thereby drawing an arc.
[0252] The electronic device 100 maps x_left and x_right to corresponding bits in a 32-bit integer, sets the points outside x_left and x_right in the 32-bit integer to zero, and sets the points between x_left and x_right in the 32-bit integer to non-zero. In this way, when drawing an arc-shaped symbol, each group of x_left and x_right can draw a row of pixels, and from top to bottom, according to the above formulas ③④⑤⑥, x_left and x_right can be continuously obtained, thereby drawing a complete arc-shaped symbol.
[0253] Case 2: If Fig. 9B As shown, the arc is on the upper left side of the center line. In the y-axis direction, the vertex of circle 2 is less than the vertex of circle 1, and the bottom point of circle 2 is less than the bottom point of circle 1. That is, y 2_up <y 1_up <y 2_down <y 1_down .
[0254] When the value of y is in the interval [circle 2 vertex, circle 1 vertex], the left side is the large circle arc, and the right side is the circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the large circle arc on the left, refer to formula ③; x_right can be obtained based on the analytical equation of the circle 2 oblique line on the right, refer to formula ④.
[0255] When the value of y is in the interval [circle 1 vertex, circle 2 bottom], the left side is circle 1 oblique line, and the right side is circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the left oblique line of circle 1, refer to formula ⑥; x_right can be obtained based on the analytical equation of the right oblique line of circle 2, refer to formula ④.
[0256] When the value of y is in the interval [circle 1 vertex, circle 1 bottom point], the left side is circle 1 oblique line, and the right side is small circle arc. Among them, x_left can be obtained based on the analytical equation of circle 1 oblique line on the left side, refer to formula ⑥; x_right can be obtained based on the analytical equation of small circle arc on the right side, refer to formula ⑤.
[0257] Case 3: If Fig. 9C As shown, the arc is on the lower left side of the center line. In the y-axis direction, the bottom point of circle 1 is less than the top point of circle 1, and the bottom point of circle 2 is less than the top point of circle 2. That is, y 1_down <y 1_down <y 2_down <y 2_up .
[0258] When the value of y is in the interval [circle 1 bottom point, circle 1 top point], the left side is circle 1 oblique line, and the right side is small circle arc. Among them, x_left can be obtained based on the analytical equation of circle 1 oblique line on the left side, refer to formula ⑥; x_right can be obtained based on the analytical equation of small circle arc on the right side, refer to formula ⑤.
[0259] When the value of y is in the interval [circle 1 vertex, circle 2 bottom point], the left side is the large circle arc and the right side is the small circle arc. Among them, x_left can be obtained based on the analytical equation of the large circle arc on the left, refer to formula ③; x_right can be obtained based on the analytical equation of the small circle arc on the right, refer to formula ⑤.
[0260] When the value of y is in the interval [circle 2 base, circle 2 apex], the left side is the large circle arc, and the right side is the circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the large circle arc on the left, refer to formula ③; x_right can be obtained based on the analytical equation of the circle 2 oblique line on the right, refer to formula ④.
[0261] Case 4: If Fig.9D As shown, the arc is on the lower left side of the center line. In the y-axis direction, the bottom point of circle 1 is less than the bottom point of circle 2, the top point of circle 1 is less than the top point of circle 2, that is, y 1_down <y 2_down <y 1_up <y 2_up .
[0262] When the value of y is in the interval [bottom point of circle 1, bottom point of circle 2], the left side is the oblique line of circle 1, and the right side is the small circle arc. Among them, x_left can be obtained based on the analytical equation of the oblique line of circle 1 on the left, refer to formula ⑥; x_right can be obtained based on the analytical equation of the small circle arc on the right, refer to formula ⑤.
[0263] When the value of y is in the interval [bottom of circle 2, top of circle 1], the left side is the oblique line of circle 1, and the right side is the oblique line of circle 2. Among them, x_left can be obtained based on the analytical equation of the oblique line of circle 1 on the left, refer to formula ⑥; x_right can be obtained based on the analytical equation of the oblique line of circle 2 on the right, refer to formula ④.
[0264] When the value of y is in the interval [circle 1 vertex, circle 2 vertex], the left side is the large circle arc, and the right side is the circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the large circle arc on the left, refer to formula ③; x_right can be obtained based on the analytical equation of the circle 2 oblique line on the right, refer to formula ④.
[0265] Case 5: If Fig.9E As shown, the arc is on the lower right side of the center line. In the y-axis direction, the bottom point of circle 2 is less than the bottom point of circle 1, and the top point of circle 2 is less than the top point of circle 1. That is, y 2_down <y 1_down <y 2_up <y 1_up .
[0266] When the value of y is in the interval [bottom point of circle 2, bottom point of circle 1], the left side is the small circle arc, and the right side is the oblique line of circle 2. Among them, x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the oblique line of circle 2 on the right, refer to formula ④.
[0267] When the value of y is in the interval [bottom of circle 1, top of circle 2], the left side is the oblique line of circle 1, and the right side is the oblique line of circle 2. Among them, x_left can be obtained based on the analytical equation of the oblique line of circle 1 on the left, refer to formula ⑥; x_right can be obtained based on the analytical equation of the oblique line of circle 2 on the right, refer to formula ④.
[0268] When the value of y is in the interval [circle 2 vertex, circle 1 vertex], the left side is circle 1 oblique line, and the right side is large circle arc. Among them, x_left can be obtained based on the analytical equation of circle 1 oblique line on the left side, refer to formula ⑥; x_right can be obtained based on the analytical equation of large circle arc on the right side, refer to formula ③.
[0269] Case 6: If Fig.9F As shown, the arc is on the lower right side of the center line. In the y-axis direction, the bottom point of circle 2 is less than the top point of circle 2, and the bottom point of circle 1 is less than the top point of circle 1. 1_down <y 2_down <y 1_up <y 2_up .
[0270] When the value of y is in the interval [circle 2 bottom point, circle 2 top point], the left side is the small circle arc, and the right side is the circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the circle 2 oblique line on the right, refer to formula ④.
[0271] When the value of y is in the interval [vertex of circle 2, bottom of circle 1], the left side is a small circle arc and the right side is a large circle arc. Among them, x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the large circle arc on the right, refer to formula ③.
[0272] When the value of y is in the interval [circle 1 vertex, circle 2 vertex], the left side is circle 1 oblique line, and the right side is large circle arc. Among them, x_left can be obtained based on the analytical equation of circle 1 oblique line on the left side, refer to formula ⑥; x_right can be obtained based on the analytical equation of large circle arc on the right side, refer to formula ③.
[0273] Case 7: If Figure 9G As shown, the arc is on the upper right side of the center line. In the y-axis direction, the vertex of circle 1 is less than the bottom point of circle 1 and the vertex of circle 2 is less than the bottom point of circle 2. 1_up <y 1_down <y 2_up <y 2_down .
[0274] When the value of y is in the interval [circle 1 vertex, circle 1 bottom point], the left side is circle 1 oblique line, and the right side is large circle arc. Among them, x_left can be obtained based on the analytical equation of circle 1 oblique line on the left side, refer to formula ⑥; x_right can be obtained based on the analytical equation of large circle arc on the right side, refer to formula ③.
[0275] When the value of y is in the interval [circle 1 bottom point, circle 2 top point], the left side is a small circle arc, and the right side is a large circle arc. Among them, x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the large circle arc on the right, refer to formula ③.
[0276] When the value of y is in the interval [circle 2 vertex, circle 2 base], the left side is the small circle arc, and the right side is the circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the circle 2 oblique line on the right, refer to formula ④.
[0277] Case 8: If Figure 9H As shown, the arc is on the upper right side of the center line. In the y-axis direction, the vertex of circle 1 is less than the vertex of circle 2, the bottom point of circle 1 is less than the bottom point of circle 2, that is, y 1_up <y 2_up <y1_down <y 2_down .
[0278] When the value of y is in the interval [circle 1 vertex, circle 2 vertex], the left side is circle 1 oblique line, and the right side is large circle arc. Among them, x_left can be obtained based on the analytical equation of circle 1 oblique line on the left side, refer to formula ⑥; x_right can be obtained based on the analytical equation of large circle arc on the right side, refer to formula ③.
[0279] When the value of y is in the interval [circle 2 vertex, circle 1 bottom], the left side is circle 1 oblique line, and the right side is circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the left oblique line of circle 1, refer to formula ⑥; x_right can be obtained based on the analytical equation of the right oblique line of circle 2, refer to formula ④.
[0280] When the value of y is in the interval [bottom point of circle 1, bottom point of circle 2], the left side is the small circle arc, and the right side is the oblique line of circle 2. Among them, x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the oblique line of circle 2 on the right, refer to formula ④.
[0281] The above lists eight methods of drawing arc-shaped code elements in different positions.
[0282] In some embodiments, the arc-shaped code elements may pass through the center line (a straight line passing through point O1 and perpendicular to the y-axis direction), resulting in the arc-shaped code elements being distributed in the second and third quadrants, or in the first and fourth quadrants. These situations may correspond to one of the above-mentioned situations 1 to 8.
[0283] In some embodiments, the arc-shaped code element may pass through the center line (a straight line passing through point O1 and perpendicular to the x-axis direction), and the arc-shaped code element may appear on both sides of the center line, that is, the arc-shaped code element is distributed in the first quadrant and the second quadrant, or in the third quadrant and the fourth quadrant. At this time, the analytical equations from top to bottom may be completely different. In order to avoid the complexity of generating a two-dimensional code, the embodiment of the present application uses the center line as the boundary and divides an arc-shaped code element into two. The arc-shaped code element on the left side of the center line is drawn first, and then the arc-shaped code element on the right side of the center line is drawn, which is converted into a situation where the arc-shaped code element is on the same side of the center line.
[0284] In some embodiments, a method for determining whether a circular arc code element passes through the center line may be that if the horizontal coordinate of the center of circle 1 and the horizontal coordinate of the center of circle 2 in the circular arc code element include the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate of the center of circle 1 <org_y < the horizontal coordinate of the center of circle 2, then it is determined that the circular arc passes through the center line.
[0285] The following eight situations where the arc passes through the center line are described in detail:
[0286] Case 9: If Fig. 10A As shown, the arc involves the upper left and upper right sides of the midline, and the midline divides an arc into two left and right arc parts.
[0287] For the left arc part, in the y-axis direction, (org_y+radius+0.5h)<(org_y+radius-0.5h)<circle 1 vertex<circle 1 bottom point, that is, (org_y+radius+0.5h)<(org_y+radius-0.5h)<y 1_up <y 1_down .
[0288] In the first part, when the value of y is in the interval [(org_y+radius+0.5h), (org_y+radius-0.5h)], the curve is a large circle arc. x_left can be obtained based on the large circle arc analytical equation, refer to formula ③; x_right is the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate org_x of O1.
[0289] In the second part, when the value of y is [(org_y+radius-0.5h), y 1_up 】When it is within this interval, the left side is a large circle arc, and the right side is a small circle arc. Among them, x_left can be obtained based on the analytical equation of the large circle arc on the left, refer to formula ③; x_right can be obtained based on the identification equation of the small circle arc on the right, refer to formula ⑤.
[0290] The third part, when the value of y is in [y 1_up ,y 1_down 】When it is within this interval, the left side is the circle 1 oblique line, and the right side is the small circle arc. Among them, x_left can be obtained based on the analytical equation of the circle 1 oblique line on the left, refer to formula ⑥; x_right can be obtained based on the analytical equation of the small circle arc on the right, refer to formula ⑤.
[0291] For the right arc part, in the y-axis direction, (org_y+radius+0.5h)<circle 2 vertex<(org_y+radius-0.5h)<circle 2 bottom point, that is, (org_y+radius+0.5h)<y 2_up <(org_y+radius-0.5h)<y 2_down .
[0292] Part 4: When the value of y is between [(org_y+radius+0.5h), y 2_up 】The curve within this interval is a large circle arc, x_left is the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate org_x of O1; x_right can be obtained based on the analytical equation of the large circle arc, refer to formula ③.
[0293] Part 5: When the value of y is in [y 2_up , (org_y+radius-0.5h)】The curve in this interval is the oblique line of circle 2, x_left is the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate org_x of O1; x_right can be obtained based on the analytical equation of the oblique line of circle 2, refer to formula ④.
[0294] Part 6: When the value of y is between [(org_y+radius-0.5h), y 2_down 】When it is within this interval, the left side is a small circle arc, and the right side is a circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the circle 2 oblique line on the right, refer to formula ④.
[0295] Case 10: If Fig. 10B As shown, the arc involves the upper left and upper right sides of the midline, and the midline divides an arc into two left and right arc parts.
[0296] For the left arc part, in the y-axis direction, (org_y+radius+0.5h)<(org_y+radius-0.5h)<circle 1 vertex<circle 1 bottom point, that is, (org_y+radius+0.5h)<(org_y+radius-0.5h)<y 1_up <y 1_down .
[0297] In the first part, when the value of y is in the interval [(org_y+radius+0.5h), (org_y+radius-0.5h)], the curve is a large circle arc. x_left can be obtained based on the large circle arc analytical equation, refer to formula ③; x_right is the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate org_x of O1.
[0298] In the second part, when the value of y is [(org_y+radius-0.5h), y 1_up 】When it is within this interval, the left side is a large circle arc, and the right side is a small circle arc. Among them, x_left can be obtained based on the analytical equation of the large circle arc on the left, refer to formula ③, and x_right can be obtained based on the analytical equation of the small circle arc on the right, refer to formula ⑤.
[0299] The third part, when the value of y is in [y 1_up ,y 1_down 】When it is within this interval, the left side is the circle 1 oblique line, and the right side is the small circle arc. Among them, x_left can be obtained based on the analytical equation of the circle 1 oblique line on the left, refer to formula ⑥; x_right can be obtained based on the analytical equation of the small circle arc on the right, refer to formula ⑤.
[0300] For the right arc part, in the y-axis direction, (org_y+radius+0.5h)<(org_y+radius-0.5h)<circle 2 vertex<circle 2 bottom point, that is, (org_y+radius+0.5h)<(org_y+radius-0.5h)<y 2_up <y 2_down .
[0301] In the fourth part, when the value of y is in the interval [(org_y+radius+0.5h), (org_y+radius-0.5h)], the curve is a large circle arc, x_left is the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate org_x of O1; x_right can be obtained based on the analytical equation of the large circle arc, refer to formula ③.
[0302] Part 5: When the value of y is between [(org_y+radius-0.5h), y 2_up 】When it is within this interval, the left side is a small arc and the right side is a large arc. Among them, x_left can be obtained based on the analytical equation of the small arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the large arc on the right, refer to formula ③.
[0303] Part 6: When the value of y is in [y 2_up ,y 2_down 】When it is within this interval, the left side is a small circle arc, and the right side is a circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the circle 2 oblique line on the right, refer to formula ④.
[0304] Case 11: If Fig. 10C As shown, the arc involves the upper left and upper right sides of the midline, and the midline divides an arc into two left and right arc parts.
[0305] For the left arc part, in the y-axis direction, (org_y+radius+0.5h)<circle 1 vertex<(org_y+radius-0.5h)<circle 1 bottom point, that is, (org_y+radius+0.5h)<y 1_up <(org_y+radius-0.5h)<y 1_down .
[0306] In the first part, when the value of y is [(org_y+radius+0.5h), y 1_up 】The curve within this interval is a great circle arc. x_left can be obtained based on the analytical equation of the great circle arc, refer to formula ③; x_right is the horizontal coordinate of the center of the great circle, that is, the horizontal coordinate org_x of O1.
[0307] The second part, when the value of y is in [y 1_up , (org_y+radius-0.5h)】The curve in this interval is the oblique line of circle 1, x_left can be obtained based on the analytical equation of the oblique line of circle 1, refer to formula ⑥; x_right is the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate org_x of O1.
[0308] In the third part, when the value of y is [(org_y+radius-0.5h), y 1_down 】When it is within this interval, the left side is the circle 1 oblique line, and the right side is the small circle arc. Among them, x_left can be obtained based on the analytical equation of the circle 1 oblique line on the left, refer to formula ⑥; x_right can be obtained based on the analytical equation of the small circle arc on the right, refer to formula ⑤.
[0309] For the right arc part, in the y-axis direction, (org_y+radius+0.5h)<circle 2 vertex<(org_y+radius-0.5h)<circle 2 bottom point, that is, (org_y+radius+0.5h)<y 2_up <(org_y+radius-0.5h)<y 2_down .
[0310] Part 4: When the value of y is between [(org_y+radius+0.5h), y 2_up 】The curve within this interval is a large circle arc, x_left is the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate org_x of O1; x_right can be obtained based on the analytical equation of the large circle arc, refer to formula ③.
[0311] Part 5: When the value of y is in [y 2_up , (org_y+radius-0.5h)】The curve in this interval is the oblique line of circle 2, x_left is the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate org_x of O1; x_right can be obtained based on the analytical equation of the oblique line of circle 2, refer to formula ④.
[0312] Part 6: When the value of y is between [(org_y+radius-0.5h), y 2_down 】When it is within this interval, the left side is a small circle arc, and the right side is a circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the circle 2 oblique line on the right, refer to formula ④.
[0313] Case 12: If Fig. 10D As shown, the arc involves the upper left and upper right sides of the midline, and the midline divides an arc into two left and right arc parts.
[0314] For the left arc part, in the y-axis direction, (org_y+radius+0.5h)<circle 1 vertex<(org_y+radius-0.5h)<circle 1 bottom point, that is, (org_y+radius+0.5h)<y 1_up <(org_y+radius-0.5h)<y 1_down .
[0315] In the first part, when the value of y is [(org_y+radius+0.5h), y 1_up 】The curve within this interval is a great circle arc. x_left can be obtained based on the analytical equation of the great circle arc, refer to formula ③; x_right is the horizontal coordinate of the center of the great circle, that is, the horizontal coordinate org_x of O1.
[0316] The second part, when the value of y is in [y 1_up , (org_y+radius-0.5h)】The curve in this interval is the oblique line of circle 1, x_left can be obtained based on the analytical equation of the oblique line of circle 1, refer to formula ⑥; x_right is the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate org_x of O1.
[0317] In the third part, when the value of y is [(org_y+radius-0.5h), y 1_down 】When it is within this interval, the left side is the circle 1 oblique line, and the right side is the small circle arc. Among them, x_left can be obtained based on the analytical equation of the circle 1 oblique line on the left, refer to formula ⑥; x_right can be obtained based on the analytical equation of the small circle arc on the right, refer to formula ⑤.
[0318] For the right arc part, in the y-axis direction, (org_y+radius+0.5h)<(org_y+radius-0.5h)<circle 2 vertex<circle 2 bottom point, that is, (org_y+radius+0.5h)<(org_y+radius-0.5h)<y 2_up <y 2_down .
[0319] In the fourth part, when the value of y is in the interval [(org_y+radius+0.5h), (org_y+radius-0.5h)], the curve is a large circle arc, x_left is the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate org_x of O1; x_right can be obtained based on the analytical equation of the large circle arc, refer to formula ③.
[0320] Part 5: When the value of y is between [(org_y+radius-0.5h), y 2_up】When it is within this interval, the left side is a small arc and the right side is a large arc. Among them, x_left can be obtained based on the analytical equation of the small arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the large arc on the right, refer to formula ③.
[0321] Part 6: When the value of y is in [y 2_up ,y 2_down 】When it is within this interval, the left side is a small circle arc, and the right side is a circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the circle 2 oblique line on the right, refer to formula ④.
[0322] Case 13: If Fig.10E As shown, the arc involves the lower left and lower right sides of the midline, and the midline divides an arc into two left and right arc parts.
[0323] For the left arc part, in the y-axis direction, the bottom point of circle 1 < (org_y-radius+0.5h) < the top point of circle 1 < (org_y-radius-0.5h), that is, y 1_down <(org_y-radius+0.5h)<y 1_up <(org_y-radius-0.5h).
[0324] In the first part, when the value of y is in [y 1_down , (org_y-radius+0.5h)】, the left side is the circle 1 oblique line, and the right side is the small circle arc. Among them, x_left can be obtained based on the analytical equation of the circle 1 oblique line, refer to formula ⑥, and x_right can be obtained based on the analytical equation of the small circle arc on the right, refer to formula ⑤.
[0325] In the second part, when the value of y is [(org_y-radius+0.5h), y 1_up 】The curve within this interval is the oblique line of circle 1. x_left can be obtained based on the analytical equation of the oblique line of circle 1 on the left, refer to formula ⑥; x_right is the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate org_x of O1.
[0326] The third part, when the value of y is in [y 1_up , (org_y-radius-0.5h)】The curve in this interval is a great circle arc, x_left can be obtained based on the analytical equation of the great circle arc, refer to formula ③; x_right is the horizontal coordinate of the center of the great circle, that is, the horizontal coordinate org_x of O1.
[0327] For the right arc part, in the y-axis direction, the bottom point of circle 2 < the top point of circle 2 < (org_y-radius+0.5h) < (org_y-radius-0.5h), that is, y 2_down <y 2_up <(org_y-radius+0.5h)<(org_y-radius-0.5h).
[0328] Part 4: When the value of y is between [(y 2_down ,y 2_up 】When it is within this interval, the left side is the small circle arc, and the right side is the circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the circle 2 oblique line, refer to formula ④.
[0329] Part 5: When the value of y is in [y 2_up , (org_y-radius+0.5h)】When it is in this interval, the left side is a small circle arc and the right side is a large circle arc. x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the large circle arc on the right, refer to formula ③.
[0330] In the sixth part, when the value of y is in the interval [(org_y-radius+0.5h), (org_y-radius-0.5h)], the curve is a great circle arc, x_left is the horizontal coordinate of the center of the great circle, that is, the horizontal coordinate org_x of O1; x_right can be obtained based on the analytical equation of the great circle arc, refer to formula ③.
[0331] Case 14: If Fig.10F As shown, the arc involves the lower left and lower right sides of the midline, and the midline divides an arc into two left and right arc parts.
[0332] For the left arc part, in the y-axis direction, the bottom point of circle 1 < (org_y-radius+0.5h) < the top point of circle 1 < (org_y-radius-0.5h), that is, y 1_down <(org_y-radius+0.5h)<y 1_up <(org_y-radius-0.5h).
[0333] In the first part, when the value of y is in [y 1_down , (org_y-radius+0.5h)】, the left side is the circle 1 oblique line, and the right side is the small circle arc. Among them, x_left can be obtained based on the analytical equation of the circle 1 oblique line, refer to formula ⑥, and x_right can be obtained based on the analytical equation of the small circle arc on the right, refer to formula ⑤.
[0334] In the second part, when the value of y is [(org_y-radius+0.5h), y 1_up 】The curve within this interval is the oblique line of circle 1. x_left can be obtained based on the analytical equation of the oblique line of circle 1 on the left, refer to formula ⑥; x_right is the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate org_x of O1.
[0335] The third part, when the value of y is in [y 1_up , (org_y-radius-0.5h)】The curve in this interval is a great circle arc, x_left can be obtained based on the analytical equation of the great circle arc, refer to formula ③; x_right is the horizontal coordinate of the center of the great circle, that is, the horizontal coordinate org_x of O1.
[0336] For the right arc part, in the y-axis direction, the bottom point of circle 2 is less than (org_y-radius+0.5h) and the top point of circle 2 is less than (org_y-radius-0.5h), that is, y 2_down <(org_y-radius+0.5h)<y 2_up <(org_y-radius-0.5h).
[0337] Part 4: When the value of y is in [y 2_down , (org_y-radius+0.5h)】, the left side is the small circle arc, and the right side is the circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the circle 2 oblique line on the right, refer to formula ④.
[0338] Part 5: When the value of y is between [(org_y-radius+0.5h), y 2_up 】The curve in this interval is the oblique line of circle 2, x_left is the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate org_x of O1; x_right can be obtained based on the analytical equation of the oblique line of circle 2, refer to formula ④.
[0339] Part 6: When the value of y is in [y 2_up , (org_y-radius-0.5h)】The curve in this interval is a great circle arc, x_left is the horizontal coordinate of the center of the great circle, that is, the horizontal coordinate org_x of O1; x_right can be obtained based on the analytical equation of the great circle arc, refer to formula ③.
[0340] Case 15: If Figure 10G As shown, the arc involves the lower left and lower right sides of the midline, and the midline divides an arc into two left and right arc parts.
[0341] For the left arc part, in the y-axis direction, the bottom point of circle 1 < the top point of circle 1 < (org_y-radius+0.5h) < (org_y-radius-0.5h), that is, y 1_down <y 1_up <(org_y-radius+0.5h)<(org_y-radius-0.5h).
[0342] In the first part, when the value of y is in [y 1_down ,y 1_up 】When it is within this interval, the left side is the circle 1 oblique line, and the right side is the small circle arc. Among them, x_left can be obtained based on the analytical equation of the circle 1 oblique line on the left, refer to formula ⑥; x_right can be obtained based on the analytical equation of the small circle arc on the right, refer to formula ⑤.
[0343] The second part, when the value of y is in [y 1_up , (org_y-radius+0.5h)】, the left side is a large arc, and the right side is a small arc. Among them, x_left can be obtained based on the analytical equation of the large arc on the left; x_right can be obtained based on the reference formula ③ and the analytical equation of the small arc on the right, reference formula ⑤.
[0344] In the third part, when the value of y is in the interval [(org_y-radius+0.5h), (org_y-radius-0.5h)], the curve is a great circle arc. x_left can be obtained based on the analytical equation of the great circle arc, refer to formula ③; x_right is the horizontal coordinate of the center of the great circle, that is, the horizontal coordinate org_x of O1.
[0345] For the right arc part, in the y-axis direction, the bottom point of circle 2 is less than (org_y-radius+0.5h) and the top point of circle 2 is less than (org_y-radius-0.5h), that is, y 2_down <(org_y-radius+0.5h)<y 2_up <(org_y-radius-0.5h).
[0346] Part 4: When the value of y is between [(y 2_down ,y 2_up 】When it is within this interval, the left side is the small circle arc, and the right side is the circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the circle 2 oblique line, refer to formula ④.
[0347] Part 5: When the value of y is in [y 2_up, (org_y-radius+0.5h)】When it is in this interval, the left side is a small circle arc and the right side is a large circle arc. x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the large circle arc on the right, refer to formula ③.
[0348] In the sixth part, when the value of y is in the interval [(org_y-radius+0.5h), (org_y-radius-0.5h)], the curve is a great circle arc, x_left is the horizontal coordinate of the center of the great circle, that is, the horizontal coordinate org_x of O1; x_right can be obtained based on the analytical equation of the great circle arc, refer to formula ③.
[0349] Case 16: If Fig. 10H As shown, the arc involves the lower left and lower right sides of the midline, and the midline divides an arc into two left and right arc parts.
[0350] For the left arc part, in the y-axis direction, the bottom point of circle 1 < the top point of circle 1 < (org_y-radius+0.5h) < (org_y-radius-0.5h), that is, y 1_down <y 1_up <(org_y-radius+0.5h)<(org_y-radius-0.5h).
[0351] In the first part, when the value of y is in [y 1_down ,y 1_up 】When it is within this interval, the left side is the circle 1 oblique line, and the right side is the small circle arc. Among them, x_left can be obtained based on the analytical equation of the circle 1 oblique line on the left, refer to formula ⑥; x_right can be obtained based on the analytical equation of the small circle arc on the right, refer to formula ⑤.
[0352] The second part, when the value of y is in [y 1_up , (org_y-radius+0.5h)】, the left side is a large arc, and the right side is a small arc. Among them, x_left can be obtained based on the analytical equation of the large arc on the left; x_right can be obtained based on the reference formula ③ and the analytical equation of the small arc on the right, reference formula ⑤.
[0353] In the third part, when the value of y is in the interval [(org_y-radius+0.5h), (org_y-radius-0.5h)], the curve is a great circle arc. x_left can be obtained based on the analytical equation of the great circle arc, refer to formula ③; x_right is the horizontal coordinate of the center of the great circle, that is, the horizontal coordinate org_x of O1.
[0354] For the right arc part, in the y-axis direction, the bottom point of circle 2 is less than (org_y-radius+0.5h) and the top point of circle 2 is less than (org_y-radius-0.5h), that is, y 2_down <(org_y-radius+0.5h)<y 2_up <(org_y-radius-0.5h).
[0355] Part 4: When the value of y is in [y 2_down , (org_y-radius+0.5h)】, the left side is the small circle arc, and the right side is the circle 2 oblique line. Among them, x_left can be obtained based on the analytical equation of the small circle arc on the left, refer to formula ⑤; x_right can be obtained based on the analytical equation of the circle 2 oblique line on the right, refer to formula ④.
[0356] Part 5: When the value of y is between [(org_y-radius+0.5h), y 2_up 】The curve in this interval is the oblique line of circle 2, x_left is the horizontal coordinate of the center of the large circle, that is, the horizontal coordinate org_x of O1; x_right can be obtained based on the analytical equation of the oblique line of circle 2, refer to formula ④.
[0357] Part 6: When the value of y is in [y 2_up , (org_y-radius-0.5h)】The curve in this interval is a great circle arc, x_left is the horizontal coordinate of the center of the great circle, that is, the horizontal coordinate org_x of O1; x_right can be obtained based on the analytical equation of the great circle arc, refer to formula ③.
[0358] For the above sixteen situations, the electronic device 100 can draw an arc of any shape. The electronic device 100 obtains the coordinate points of the centers of circle 1 and circle 2, and then determines the y-axis coordinate points of the vertices and bottom points of circle 1 and circle 2. The electronic device determines the size of the vertex of circle 2, the bottom point of circle 2, the vertex of circle 1, and the bottom point of circle 1 in the y-axis direction, and then determines which of the above sixteen situations it belongs to, and then draws the arc based on the analytical equation of the corresponding situation.
[0359] Correspond x_left and x_right to the corresponding bits in the 32-bit integer, set the points outside x_left and x_right in the 32-bit to zero, and set the points between x_left and x_right in the 32-bit to non-zero. In this way, when drawing an arc code element, each set of x_left and x_right can draw a row of pixels, and draw from top to bottom. According to the formula in the corresponding situation, x_left and x_right can be continuously obtained, thereby drawing a complete arc code element.
[0360] In the embodiment of the present application, both the generation and recognition of the QR code adopt the 32-bit bit stream method, which can improve the encoding and decoding speed of the QR code.
[0361] The above describes the steps of generating and drawing a two-dimensional code in the embodiment of the present application. For the generated two-dimensional code image, the embodiment of the present application also provides a corresponding two-dimensional code recognition method, such as Fig.11 As shown, the specific steps of this method are as follows:
[0362] Step S201: The electronic device 100 obtains a picture to be identified.
[0363] The picture to be identified includes a QR code to be identified.
[0364] In some embodiments, after the electronic device 100 obtains the picture to be identified, it performs contrast adjustment, grayscale processing, binarization processing, smoothing processing and other operations on the picture to be identified to facilitate subsequent two-dimensional code recognition.
[0365] Step S202: The electronic device 100 determines the position of the locator in the image to be identified.
[0366] The electronic device 100 obtains the picture to be identified, and when identifying the two-dimensional code in the picture to be identified, it searches for the locator in the picture to be identified according to the characteristics of the locator, and determines the position of the locator in the input picture.
[0367] In some embodiments, the locators include three locators and one auxiliary locator, which are distributed at the upper left, upper right, lower left, and lower right of the two-dimensional code. The electronic device 100 searches for the three locators in the input image according to the characteristics of the three locators, and determines the positions of the three locators in the input image. A variety of combination methods are used to combine the position positioning of the three locators to achieve accurate and rapid positioning of the two-dimensional code.
[0368] The pattern of the locator is generally a pattern with a fixed ratio (such as Figure 3C As shown, the pattern of the locator is a concentric circular pattern of black and white. The ratio of the black and white code elements of the main locator is 1:1:2:1:1, and the ratio of the black and white code elements of the auxiliary locator is 1:1:2:1:1). In the process of scanning the QR code, the locator pattern of the QR code is generally searched based on this fixed ratio to determine the direction of the QR code.
[0369] Exemplarily, after determining the position of an auxiliary locator, the electronic device 100 can quickly locate the position of the main locator based on the relative position relationship between the main locator and the auxiliary locator, thereby improving the efficiency of QR code positioning.
[0370] Exemplarily, the positions of three main locators and one auxiliary locator can be located separately. According to the positions of the located main locators and the auxiliary locators, combined with the relative position relationship between the main locators and the auxiliary locators in the QR code structure, the position calibration of the QR code coding area can be performed to improve the accuracy of QR code positioning.
[0371] Step S203: The electronic device 100 identifies the QR code image in the image to be identified based on the position of the locator, identifies the version information in the QR code image, and determines the target version of the QR code to be identified.
[0372] After the electronic device 100 determines the target version of the QR code to be identified, it can obtain the center coordinates and radius information of each storage position (dot shape) in the target version, the center coordinates and radius information of the image area, the relevant coordinate information of the locator, etc.
[0373] In some embodiments, the electronic device 100 can determine the vertex position of the two-dimensional code in the image to be identified based on the position of the locator, and then correct the two-dimensional code based on the vertex position, for example, the electronic device 100 performs a perspective transformation on the two-dimensional code image to obtain a non-tilted two-dimensional code image. Due to the problem of shooting angle, in most cases, the two-dimensional code in the acquired two-dimensional code image is linearly deformed. The electronic device 100 detects the four corner points of the two-dimensional code and obtains a correction figure, that is, a non-tilted two-dimensional code image, according to the inverse perspective transformation.
[0374] Step S204: Identify the code element in the to-be-identified two-dimensional code through the coordinate information of each storage location in the target version to achieve decoding.
[0375] The coordinate information of each storage location in the target version includes the center coordinates and radius information of the storage location, wherein the target version may also indicate the center coordinates and radius information of the image area, the related coordinate information of the locator, and the like.
[0376] The electronic device 100 obtains the coordinate information of each storage location in the target version including the center coordinates and radius information of the storage location, and then identifies the code elements in the two-dimensional code image (the two-dimensional code to be identified) based on the non-tilted two-dimensional code image.
[0377] In some embodiments, the electronic device 100 identifies the corresponding stored value at each storage position in the two-dimensional code image based on the coordinate information of each storage position. Optionally, the value corresponding to the storage position occupied by the code element in the coding area of the two-dimensional code to be identified is the first value, and the value corresponding to the storage position not occupied by the code element is the second value. For example, the electronic device 100 obtains the center coordinates and radius of a circle with 100 storage positions. The electronic device 100 scans the 100 storage positions in the two-dimensional code image based on the center coordinates and radius. The value corresponding to the storage position occupied by the code element is 1, and the value corresponding to the storage position not occupied by the code element is 0. Then, a string of binary characters can be identified. The electronic device 100 decodes based on the binary character string to obtain the information corresponding to the two-dimensional code.
[0378] In some embodiments, the electronic device 100 identifies the dot-shaped code element in the two-dimensional code image, determines the position of each dot-shaped code element and the value corresponding to each dot-shaped code element as a first value, and the electronic device 100 determines the value corresponding to the storage position not occupied by the code element as a second value based on the coordinate information of the storage position indicated in the target version of the two-dimensional code image. For example, the electronic device 100 identifies the two-dimensional code image and identifies that there are 60 positions (including the coordinates of the center of the circle and the radius) with code elements, and the corresponding value is 1; the electronic device 100 corresponds the 60 positions to, for example, 100 storage positions in the target version of the two-dimensional code, and the remaining 40 storage positions have a value of 0. The electronic device 100 identifies a string of binary characters, and the electronic device 100 decodes based on the binary character string to obtain the information corresponding to the two-dimensional code.
[0379] In some embodiments, the electronic device 100 identifies the dot-shaped code element in the two-dimensional code image, determines the position of the dot-shaped code element of the first color and the corresponding value as the first value, and determines the position of the dot-shaped code element of the second color and the corresponding value as the second value. Optionally, the electronic device 100 identifies the two-dimensional code image, identifies that the code element at 60 positions (including the coordinates of the center of the circle and the radius) is the first color, the corresponding value is 1, and the code element at 40 positions is the second color, and the corresponding value is 0; then the electronic device 100 identifies a string of binary characters, and the electronic device 100 decodes based on the binary character string to obtain the information corresponding to the two-dimensional code.
[0380] In some embodiments, the electronic device 100 identifies an arc-shaped code element in the two-dimensional code image, and based on the length of the arc-shaped code element, it can be determined that the arc-shaped code element is composed of several dot-shaped code elements, and the coordinates of the center of each dot-shaped code element can be determined. The electronic device 100 determines the position of each dot-shaped code element and the value corresponding to each dot-shaped code element as a first value, and the electronic device 100 determines that the value corresponding to the storage position not occupied by the code element is a second value based on the coordinate information of the storage position indicated in the target version of the two-dimensional code image.
[0381] The above describes the steps of identifying the two-dimensional code in the embodiment of the present application. The embodiment of the present application provides a method for identifying a two-dimensional code. The electronic device 100 performs digital image processing on the image to be identified, determines the position of the locator in the image to be identified, determines the two-dimensional code image, identifies the target version of the two-dimensional code, obtains the encoding information based on the position coordinates of the target version, and implements decoding through the decoding rules. In this way, the decoding of the two-dimensional code of the two-dimensional code structure of the target version is completed. In the embodiment of the present application, the two-dimensional code is identified by using a 32-bit bit stream, which can improve the decoding speed of the two-dimensional code.
[0382] The present application also provides other versions of the QR code. Fig. 12A and Fig. 12B As shown, Fig. 12A and Fig. 12B Two possible versions of the QR code are shown.
[0383] like Fig. 12A In the QR code version shown, the QR code is circular as a whole, including an image area located in the middle and a coding area surrounding the image area. Among them, the coding area of the QR code includes at least two concentric circles formed by the code elements of the QR code, and the code elements include dot-shaped code elements. The radius of the dot-shaped code elements in the same concentric circle area is the same, and the radius of the dot-shaped code elements in different concentric circle areas is different. Among them, the radius of the dot-shaped code element in the innermost concentric circle area is the smallest, and the radius of the dot-shaped code element in the outer concentric circle area is larger.
[0384] For example, Fig. 12A The figure also includes 3 main locators and 3 auxiliary locators, and the 3 main locators and 1 auxiliary locator are all circular areas. The number and style of the main locators and the auxiliary locators are not limited in the embodiment of the present application.
[0385] exist Fig. 12A In the embodiment of the present application, the number of concentric circle areas included in the coding area can be adjusted according to the size of the data volume of the two-dimensional code, and the information capacity of the two-dimensional code can be expanded by expanding the number of concentric circle areas in the coding area.
[0386] like Fig. 12B In the QR code version shown, the QR code is circular in shape, including an image area in the middle and a coding area surrounding the image area. The coding area of the QR code includes at least two concentric circles formed by the code elements of the QR code, and the code elements include dot-shaped code elements. The radius of each dot-shaped code element is the same. Figure 3A The difference is that, Fig. 12B The QR code version shown does not include circular arc-shaped code elements.
[0387] For example, Fig. 12B The figure also includes 3 main locators and 3 auxiliary locators, and the 3 main locators and 1 auxiliary locator are all circular areas. The number and style of the main locators and the auxiliary locators are not limited in the embodiment of the present application.
[0388] exist Fig. 12B In the embodiment of the present application, the number of concentric circle areas included in the coding area can be adjusted according to the size of the data volume of the two-dimensional code, and the information capacity of the two-dimensional code can be expanded by expanding the number of concentric circle areas in the coding area.
[0389] The embodiment of the present application uses a new type of two-dimensional code structure. The two-dimensional code is circular, includes an image area in the middle and a coding area surrounding the image area, the coding area includes at least two concentric circle areas formed by the code elements of the two-dimensional code, and the code elements include dot-shaped code elements and arc-shaped code elements. By expanding the number of concentric circle areas of the coding area, the information capacity of the two-dimensional code can be quickly expanded; further, the area of the two-dimensional code other than the image area also includes a main locator and an auxiliary locator. When performing two-dimensional code recognition, combined with the positioning of the main locator and the auxiliary locator in the input image, a combination of multiple positioning methods can be achieved, so that the two-dimensional code can be accurately and quickly positioned, thereby improving the accuracy and efficiency of two-dimensional code recognition.
[0390] The present application also provides a computer-readable storage medium. All or part of the processes in the above method embodiments can be completed by a computer program to instruct the relevant hardware, and the program can be stored in the above computer storage medium. When the program is executed, it can include the processes of the above method embodiments. The computer-readable storage medium includes: a read-only memory (ROM) or a random access memory (RAM), a disk or an optical disk, and other media that can store program codes.
[0391] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media integration. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.
[0392] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs.
[0393] The modules in the device of the embodiment of the present application can be merged, divided and deleted according to actual needs.
[0394] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A two-dimensional code recognition method, It is characterized in that The two-dimensional code includes an image area located in the middle and a circular ring area surrounding the image area, the circular ring area includes a coding area, a first spacing area and a second spacing area, the coding area is composed of at least two concentric circles, the code elements in the coding area include one or more of dot-shaped code elements and arc-shaped code elements, and the code elements are distributed on the concentric circles, the coding area includes a first coding area and a second coding area, the first coding area is composed of the upper half of the concentric circles, the second coding area is composed of the lower half of the concentric circles, and the first spacing area and the second spacing area are respectively the left spacing area and the right spacing area between the first coding area and the second coding area; The method comprises: The electronic device obtains a two-dimensional code to be identified, and determines values corresponding to a plurality of code elements in a coding area of the two-dimensional code to be identified; The electronic device identifies the first information corresponding to the two-dimensional code to be identified according to the values corresponding to the multiple code elements in the coding area.
2. The method according to claim 1, It is characterized in that The first spacing area and the second spacing area are partial circular rings with the same width.
3. The method according to claim 1, It is characterized in that The first coding region and the second coding region occupy the same area.
4. The method according to claim 1, It is characterized in that The ratio of the width of the image area in the horizontal direction to the width of the two-dimensional code in the horizontal direction is 1:
3.
5. The method according to claim 1, It is characterized in that The multiple code elements in the coding area are distributed on at least two concentric circles, the centers of the at least two concentric circles are the centers of the two-dimensional code, and the code elements include dot-shaped code elements.
6. The method according to claim 5, It is characterized in that The arc distance between the centers of adjacent dot-shaped code elements on the same concentric circle in the coding area is (2r+b)*k, where k is a positive integer, r is the radius of the dot-shaped code element, and b is a fixed value; the circumference of the same concentric circle is N*(2r+b), where N is a positive integer greater than k.
7. The method according to claim 6, It is characterized in that In the same concentric circle of the coding area, the arc distance between the centers of three consecutive dot-shaped code elements is greater than (2r+b)*2.
8. The method according to claim 5, It is characterized in that There are dot-shaped code elements a and b on two different concentric circles of the two-dimensional code, respectively, and a line connecting the centers of the dot-shaped code element a and the dot-shaped code element b passes through the center of the two-dimensional code.
9. The method according to claim 5, It is characterized in that The radii of the dot-shaped code elements on different concentric circles in the two-dimensional code are different.
10. The method according to claim 9, It is characterized in that The radius of the dot-shaped code element in the outer concentric circles of the two-dimensional code is greater than the radius of the dot-shaped code element in the inner concentric circles.
11. The method according to claim 5, It is characterized in that The code elements also include arc-shaped code elements, and the arc length of the arc-shaped code elements on the concentric circles is (2r+b)*M, where M is a positive integer.
12. The method according to claim 11, It is characterized in that On the same concentric circle, the arc distance between an arc-shaped code element and its adjacent code element is greater than or equal to (2r+b)*2.
13. The method according to claim 1, It is characterized in that The electronic device obtains a two-dimensional code to be identified, determines values corresponding to a plurality of code elements in a coding area of the two-dimensional code to be identified, and identifies first information corresponding to the two-dimensional code to be identified, including: The electronic device obtains a QR code to be identified; The electronic device determines a target version of the to-be-recognized two-dimensional code, wherein the target version indicates coordinate information of each storage location in a coding area of the to-be-recognized two-dimensional code; The electronic device determines, based on the coordinate information of each storage position, that the storage position occupied by each code element in the encoding area of the to-be-identified two-dimensional code corresponds to the first value; The first information corresponding to the to-be-identified two-dimensional code is identified according to the first value.
14. The method according to claim 13, It is characterized in that Each storage location is in the shape of a dot, and the coordinate information includes the center coordinate information and radius information of the storage location.
15. The method according to claim 13, It is characterized in that The electronic device determines the target version of the to-be-recognized two-dimensional code, which includes: The electronic device determines the position of the locator in the image to be recognized; The electronic device determines the vertex position of the two-dimensional code in the image to be recognized based on the position of the locator; The electronic device corrects the two-dimensional code in the image to be identified based on the vertex position to obtain the two-dimensional code to be identified.
16. The method according to any one of claims 1 to 15, It is characterized in that The type of the first information includes one or more of the following: characters, text, pictures, audio, video, and link addresses.
17. A method for generating a two-dimensional code, It is characterized in that The method comprises: The electronic device acquires first information; The electronic device generates a two-dimensional code based on the first information, where the two-dimensional code indicates the first information; The two-dimensional code includes an image area located in the middle and a circular ring area surrounding the image area, the circular ring area includes a coding area, a first spacing area and a second spacing area, the coding area is composed of at least two concentric circles, the code elements in the coding area include one or more of dot-shaped code elements and arc-shaped code elements, and the code elements are distributed on the concentric circles. The coding area includes a first coding area and a second coding area, the first coding area is composed of the upper half of the concentric circles, and the second coding area is composed of the lower half of the concentric circles. The first spacing area and the second spacing area are respectively the left spacing area and the right spacing area set between the first coding area and the second coding area.
18. The method according to claim 17, It is characterized in that The multiple code elements in the coding area are distributed on at least two concentric circles, the centers of the at least two concentric circles are the centers of the two-dimensional code, and the multiple code elements include dot-shaped code elements.
19. The method according to claim 18, It is characterized in that The electronic device generating a two-dimensional code based on the first information includes: The electronic device encodes the first information into a binary string; The electronic device determines a target version of the QR code to be generated according to the length of the binary string, wherein the target version indicates coordinate information of each storage location in the coding area; The electronic device allocates the binary string to a storage position in the coding area according to the coordinate information of each storage position; wherein the storage position includes a first storage position and a second storage position, the first storage position stores a first value in the binary string and the second storage position stores a second value in the binary string; The electronic device draws a first code element based on the coordinate information of the first storage location, and generates a two-dimensional code based on the first code element; the first code element is one of multiple code elements in the encoding area of the two-dimensional code.
20. The method according to claim 19, It is characterized in that The coordinate information of the storage location includes the center coordinate information and radius information of the storage location; the first code element is a dot-shaped code element, and the dot-shaped code element is drawn based on the center coordinate information and radius information of the first storage location.
21. The method according to claim 19, It is characterized in that The number of concentric circles in the coding region varies in different target versions.
22. The method according to claim 19, It is characterized in that The electronic device draws a first symbol at the first storage location based on the coordinate information of the first storage location, including: The electronic device determines a value range of the first code element on the Y axis by using the circle center coordinate information and the radius information of the first storage location, wherein a minimum value of the value range of the first code element on the Y axis is the circle center ordinate in the circle center coordinate information minus the radius, and a maximum value of the value range is the circle center ordinate in the circle center coordinate information plus the radius; The electronic device determines a left X value and a right X value for each Y value within the value range by a preset formula, and draws the pixel points between the left X value and the right X value as a first color, thereby completing the drawing of the first code element, and all the pixel points of the first code element are the first color.
23. The method according to claim 19, It is characterized in that The method further comprises: The first code element further includes an arc-shaped code element, and the arc-shaped code element occupies at least two adjacent first storage positions, and the at least two adjacent first storage positions are located on the same concentric circle.
24. The method according to claim 23, It is characterized in that The first code element occupies at least two storage positions, wherein the storage positions at the left and right ends of the at least two storage positions are the third storage position and the fourth storage position; the center points of the third storage position and the fourth storage position are both on the same side of the midline of the two-dimensional code, and the midline of the two-dimensional code is a straight line passing through the center point of the two-dimensional code and perpendicular to the X-axis; The electronic device draws a first symbol based on the coordinate information of the first storage location, including: The electronic device determines the value range of the first code element on the Y axis through the coordinate information of the center of the circle and the radius information of the third storage position and the fourth storage position, and when the ordinate of the center of the circle of the third storage position is greater than the ordinate of the center of the circle of the fourth storage position, the minimum value of the value range of the first code element on the Y axis is the ordinate of the point on the third storage position that is shortest from the center of the two-dimensional code, and the maximum value of the value range of the first code element on the Y axis is the ordinate of the point on the fourth storage position that is longest from the center of the two-dimensional code; The electronic device determines a left X value and a right X value for each Y value within the value range by a preset formula, and draws the pixel points between the left X value and the right X value as a first color, thereby completing the drawing of the first code element, and all the pixel points of the first code element are the first color.
25. The method according to claim 23, It is characterized in that The first code element occupies at least two storage positions, wherein the storage positions at the left and right ends of the at least two storage positions are the third storage position and the fourth storage position; the center points of the third storage position and the fourth storage position are respectively on both sides of the midline of the two-dimensional code, the midline of the two-dimensional code is a straight line passing through the center point of the two-dimensional code and perpendicular to the X-axis, the part of the first code element on the left side of the midline is the first part, and the part of the first code element on the right side of the midline is the second part; The electronic device draws a first symbol based on the coordinate information of the first storage location, including: The electronic device draws the first part and the second part of the first code element respectively; the minimum value of the value range of the first part on the Y-axis is the vertical coordinate of the point on the third storage position that is shortest from the center of the two-dimensional code, and the maximum value of the value range on the Y-axis is the maximum vertical coordinate in the concentric circle where the third storage position is located; the minimum value of the value range of the second part on the Y-axis is the vertical coordinate of the point on the fourth storage position that is shortest from the center of the two-dimensional code, and the maximum value of the value range on the Y-axis is the maximum vertical coordinate in the concentric circle where the fourth storage position is located.
26. An electronic device, It is characterized in that include: One or more processors, one or more memories; the one or more memories are respectively coupled to the one or more processors; the one or more memories are used to store computer program code, and the computer program code includes computer instructions; when the computer instructions are executed on the processor, the electronic device executes the method described in any one of claims 1-16 or 17-25.
27. A computer-readable medium for storing one or more programs, wherein the one or more programs are configured to be executed by the one or more processors, the one or more programs comprising instructions for executing the method of any one of claims 1-16 or 17-25.
Citation Information
Cited By
QR code recognition method and related apparatus
WO2022166619A1
