CN113919382A - Code scanning method and device - Google Patents

Code scanning method and device Download PDF

Info

Publication number
CN113919382A
CN113919382A CN202110477843.0A CN202110477843A CN113919382A CN 113919382 A CN113919382 A CN 113919382A CN 202110477843 A CN202110477843 A CN 202110477843A CN 113919382 A CN113919382 A CN 113919382A
Authority
CN
China
Prior art keywords
parameter
code scanning
electronic device
image
module
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110477843.0A
Other languages
Chinese (zh)
Other versions
CN113919382B (en
Inventor
王国英
余烽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202110477843.0A priority Critical patent/CN113919382B/en
Publication of CN113919382A publication Critical patent/CN113919382A/en
Application granted granted Critical
Publication of CN113919382B publication Critical patent/CN113919382B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • G06K7/14172D bar codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1443Methods for optical code recognition including a method step for retrieval of the optical code locating of the code in an image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1456Methods for optical code recognition including a method step for retrieval of the optical code determining the orientation of the optical code with respect to the reader and correcting therefore
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/146Methods for optical code recognition the method including quality enhancement steps
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02ATECHNOLOGIES FOR ADAPTATION TO CLIMATE CHANGE
    • Y02A10/00TECHNOLOGIES FOR ADAPTATION TO CLIMATE CHANGE at coastal zones; at river basins
    • Y02A10/40Controlling or monitoring, e.g. of flood or hurricane; Forecasting, e.g. risk assessment or mapping

Abstract

The application discloses a code scanning method and device. The electronic equipment can obtain an original image through the camera based on the adjusted camera parameters by adjusting the camera focusing mode and the camera frame rate and other camera parameters of the image collected by the camera, and then the electronic equipment can process the original image to obtain a clear image comprising the corrected bar code. Therefore, a clearer and easily-recognized bar code image can be quickly obtained, and the bar code scanning speed of bar code scanning application is improved.

Description

Code scanning method and device
Technical Field
The present application relates to the field of terminals, and in particular, to a method and an apparatus for scanning a code.
Background
With the development of science and technology, barcodes are flooding our lives. The barcode may help us to pay quickly, add friends, pay public numbers, etc. When a user uses a terminal to identify a barcode, the barcode identification speed of the terminal is slow, even the barcode cannot be identified due to the influence of factors such as the position of the barcode, the brightness of the identification environment, the size of the barcode and the like.
Disclosure of Invention
The application provides a code scanning method and a related device, which realize that the camera shooting parameters such as the focusing mode of a camera and the frame rate of pictures collected by the camera are adjusted, and the original image is obtained through the camera based on the adjusted camera shooting parameters, and then the electronic equipment can process the original image to obtain a clear image comprising a corrected bar code. Therefore, the electronic equipment can quickly obtain a clearer and easily-recognized bar code image, and the code scanning speed of code scanning application is improved.
In a first aspect, the present application provides a code scanning method applied to an electronic device installed with a code scanning application, including: after receiving a code scanning input of a user for a code scanning application, the electronic device determines that the electronic device is in a code scanning scene. The electronic device selects a target mode from one or more parameter modes supported by a camera on the electronic device based on parameter information of a code scanning application, wherein the parameter information comprises one or more of resolution, frame rate and focusing mode. The electronic equipment acquires a first image based on the parameters corresponding to the target mode, wherein the first image comprises a bar code. The electronic device displays a second image, wherein the second image comprises the corrected bar code.
According to the code scanning method, when the electronic equipment scans the codes, the target mode can be selected from a plurality of parameter modes supported by the electronic equipment based on the parameter information applied by the code scanning, and the first image comprising the bar code can be obtained based on the target mode. The electronic equipment can also obtain a second image through correction based on the first image and display the second image on a display screen of the electronic equipment. The code scanning application can obtain the information of the bar code through the second image and execute corresponding operation according to the information of the bar code. Therefore, the electronic equipment can obtain the image comprising the bar code more quickly, and the code scanning speed is improved.
In a possible embodiment, the electronic device includes a code scanning determination module, and after receiving a code scanning input by a user for a code scanning application, the method further includes: the scan application initiates a scan activity. And the code scanning application sends the parameter information of the code scanning application to the code scanning judgment module.
In a possible implementation manner, the electronic device includes an activity manager, and after the code scanning application starts code scanning activity, the method further includes: the activity manager obtains the activity name of the scanning activity. The activity manager sends the activity name to the code scanning judgment module.
In a possible implementation manner, determining that the electronic device is in a code scanning scene specifically includes: after receiving the activity name, a code scanning judgment module of the electronic device acquires a preset list, wherein the preset list stores all activity names for executing code scanning operation by the application providing the code scanning function. When the code scanning judgment module determines that the preset list comprises the activity name, the code scanning judgment module determines that the electronic equipment is in the code scanning scene.
In one possible implementation manner, the code scanning application sends parameter information of the code scanning application to the code scanning judgment module through the first interface.
In a possible implementation manner, the electronic device includes a code scanning determination module, and after receiving a code scanning input by a user for a code scanning application, the method further includes: the code scanning application sends the camera calling parameter to the code scanning judgment module through the second interface, the code scanning application sends the parameter information to the code scanning judgment module through the first interface, and the second interface is different from the first interface. The electronic equipment determines that the electronic equipment is in a code scanning scene, and the method specifically comprises the following steps: after the code scanning judgment module receives the camera calling parameter sent by the code scanning application through the second interface, the code scanning judgment module determines that the value of the camera calling parameter is a preset value, and the code scanning judgment module determines that the electronic equipment is in a code scanning scene.
In a possible implementation manner, the electronic device includes a barcode identification module, and after the electronic device receives a code scanning input of a user for a code scanning application, the method further includes: the electronic device acquires a third image in response to the scan code input. The electronic equipment determines that the electronic equipment is in a code scanning scene, and the method specifically comprises the following steps: when the barcode recognition module recognizes that the third image comprises the barcode, the barcode recognition module determines that the electronic equipment is in a barcode scanning scene.
In a possible implementation manner, the electronic device includes a parameter adjusting module, and after the code scanning determining module determines that the electronic device is in a code scanning scene, the method further includes: and the code scanning judgment module sends the information in the code scanning scene and the parameter information applied by the code scanning to the parameter adjustment module. In response to receiving the parameter information of the code scanning application, the parameter adjusting module acquires one or more parameter modes supported by a camera of the electronic device. The electronic equipment selects a target mode from one or more parameter modes supported by a camera on the electronic equipment based on parameter information of code scanning application, and specifically includes: the parameter adjustment module selects a target mode from one or more parameter modes supported by the camera based on parameter information of the code scanning application.
In a possible implementation manner, the parameter adjusting module selects a target mode from one or more parameter modes supported by the camera based on parameter information of the code scanning application, and specifically includes: the parameter adjusting module determines M first modes with the minimum difference between the aspect ratio of the resolution and the aspect ratio of the resolution in the parameter information from a plurality of parameter modes of the camera, wherein M is a positive integer.
When M is equal to 1, the parameter adjustment module determines the first mode as the target mode.
When M is larger than 1, the parameter adjusting module determines N second modes with the largest width-height product of the resolution from the M first modes, wherein N is a positive integer and is less than or equal to M.
When N is equal to 1, the parameter adjustment module determines the second mode as the target mode.
When N is larger than 1, the parameter adjusting module determines that the focusing mode is O third modes of the automatic focusing mode from the N second modes, wherein O is a positive integer and O is less than or equal to N.
When O equals 1, the parameter adjustment module determines the third mode as the target mode.
When O is larger than 1, the parameter adjusting module determines P fourth modes with the maximum frame rate value from the O third modes, wherein P is a positive integer and is less than or equal to O.
When P equals 1, the parameter adjustment module determines the fourth mode as the target mode.
When P is larger than 1, the parameter adjusting module randomly selects one parameter mode from the P fourth modes to be determined as the target mode.
Therefore, the electronic equipment can screen out the parameter mode with higher performance and obtain the image collected by the camera more quickly.
In a possible implementation manner, the electronic device includes a parameter adjusting module, and after the barcode recognition module determines that the electronic device is in a code scanning scene, the method further includes: and the bar code identification module sends the information of the current code scanning scene to the parameter adjusting module. In response to receiving the information currently in the code scanning scene, the parameter adjusting module acquires parameter information of the code scanning application. The parameter adjusting module acquires one or more parameter modes supported by a camera of the electronic equipment. The parameter adjustment module selects a target mode from one or more parameter modes supported by the camera based on parameter information of the code scanning application.
In one possible implementation, before the electronic device displays the second image, the method further includes: and the electronic equipment corrects the bar code contained in the first image to obtain a second image. In a possible implementation manner, the electronic device includes a barcode recognition module, a position adjustment module, and a barcode correction module, and the electronic device corrects a barcode included in the first image, specifically: the bar code identification module identifies that the first image comprises a bar code. The bar code identification module records the coordinates of the center point and the coordinates of the center of the bar code. And the center point coordinate, the center coordinate and the first image are sent to a position adjusting module. The position adjusting module moves an image area including the bar code in the first image to the center of a screen of the electronic equipment based on the center point coordinate and the center coordinate, and then sends the adjusted first image to the bar code correcting module. The barcode correction module converts the size of the barcode in the first image into a preset barcode size through an image conversion algorithm.
In one possible implementation, the first interface is a configureStreams interface.
In a possible implementation manner, the first interface is a configureStreams interface, and the second interface is a setcamerarecenemode interface.
In a possible implementation manner, the code scanning determination module determines that a value of a camera call parameter is a preset value, and specifically includes: the camera call parameters include a camera call parameter "modeType" and a camera call parameter "modeStatus". The preset values of the camera calling parameters are specifically as follows: if the value of the camera call parameter "modeType" indicates "code scanning mode" and the value of the camera call parameter "modeStatus" indicates "open mode", it can be determined that the current scene is a code scanning scene.
In a second aspect, the present application provides an electronic device comprising: one or more processors, a display screen, one or more memories, one or more cameras. Wherein the display screen, the one or more cameras, and the one or more memories are coupled to the one or more processors, the one or more memories being configured to store computer program code comprising computer instructions that, when executed by the one or more processors, cause the electronic device to perform the code scanning method in any of the possible implementations of any of the aspects.
In a third aspect, an embodiment of the present application provides a computer-readable storage medium, which includes computer instructions, and when the computer instructions are executed on an electronic device provided in the present application, the electronic device is caused to perform a code scanning method in any one of the possible implementation manners of the foregoing aspect.
Drawings
Fig. 1 is a schematic diagram of a hardware structure according to an embodiment of the present disclosure;
FIGS. 2A-2E are schematic diagrams of a set of code scanning scenarios provided by an embodiment of the present application;
fig. 3 is a block diagram of a module provided in an embodiment of the present application;
FIG. 4 is a schematic flow chart provided by an embodiment of the present application;
FIG. 5 is a schematic flow chart provided by an embodiment of the present application;
fig. 6 is a schematic diagram illustrating a method for acquiring a corrected barcode according to an embodiment of the present application;
fig. 7 is a flowchart illustrating a code scanning method according to an embodiment of the present disclosure.
Detailed Description
The technical solutions in the embodiments of the present application will be described in detail and clearly with reference to the accompanying drawings. In the description of the embodiments herein, "/" means "or" unless otherwise specified, for example, a/B may mean a or B; "and/or" in the text is only an association relationship describing an associated object, and means that three relationships may exist, for example, a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone.
In the following, the terms "first", "second" are used for descriptive purposes only and are not to be understood as implying or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of embodiments of the application, unless stated otherwise, "plurality" means two or more.
In the embodiment of the present application, the barcode may include a one-dimensional barcode, a two-dimensional barcode, a three-dimensional barcode, and the like. Barcodes may use several geometric shapes corresponding to binary values to represent alphanumeric information. The code scanning process can be interpreted as a process that the electronic equipment acquires a picture comprising the bar code through the camera and analyzes the bar code in the picture to obtain information represented by the bar code.
The embodiment of the application provides a code scanning method. The electronic equipment can obtain an original image through the camera based on the adjusted camera parameters by adjusting the camera focusing mode and the camera frame rate and other camera parameters of the image collected by the camera, and then the electronic equipment can process the original image to obtain a clear image comprising the corrected bar code. Therefore, a clearer and easily-recognized bar code image can be quickly obtained, and the bar code scanning speed of bar code scanning application is improved.
Fig. 1 shows a hardware structure diagram of an electronic device 100 provided in an embodiment of the present application.
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, 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, and the embodiment of the present application does not particularly limit the specific type of the electronic device.
The electronic device 100 may include a processor 101, a memory 102, a wireless communication module 103, a mobile communication module 104, an antenna 103A, an antenna 104A, a power switch 105, a sensor module 106, a focus motor 107, a camera 108, a display screen 109, and the like. Among them, the sensor module 106 may include a gyroscope sensor 106A, an acceleration sensor 106B, an ambient light sensor 106C, an image sensor 106D, a distance sensor 106E, and the like. The wireless communication module 103 may include a WLAN communication module, a bluetooth communication module, and the like. The above-mentioned portions can transmit data through a bus.
Processor 101 may include one or more processing units, such as: the processor 110 may include an Application Processor (AP), a modem processor, a Graphics Processing Unit (GPU), an Image Signal Processor (ISP), a controller, a video codec, a Digital Signal Processor (DSP), a baseband processor, and/or a neural-Network Processing Unit (NPU), etc. The different processing units may be separate devices or may be integrated into one or more processors.
The memory 102 may be used to store computer-executable program code, which may include instructions. The processor 101 executes various functional applications of the electronic device 100 and data processing by executing instructions stored in the memory 102. The memory 102 may include a program storage area and a data storage area. In particular implementations, memory 902 may include high speed random access memory and may also include non-volatile memory, such as one or more magnetic disk storage devices, flash memory devices, or other non-volatile solid state storage devices.
The wireless communication function of the electronic device 100 may be implemented by the antenna 103A, the antenna 104A, the mobile communication module 104, the wireless communication module 103, a modem processor, a baseband processor, and the like.
Antennas 103A and 104A may be used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 may be used to cover a single or multiple communication bands. Different antennas can also be multiplexed to improve the utilization of the antennas.
The mobile communication module 104 may provide a solution including 2G/3G/4G/5G wireless communication applied on 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), and the like. The mobile communication module 150 may receive the electromagnetic wave from the antenna 104A, filter, amplify, etc. the received electromagnetic wave, and transmit the filtered electromagnetic wave to the modem processor for demodulation. The mobile communication module 104 may also amplify the signal modulated by the modem processor, and convert the signal into electromagnetic waves through the antenna 104A for radiation.
The modem processor may include a modulator and a demodulator. The modulator is used for modulating a low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used for demodulating the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then passes the demodulated low frequency baseband signal to a baseband processor for processing. The low frequency baseband signal is processed by the baseband processor and then transferred to the application processor. The application processor outputs sound signals through an audio device or displays images or video through the display screen 109.
The wireless communication module 103 may provide a solution for wireless communication applied to the electronic device 100, including Wireless Local Area Networks (WLAN), Bluetooth (BT), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), Near Field Communication (NFC), Infrared (IR), and the like. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 103 receives electromagnetic waves via the antenna 103A, performs frequency modulation and filtering processing on electromagnetic wave signals, and transmits the processed signals to the processor 101. The wireless communication module 103 may also receive a signal to be transmitted from the processor 101, perform frequency modulation and amplification on the signal, and convert the signal into electromagnetic waves through the antenna 103A to radiate the electromagnetic waves.
The power switch 105 may be used to control the power supply of the power source to the electronic device 100.
The gyro sensor 106A may be used to determine a motion gesture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 about three axes (i.e., x, y, and z axes) may be determined by the gyroscope sensor 106A. The gyro sensor 106A may be used for photographing anti-shake. For example, when the shutter is pressed, the gyro sensor 106A detects a shake angle of the electronic device 100, calculates a distance to be compensated for by the lens module according to the shake angle, and allows the lens to counteract the shake of the electronic device 100 through a reverse movement, thereby achieving anti-shake. The gyro sensor 106A may also be used for navigation, somatosensory gaming scenes.
The acceleration sensor 106B may detect the magnitude of acceleration of the electronic device 100 in various directions (typically three axes). The magnitude and direction of gravity can be detected when the electronic device 100 is stationary. And can also be used for recognizing the posture of the electronic device, for example, the acceleration sensor 106B can be applied to horizontal and vertical screen switching, pedometer and other applications.
The ambient light sensor 106C is used to sense ambient light level. The electronic device 100 may adaptively adjust the brightness of the display screen 109 based on the perceived ambient light level. The ambient light sensor 106C may also be used to automatically adjust the white balance when taking a picture.
The image sensor 106D, also called a photo sensor, can convert the photo image on the photo sensing surface into an electrical signal proportional to the photo image by using the photoelectric conversion function of the photo device. The image sensor may be a Charge Coupled Device (CCD) sensor or a complementary metal-oxide-semiconductor (CMOS) sensor.
The distance sensor 106E may be used to measure distance. The electronic device 100 may measure the distance by infrared or laser. In some shooting scenarios, the electronic device 100 may utilize the distance sensor 106E to range for fast focus.
The focus motor 107 can be used for quick focusing. The electronic device 100 can control the movement of the lens by the focusing motor 107 to realize automatic focusing.
The electronic device 100 may implement a shooting function through the ISP, the camera 108, the video codec, the GPU, the display screen 109, the application processor, and the like.
The ISP is used to process the data fed back by the camera 108. For example, when a photo is taken, the shutter is opened, light is transmitted to the camera photosensitive element through the lens, the optical signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converting into an image visible to naked eyes. The ISP can also carry out algorithm optimization on the noise, brightness and skin color of the image. The ISP can also optimize parameters such as exposure, color temperature and the like of a shooting scene. In some embodiments, the ISP may be provided in the camera 108.
The camera 108 may be used to capture still images or video. An object generates an optical image through the lens and projects the optical image to the image sensor. The image sensor may convert the optical signal into an electrical signal and then pass the electrical signal to the ISP for conversion into a digital image signal. The ISP can output the digital image signal to the DSP for processing. The DSP converts the digital image signal into image signal in standard RGB, YUV and other formats. In some embodiments, the electronic device 100 may include 1 or N cameras 193, N being a positive integer greater than 1.
Video codecs are used to compress or decompress digital images. The electronic device 100 may support one or more image codecs. In this way, the electronic device 100 develops or stores pictures or videos in multiple encoding formats.
The electronic device 100 may implement display functions via the GPU, the display screen 109, and the application processor, among others. The GPU is a microprocessor for image processing, and is connected to the display screen 109 and an application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 101 may include one or more GPUs that execute program instructions to generate or alter display information.
The display screen 109 is used to display images, videos, and the like. The display screen 109 includes a display panel. The display panel may adopt a Liquid Crystal Display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (active-matrix organic light-emitting diode, AMOLED), a flexible light-emitting diode (FLED), a miniature, a Micro-oeld, a quantum dot light-emitting diode (QLED), and the like. In some embodiments, the electronic device 100 may include 1 or N display screens 109, N being a positive integer greater than 1.
It is to be understood that the illustrated structure of the embodiment of the present invention does not specifically limit the electronic device 100. In other embodiments of the present application, electronic device 100 may include more or fewer components than shown, or some components may be combined, some components may be split, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Fig. 2A-2E illustrate a set of code scanning scene diagrams provided by an embodiment of the present application.
In some possible application scenarios, the electronic device 100 may respond to a code scanning operation of a user, and after recognizing that the current code scanning scenario is, the electronic device 100 may adjust parameters such as a focusing mode and a frame rate of the camera in accordance with an environment where the device is located. Then, the electronic device 100 may obtain, through the camera, a barcode image whose definition reaches a preset threshold, and the electronic device 100 may further adjust the barcode image to a preset barcode size, and display the corrected barcode image on the display screen. Thus, the electronic device 100 can quickly obtain the image of the barcode with the clear preset barcode size, and the barcode scanning speed is increased while the success rate of barcode scanning identification is increased.
Illustratively, in the scenario shown in fig. 2A, there is a barcode 201 and an electronic device 100. Wherein, the angle of the barcode 201 is different from the angle of the screen of the electronic device 100. The electronic device 100 may display an interface 210 with a desktop, among other things. A page with application icons placed is displayed in the interface 210. Wherein the page may include a plurality of application icons (e.g., a scan code application icon 211, a set application icon, a payment application icon, a chat application icon, etc.). Optionally, a page indicator may be displayed below the page on which the application icon is placed, where the page indicator may indicate the total number of pages on the desktop and the position relationship between the currently displayed page and other pages. For example, the interface 210 of the desktop may include three pages, with the black dot in the page indicator at the far left, which may indicate that the currently displayed page is the left-most one of the three pages. Optionally, a status bar is further displayed above the page on which the application icon is placed, and the status bar may include information such as a strength indicator of the communication signal, an electric quantity value, and a time. Further optionally, there may be a tray (dock) area below the page indicator, which may include one or more tray icons (e.g., a dialing application icon, an information application icon, a contacts application icon, a camera application icon, etc.), which may remain displayed upon page switching.
Electronic device 100 may receive an input (e.g., a single click) from a user directed to code swipe application icon 211, and in response to the input, display code swipe application interface 220, as shown in fig. 2B, on a display screen of electronic device 100. The barcode scanner application 230 displays a barcode of a standard barcode size. Optionally, the electronic device 100 may also receive an input of a code scanning function of a user for a certain application (e.g., a payment application, a chat application, etc.), and in response to the input, display a corresponding code scanning interface, where content of the code scanning interface may refer to content of the code scanning application interface 220 shown in fig. 2B.
First, the electronic device 100 may, after receiving an input of the code scanning application icon 211 from a user, start a code scanning activity (activity) by the code scanning application, and send parameter information of the code scanning application to the barcode scene control unit 302 of the hardware abstraction layer through a camera function interface (e.g., configureStreams interface) of the application framework layer. The camera function interface of the application framework layer may obtain an activity name (e.g., com.saoma.captureactivity) corresponding to the activity from the activity manager through a designated interface (e.g., getTopActivity), and send the obtained activity name to the barcode scene control unit 302. Activity is a program component responsible for interaction with the user, and provides a window, button, icon, etc. for the user to interact with the electronic device 100. The user may interact with the device through an activity window (buttons, icons, etc.). The barcode scene control unit 302 of the electronic device 100 may determine whether the current scene is a code scanning scene according to the received activity name. After the electronic device 100 determines that the current scene is the code scanning scene, the electronic device 100 may further obtain a plurality of parameter modes supported by the image sensor driver. The electronic device 100 may filter the target pattern from the plurality of parameter patterns based on parameter information (e.g., resolution, frame rate, etc. of the image) provided by the code scanning application. The target mode is a parameter mode with one or more of frame rate range and resolution being optimal among all parameter modes provided by the electronic device 100. The electronic apparatus 100 may adjust a focus mode and a frame rate of the camera and the like through related driving (e.g., focus motor driving, image sensor driving, etc.) based on the target mode. Thus, the electronic device 100 can increase the speed of acquiring the picture of the camera and obtain a clearer bar code image. Since the angle of the barcode 201 in the scene is different from the angle of the screen of the electronic device 100, the angle of the barcode is different from the angle of the screen of the electronic device 100 in the image acquired by the camera of the electronic device 100.
Then, the electronic device 100 may identify the position of the barcode in the acquired image, and perform coordinate transformation to make the barcode be located at the center of the barcode scanning frame of the display screen. Then, the electronic device 100 may compare the standard barcode size preset in the memory, and map the image to make the size of the barcode in the image the same as the standard barcode size. The memory may be a read-only memory (ROM), a Random Access Memory (RAM), or the like. Finally, the electronic device 100 may display the barcode image on a display screen. As shown in fig. 2B, the electronic device 100 displays a barcode scanning application interface 220, and the barcode scanning application interface 220 displays an image including the corrected barcode 201. In this way, the barcode scanning application of the electronic device 100 can obtain the corrected clear barcode, so that the barcode scanning application can identify the barcode to obtain the barcode information.
In some possible application scenarios, the electronic device 100 may display a code swipe application interface 230 as shown in fig. 2C on a display screen of the electronic device 100 before displaying the code swipe application interface 220 as shown in fig. 2B. One frame of image acquired by the camera of the electronic device 100 is displayed in the code scanning application interface 230. Since the angle of the barcode in the scene is different from the angle of the screen of the electronic device 100, the angle of the barcode is different from the angle of the screen of the electronic device 100 in the image acquired by the camera of the electronic device 100.
Similarly, when the electronic device 100 recognizes a barcode with a smaller size, a clear barcode can be quickly obtained by the barcode scanning method provided in the embodiment of the present application, as shown in fig. 2D, when the electronic device 100 recognizes a barcode 240 with a smaller size, a barcode scanning application interface 250 can be displayed. The code scanning application interface 250 displays an image with a size larger than that of an image directly acquired by the camera. Optionally, before electronic device 100 displays code scanning application interface 250, electronic device 100 may display a code scanning application interface that includes an image obtained directly from a camera.
In one possible implementation, the electronic device 100 may obtain the brightness of the current environment, for example, by the ambient light sensor 106C or the image sensor 106D. When the electronic device 100 detects that the illumination intensity of the current environment is lower than a preset intensity (e.g., 15lux), the electronic device 100 may acquire an image of the barcode in the dim environment by reducing the frame rate, increasing the exposure, and the like.
For example, as shown in fig. 2E, when the electronic device 100 scans the barcode 261, it may be recognized that the illumination intensity of the current environment is 10lux, and the electronic device 100 determines that the current illumination intensity is lower than the preset intensity, and the electronic device 100 may decrease the frame rate, increase the exposure level, and acquire an image with the illumination intensity higher than the preset intensity. The electronic device 100 may display the code scanning application interface 270, wherein an image with higher brightness than an image directly acquired by the camera is displayed in the code scanning application interface 270.
Fig. 3 is a block diagram of an electronic device 100 according to an embodiment of the present invention.
The block diagram shows the application layer, the application framework layer, the hardware abstraction interface layer, the hardware abstraction implementation layer, the hardware driver layer, and some modules of the hardware layer of the electronic device 100.
Wherein the application layer may include a series of application packages. The application package may include applications such as a swipe code application 301, a camera, payment, short message, etc.
The application framework layer may provide an Application Programming Interface (API) and a programming framework for applications of the application layer. The application framework layer may include some predefined functions. For example, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, and the like. The application framework layer may also include an activity manager. The activity manager may obtain activity names corresponding to different activities.
The hardware abstraction interface layer may include a plurality of library modules. Wherein each module implements a set of interfaces for a particular type of hardware component. When the application framework layer requests access to the device hardware, the operating system will load the corresponding library module for that hardware.
In some application scenarios, the hardware abstraction interface layer may include a code scanner interface (not shown). The code scanning interface may be configured to transmit status information of the code scanning mode and the code scanning mode to the code scanning determination module 303.
The hardware abstraction implementation layer may include a barcode scene control unit 302, an image signal processing unit 310, a barcode image processing unit 320, a focusing module 306, and an image sensor module 307, among others.
The barcode scene control unit 302 includes a barcode scanning determination module 303, a parameter adjustment module 304, and the like.
The code scanning determination module 303 may obtain information such as an image parameter of the code scanning application, and the code scanning determination module 303 may further determine whether the current code scanning scene is present by the following method.
The method comprises the following steps: the code scan judging module 303 of the electronic device 100 may preset a preset list in a memory (e.g., ROM, RAM, etc.), wherein the preset list stores activity names of all code scan operations executed by the code scan applications. When the electronic device 100 detects that the user opens the input of the code scanning function of the code scanning application, the code scanning application may start the code scanning activity, and send the activity name and the parameter information of the code scanning application to the code scanning judgment module 303 through the interface. When the code scanning determination module 303 detects that the activity name is in the preset list, the electronic device 100 may determine that the current scene is a code scanning scene. Further, the code scanning determination module 303 may obtain an activity name of the application program performing the code scanning operation after the electronic device 100 installs a new application program each time, and store the activity name in the preset list. Alternatively, the electronic device 100 may receive a preset list including a new activity name periodically pushed by the server.
For example, fig. 4 shows a schematic flowchart provided in an embodiment of the present application. The flowchart includes specific steps of the electronic device 100 determining whether the current scene is a code scanning scene.
S401, the electronic device 100 detects that the user opens the input of the code scanning function.
After the code scanning application 301 of the electronic device 100 receives an input (e.g., an input for the code scanning application icon 211 shown in fig. 2A) for a user to open a code scanning function, the code scanning application 301 may send parameter information of the code scanning application to the barcode scene control unit 302 of the hardware abstraction layer through the camera function interface of the application framework layer. The camera function interface of the application framework layer may further obtain an activity name (e.g., com.saoma.captureactivity) corresponding to the activity through a specified interface (e.g., getTopActivity), and send the obtained activity name to the barcode scene control unit 302. The parameter information may include one or more of parameters such as resolution, frame rate, and focus mode of the image. Wherein the input of the user to turn on the code scanning function is not limited to single click, double click, long press, slide, voice input, etc.
S402, the electronic device 100 receives the activity name and the parameter information to obtain a preset list.
After receiving the activity names and the parameter information sent by the code scanning application 301, the code scanning determining module 303 of the electronic device 100 may obtain a preset list stored in the memory, where the preset list stores the activity names of all the applications providing the code scanning function for performing the code scanning operation.
S403, the electronic device 100 determines whether the activity name exists in a preset list.
The code scanning determination module 303 of the electronic device 100 may traverse the activity names stored in the preset list, and compare whether the obtained activity name of the code scanning application 301 is the same as one of the activity names in the preset list. When the code-scanning determining module 303 detects that an activity name identical to the activity name of the code-scanning application 301 exists in the preset list, it is determined that the received activity name exists in the preset list, and the code-scanning determining module 303 may determine that the current code-scanning scene exists. When the code-scanning determining module 303 detects that there is no activity name in the preset list that is the same as the activity name of the code-scanning application 301, it is determined that the received activity name is not in the preset list, and the code-scanning determining module 303 may determine that the activity name is not in the code-scanning scene.
The preset list may be in the form of an array, a list, a configuration file (e.g., xml root file, json format file, etc.), and the like. For example, the electronic device 100 stores a preset list "scanActivityList" in which a plurality of activity names corresponding to code scanning operations are stored.
scanActivityList={
"com.saoma.CaptureActivity",
"com.tencent.mm.plugin.scanner.ui.BaseScanUI",
"com.sina.weibo.qrcode.CaptureActivity",
"com.tencent.qqmusic.camerascan.view.CameraScanActivity",
"com.etao.feimagesearch.integrate.ScanPaiActivity",
……
};
For example, when the activity name received by the barcode determining module 303 is "com.
The method 2 comprises the following steps: electronic device 100 may provide a predefined code scan interface function to a code scan application (e.g., code scan application 301). When the code scanning application calls the code scanning interface function at the hardware abstraction layer through the application framework layer, the code scanning interface function may send a camera call parameter to the code scanning determination module 303. After the code scanning determination module 303 receives the camera call parameter of the interface function, the code scanning determination module 303 may determine whether the current code scanning scene is located by determining a value of the camera call parameter. When the code scan determination module 303 detects that the value of the camera call parameter is a preset value (e.g., "0 x 01" and "1"), it may be determined that the code scan scene is currently in progress. Wherein the preset value may be stored in a memory (e.g., ROM, RAM, etc.). When the code scan application calls the code scan interface at the hardware abstraction layer through the application framework layer, the code scan application sends parameter information of the code scan application to the code scan determination module 303 through a camera function interface (e.g., configureStreams interface) of the application framework layer.
In some possible application scenarios, the electronic device 100 may provide a code scanning interface function "setCameraSeremeMode". For example, the code scan interface function may be:
int setCameraSceneMode(int32_t modeType,int32_t modeStatus);
the scan code interface function parameters may include camera call parameters "modeType" and "modeStatus", among others. Among them, the camera call parameter "modeType" may represent a set mode type, for example, 0x01 represents a scan pattern, where 0x01 may be a preset value stored in a memory. The camera call parameter "modeStatus" may represent the status of a mode, e.g., 0 represents turning off the mode and 1 represents turning on the mode, where 1 may be a preset value stored in memory. When the code-scanning application calls the interface of setCameraSeremeMode, the interface function can also return the calling result to the code-scanning application.
In some application scenarios, if the code scan determining module 303 receives the camera call parameter (e.g., the parameter "modeType" and the parameter "modeStatus") passed by the interface function, the code scan determining module 303 determines whether the camera call parameter is in a code scan scenario according to the received camera call parameter. For example, if the value of the camera call parameter "modeType" is "0 x 01" and the value of the camera call parameter "modeStatus" is "1", it is determined that the current scene is a code-scanning scene. At the same time, the interface function may return a successful call result (e.g., return "0") to the code-scan application. If the value of the camera call parameter "modeType" is not "0 x 01" or the value of the camera call parameter "modeStatus" is not "1", it is determined that the current scene is not a code-scanning scene.
Further, if the interface function fails to execute, the interface function may return the result of the failed execution (e.g., return other values) to the code-scan application. Optionally, after receiving the result of the failure in invoking the interface, the code scanning application may invoke the code scanning interface again, and send the camera invocation parameter to the code scanning determination module 303. In the description of this embodiment, the value of the parameter "modeType" is "0 x 01", the value of the parameter "modeStatus" is 1, and the return value of the interface is 0, i.e., currently in a code-scanning scenario.
In the above, two possible methods for determining the code scanning scenario are shown. Without being limited to the method described in the above embodiment, the electronic device 100 may also determine whether the code scanning scene is determined in other manners.
Specifically, after the code scanning determining module 303 determines that the current code scanning scene is located, result information of the current code scanning scene and parameter information of the code scanning application may be sent to the parameter adjusting module 304.
The parameter adjustment module 304 may receive the result information in the code scanning scenario and the parameter information (first parameter information) of the code scanning application, which are sent by the code scanning determination module 303. The parameter adjustment module 304 may also obtain a plurality of parameter modes supported by the camera of the electronic device 100 through an interface (e.g., a getSensorModeList interface). Wherein the plurality of parameter patterns may be stored in the image sensor driver. The parameter adjustment module 304 may screen out a target pattern from a plurality of parameter patterns based on the first parameter information. The parameter adjustment module 304 may also send the target mode to the focusing module 306 and the image sensor module 307. Wherein, one parameter mode of the plurality of parameter modes can correspond to a group of shooting parameters. The set of capture parameters may include one or more of an image output format parameter, a focus mode parameter, a resolution parameter of the image, a frame rate parameter of the output image. The first parameter information may include one or more of image output format, focus mode, resolution, and frame rate. The image output format parameter may be used to adjust a format (e.g., RGB format, etc.) of an image output by an image signal processor of the electronic device 100, among other things. The focus mode parameter may be used to adjust a focus mode of the electronic device 100 (e.g., may be adjusted to an auto focus mode, a manual focus mode, or a fixed focus mode, etc.). The resolution parameter may be used to adjust the resolution of an image acquired by a camera of the electronic device 100. The frame rate parameter may be used to adjust a frame rate at which the camera of the electronic device 100 acquires images.
The focusing mode may include an auto focusing mode, a manual focusing mode and a fixed focusing mode. In the auto-focus mode, the electronic device 100 may adjust the focal length by an auto-focus (e.g., phase focus, contrast focus, etc.) method, and a clear image may be obtained without user operation. In the manual focus mode, the electronic device 100 may change the focal length in response to the received user operation. In the fixed focus mode, electronic device 100 may acquire images using a fixed focus value. In some possible application scenarios, for example, in a scenario where the position and the posture of the electronic device 100 are changed, the focusing speed of the phase focusing is fastest, and the electronic device 100 may set the auto-focusing mode to have the highest priority, and the focusing mode to be the next. In other possible application scenarios, for example, in a scenario where the position and the posture of the electronic apparatus 100 are kept unchanged, the fixed-focus mode is the focusing mode with the fastest focusing speed, and the electronic apparatus 100 may set the fixed-focus mode with the highest priority. In the embodiments described below, the default autofocus mode is the highest priority.
The target mode may be a parameter mode satisfying one or more requirements that the frame rate range is maximum, the product of the width and height values is maximum, the width and height ratio value is closest to the width and height ratio value of the first parameter information, and the focusing mode is an auto focusing mode among all parameter modes. Or the difference between the image aspect ratio in the target mode and the image aspect ratio in the first parameter information is minimum, and/or the product of the image aspect ratio in the target mode is larger than the product of the image aspect ratio in the first parameter information, and/or the maximum frame rate in the target mode is larger than the frame rate in the first parameter information, and/or the focusing mode in the target mode is the auto-focusing mode.
The focusing module 306 can receive the target mode sent by the parameter adjusting module 304, and adjust the focusing mode of the camera to be an automatic focusing mode (e.g., phase focusing) or manual focusing or fixed focus according to the focusing mode parameter.
The image sensor module 307 can receive the target mode issued by the parameter adjusting module 304, and adjust the frame rate of the camera according to the frame rate parameter. Optionally, the image sensor module 307 may further receive a resolution parameter of the image of the parameter adjusting module 304, and adjust the resolution of the image acquired by the camera according to the parameter.
In some application scenarios, the parameter adjustment module 304 may send the focusing mode parameter only to the focusing module 306, and may send the frame rate parameter only to the image sensor module 307.
The image signal processing unit 310 may include an image front-end processing module 311, an image back-end processing module 312, and a 3A module 313. Optionally, the image signal processing unit 310 may further include other image processing modules.
The image front-end processing module 311 may be used to correct colors of an image, reduce signal noise, optimize image brightness, perform color space conversion, and the like.
In some application scenarios, after the focusing module 306 receives the parameter sent by the parameter adjusting module 304 and drives the focusing motor IC to focus through the focusing motor based on the parameter, and the image sensor module 307 receives the parameter sent by the parameter adjusting module 304 and drives the image sensor to adjust the frame rate and the resolution through the image sensor based on the parameter, the image sensor may obtain a frame of original image, and send the obtained original image to the image front-end processing module 311 of the image signal processing unit 310.
The 3A module 313 can optimize exposure, color temperature, focus, etc. parameters of the scene being photographed. The 3A module 313 may further obtain the image output by the image front-end module 311, and detect the definition of the image, and when the 3A module 313 detects that the definition of the current image is lower than the preset threshold, adjust parameters such as the focal length and the frame rate, and send the adjusted parameters to the focusing module 306 and the image sensor module 307.
The image back-end processing module 312 may be used to further optimize the quality of the image output by the front-end processing module, including image dead pixel removal, detail enhancement, HDR processing, and the like. For example, the image back-end processing module 312 may acquire and optimize the image output by the image front-end module 311.
Other image processing modules may be used to optimize image quality, e.g., beauty, background blurring, motion detection, scene detection, etc. Alternatively, other image processing modules may process the image output by the image front-end processing module 311 or the image output by the image back-end processing module 312.
The barcode image processing unit 320 may include a barcode recognition module 321, a position adjustment module 322, and a barcode correction module 323. The barcode recognition module 321 may recognize whether a barcode is included in a frame of image and coordinate information of the barcode by using an image recognition algorithm (e.g., a convolutional neural network algorithm). The position adjustment module 322 may adjust the barcode at the edge position of the image to the center position of the screen. The barcode correction module 323 may adjust the size of the barcode in the image according to a preset barcode size using an image transformation algorithm (e.g., an affine transformation algorithm, a perspective transformation algorithm).
The hardware driver layer is a layer between hardware and software. The hardware driving layer includes at least a focus motor drive, an image sensor drive, an image signal processor drive, and the like. The electronic device may communicate through the driver and hardware.
The hardware layer may include a variety of hardware devices. Such as a lens, a focus motor Integrated Circuit (IC), an image sensor, an image signal processor, and the like. The focusing motor IC can move the lens to focus.
It is to be understood that the embodiment shown in fig. 3 described above does not constitute a specific limitation to the electronic device 100. In other embodiments of the present application, electronic device 100 may include more or fewer levels than shown, or combine some levels, or split some levels, or a different arrangement of levels. The illustrated hierarchy may be implemented in hardware, software, or a combination of software and hardware.
A flow chart of a code scanning method provided in the embodiment of the present application is described below.
For example, fig. 7 shows a flowchart of a code scanning method provided in an embodiment of the present application, where the method includes the following steps:
s701, the electronic device 100 receives an input (also referred to as a first input) for a code scanning application.
The code scanning application of the electronic device 100 may receive a first input by a user for the code scanning application. The first input is an input to open a code scanning application, for example, the first input may be an input to the code scanning application icon 201 shown in fig. 2A. The first input may also be an input to open a code scanning function of an application, for example, the first input may be an input to a code scanning function of a payment-class application. The code scanning application may start the code scanning activity after receiving the first input of the user, and send parameter information of the code scanning application to the code scanning determination module 303 of the barcode scene control unit 302 of the hardware abstraction layer through a camera function interface (e.g., a configureStreams interface) of the application framework layer. The camera function interface of the application framework layer may further obtain an activity name (e.g., com.saoma.captureactivity) corresponding to the activity from the activity manager through a specified interface (e.g., getTopActivity), and send the obtained activity name to the barcode scanning determination module 303 of the barcode scene control unit 302. The code scanning application may be a separate application program (e.g., the application program corresponding to the code scanning application icon 211 shown in fig. 2A) that only provides the code scanning function, or may be a service component integrated in an application (e.g., the code scanning function in the chat-type application) that provides the code scanning function.
S702, the electronic device 100 determines that the code scanning scene is currently located.
After receiving the activity name and the first parameter information, the code scanning determining module 303 of the electronic device 100 may determine whether the current code scanning scene is located, and when the electronic device 100 detects that the current code scanning scene is located, the code scanning determining module 303 may execute step S703 after sending the first parameter information applied by code scanning to the parameter adjusting module 304. If the electronic device 100 detects that the electronic device is not currently in the code scanning scene (i.e., is currently in the photographing scene), the electronic device 100 may acquire and display an image acquired by the camera based on the parameter information issued by the code scanning application. Here, the electronic apparatus 100 determines that it is currently in a code scanning scene. The determination process of the electronic device 100 may refer to the operation performed by the code scanning determination module 303 described in fig. 3, which is not described herein again.
S703, after receiving the first parameter information, the electronic device 100 may obtain a plurality of parameter modes supported by the camera, and filter a target mode from the plurality of parameter modes according to the first parameter information.
For example, the parameter patterns may be stored in the image sensor driver. After receiving the first parameter information sent by the code scanning determining module 303, the parameter adjusting module 304 of the electronic device 100 may drive the image sensor to obtain a plurality of parameter modes supported by the camera, and then traverse all the obtained parameter modes to obtain the target mode.
In a possible implementation manner, the electronic device 100 may filter the target mode from all the acquired parameter modes by using one or more of parameters such as the focusing mode, the resolution of the image, the frame rate, and the like as the determination conditions. When the resolution of the image is used as the determination condition, it may be set as the product of the aspect ratio of the image and the aspect ratio of the image. The electronic device 100 may set priorities for the plurality of parameters described above. First, the electronic device 100 may determine the quality of the parameter with the highest priority in the plurality of parameter modes, and keep the parameter mode with the highest priority in the plurality of parameter modes that is the best. If only the highest priority parameter of one parameter pattern is optimal among the plurality of parameter patterns, the parameter pattern may be referred to as a target pattern. If the parameter with the highest priority in at least two parameter modes is optimal, the parameter mode with the highest priority in the parameter modes is continuously screened out, and the like is repeated until one parameter mode is left, wherein the parameter mode can be called as a target mode. And if at least two parameter modes are reserved after all the parameters are screened, selecting the parameter mode which is traversed firstly as the target mode. Alternatively, a parameter pattern may be randomly selected as the target pattern.
For the parameter of the focusing mode, the electronic device 100 may screen out a parameter mode with an optimal focusing mode from the multiple parameter modes according to a criterion that the auto-focusing mode is better than the fixed-focusing mode and the fixed-focusing mode is better than other focusing modes. In this case, for the parameter of the resolution of the image, the electronic apparatus 100 may obtain a difference between a ratio of the width to the height of the image in the plurality of parameter modes and a ratio of the width to the height of the image in the first parameter information, and set the determination condition to be the most suitable parameter mode among the plurality of parameter modes, in which the parameter mode with the smallest difference is the most suitable parameter mode. The electronic apparatus 100 may further acquire, for the parameter of the resolution of the image, a product value of width and height values of the image in the plurality of parameter modes, and set the determination condition to be optimal for a mode in which the product value is largest in the plurality of parameter modes. The electronic apparatus 100 may also determine that the mode with the largest width value and the largest height value is optimal with respect to the parameter of the resolution of the image. The electronic apparatus 100 may set the determination condition to be optimal for the frame rate of the output image in a mode in which the frame rate value provided by the first parameter information is the maximum while the maximum frame rate is within the range of the frame rate provided by the parameter mode. Or the electronic apparatus 100 may set the determination condition to be optimal for the mode with the largest frame rate among the plurality of parameter modes. Meanwhile, the electronic device 100 may further set the aspect ratio of the image to have a higher priority than the product of the aspect ratio of the image, the aspect ratio of the image to have a higher priority than the focusing mode, and the focusing mode to have a higher priority than the frame rate.
In a possible implementation manner, when the first parameter information includes a focusing mode parameter, the parameter adjusting module 304 may adjust the determination condition of the focusing mode parameter to be the optimal focusing mode specified by the focusing mode parameter in the first parameter information.
The priority of the parameter set by the electronic device 100 is not limited to the above, the criterion for determining the optimal parameter by the electronic device 100 is not limited to the above, and both the priority of the parameter and the criterion for determining the optimal parameter may be adjusted accordingly according to the actual application scenario. For example, the electronic device 100 may only filter a mode with an optimal parameter as the target mode. Or, a mode in which some two parameters are optimal is taken as an optimal mode, and the like. Alternatively, the electronic device 100 may filter out a parameter pattern that satisfies the numerical requirement of the parameter in the first parameter information as the target pattern.
For example, fig. 5 shows a schematic flowchart provided in an embodiment of the present application. The flowchart includes steps for the electronic device 100 to obtain the target mode. The steps in the flowchart may be performed by the parameter adjustment module 304. Among them, the electronic apparatus 100 may set the frame rate determination condition to be optimal for the mode in which the value of the maximum frame rate is the maximum among the plurality of parameter modes. The flow chart comprises the following steps:
s501, the electronic device 100 obtains parameter information (also called as first parameter information) of the code scanning application.
Specifically, the parameter information may include information of a width of an image, a height of an image, a focus mode, a minimum frame rate, a maximum frame rate, a format of an image, and the like.
S502, the electronic device 100 obtains all parameter modes supported by the camera, sets N to be the number of parameter modes, sets i to 1, and sets the target mode to be the ith parameter mode.
Hereinafter, a code example of all parameter modes of the electronic device 100 is shown.
Figure BDA0003047734730000131
Figure BDA0003047734730000141
Figure BDA0003047734730000151
Here, the parameter "image _ type" represents a format of an image output by the camera, and here, the format of the image may be a Bayer format (e.g., BGGR, RGGB, etc.) or a YUV type format (e.g., UYY, YUYV, etc.), or the like. The parameter "width" represents a width value of an image output by the camera, and the parameter "height" represents a height value of the image output by the camera, where the unit of the width value and the height value may be a pixel. The parameter "min _ fps" represents the minimum number of image frames per second that the electronic apparatus 100 can output, and the parameter "max _ fps" represents the maximum number of image frames per second that the electronic apparatus 100 can output. The parameter "is _ pdf _ supported" indicates whether the electronic apparatus 100 supports phase focusing. The parameter "settings" may include configuration parameters issued by the schema. When the camera is required to work in the mode, the setting needs to be sent to the hardware of the camera through a hardware bus interface. Where "reg" is a register of the camera hardware. "data" is the value written to the register. "delay" represents the waiting time after completion of writing.
S503, the electronic apparatus 100 determines that i < N.
The electronic device 100 may determine whether all the parameter patterns have been traversed, and if the electronic device 100 determines that the value of i is less than N, which indicates that the electronic device 100 has not compared all the parameter patterns, execute step S504. If the electronic device 100 determines that the value of i is greater than or equal to N, which indicates that the electronic device 100 has traversed all the parameter patterns, step S515 is performed.
S504, the electronic apparatus 100 executes i ═ i + 1.
The electronic device 100 updates the value of i each time after executing the determining step S503, i.e. performs an operation of adding 1 to the value of the variable i each time.
S505, the electronic device 100 acquires the ith parameter mode.
S506, the electronic device 100 determines whether the aspect ratio of the target mode is closer to the aspect ratio of the first parameter information than the ith parameter mode.
The electronic device 100 may calculate the aspect ratio of the ith mode, the first aspect ratio of the target mode, and the aspect ratio of the first parameter information. The electronic apparatus 100 may calculate an absolute value of a difference between the aspect ratio of the target mode and the aspect ratio of the first parameter information (may be referred to as a first difference), and may calculate an absolute value of a difference between the aspect ratio of the ith mode and the aspect ratio of the first parameter information (may be referred to as an ith difference). The electronic device 100 may compare the magnitudes of the two ratios, and if the first difference is smaller than the ith difference (it may also be understood that the aspect ratio of the target pattern is closer to the aspect ratio of the first parameter information than the ith parameter pattern), go back to step S503 directly. If the first difference is greater than or equal to the ith difference, step S507 is executed.
S507, the electronic device 100 determines whether the aspect ratio of the ith parameter mode is closer to the aspect ratio of the first parameter information than the target mode.
The electronic device 100 determines that the ith difference is smaller than the first difference (it can also be understood that the aspect ratio of the ith parameter mode is closer to the aspect ratio of the first parameter information than the target mode), and performs step S514. The electronic device 100 determines that the ith difference is not less than the first difference, and performs step S508.
S508, the electronic device 100 judges whether the product of the width and the height of the target mode is larger than the ith parameter mode.
The electronic device 100 may calculate a product of the width and height of the target pattern (which may be referred to as a first product) and the width and height of the ith pattern (which may be referred to as an ith product). The electronic device 100 may compare the magnitudes of the two ratios, and if the first product is greater than the ith product (it may also be understood that the product of the width and height values of the target pattern is greater than the ith parameter pattern), perform step S503. If the first product is less than or equal to the ith product, step S509 is performed.
S509, the electronic device 100 determines whether the width and height values of the ith parameter mode are greater than the target mode.
The electronic device 100 determines that the ith product is greater than the first product (i.e., the width and height values of the ith parameter mode are greater than the target mode), then step S514 is executed. The electronic device 100 determines that the ith product is not greater than the first product, and performs step S510.
S510, the electronic device 100 judges that the focusing mode of the target mode is better than the ith parameter mode.
If the electronic device 100 detects that the focusing mode in the target mode is auto-focusing and the focusing step in the ith parameter mode detected by the electronic device 100 is not auto-focusing, the electronic device 100 determines that the focusing mode in the target mode is better than the ith parameter mode, and returns to step S503.
If the electronic device 100 detects that the focusing modes of the target mode and the ith parameter mode are both auto-focusing, or if the electronic device 100 detects that the focusing modes of the target mode and the ith parameter mode are not auto-focusing, or detects that the target mode is not auto-focusing and the ith parameter mode is auto-focusing, step S511 is executed.
S511, the electronic device 100 determines whether the focusing mode and the target mode of the ith parameter mode are the same.
The electronic device 100 detects that the focusing mode of the i-th parameter mode is the same as the focusing mode of the target mode, and executes step S512. The electronic device 100 detects that the focusing mode of the ith parameter mode is different from the focusing mode of the target mode, that is, the electronic device 100 detects that the target mode is not autofocus and the ith parameter mode is autofocus, then step S512 is executed.
S512, the electronic device 100 determines that the maximum frame rate of the target mode is greater than the ith parameter mode.
If the electronic device 100 detects that the maximum frame rate of the target mode is greater than the maximum frame rate of the ith parameter mode, step S503 is executed. If the maximum frame rate of the target mode is less than or equal to the ith parameter mode maximum frame rate, step S513 is executed.
S513, the electronic device 100 determines that the maximum frame rate of the target mode is less than the i-th parameter mode?
If the electronic device 100 detects that the maximum frame rate of the target mode is less than the maximum frame rate of the ith parameter mode, step S514 is executed. If the electronic device 100 detects that the maximum frame rate of the target mode is not less than the maximum frame rate of the ith parameter mode, step S503 is executed.
S514, the electronic device 100 records the ith parameter mode as the target mode.
The electronic apparatus 100 updates the value of the target mode to the value of the ith parameter mode.
S515, the electronic device 100 obtains the target mode.
For example, the first parameter information acquired by the electronic device 100 may be 1280 pixels in image width, 720 pixels in image height, and 30fps in frame rate. In the parametric mode shown above, the target mode may be initialized to "mode 0", the value of N to 4, and the value of i to 1.
The electronic device 100 determines that the value of i is less than N and updates the value of i to 2. The electronic device 100 obtains the value of the 2 nd parameter mode (mode1), obtains that the aspect ratio of the 2 nd parameter mode is the same as the target mode, and updates the target mode to be "mode 1" when the product of the aspect ratio of the 2 nd parameter mode is larger than the target mode.
The electronic device 100 determines that the value of i is less than N and updates the value of i to 3. The electronic device 100 obtains the value of the 3 rd parameter mode (mode2), obtains that the aspect ratio value of the 3 rd parameter mode is closer than that of the target mode, and updates the target mode to be "mode 2".
The electronic device 100 determines that the value of i is less than N and updates the value of i to 4. The electronic device 100 obtains the value of the 4 th parameter mode (mode3), and obtains that the aspect ratio of the 4 th parameter mode is the same as the target mode, the product of the aspect ratio of the 4 th parameter mode is the same as the target mode, the focusing mode of the 4 th parameter mode is the same as the target mode, and the maximum frame rate of the 4 th parameter mode is smaller than the target mode.
The electronic device 100 determines that the value of i is equal to N, resulting in a target mode of "mode 2". In this way, the electronic device 100 may determine the target mode most suitable for the code scanning scene according to the width-to-height ratio, the product of the width and the height, the focusing mode, and the priority order of the maximum frame rate.
S704, the electronic device 100 acquires a first image through a camera based on the shooting parameter corresponding to the target mode.
The parameter adjustment module 304 of the electronic device 100 may send the shooting parameters of the target mode to the focusing module 306 and the image sensor module 307. The focusing module 306 can adjust the focusing motor IC to focus according to the focusing mode parameter. The image sensor module 307 may adjust the image sensor for image acquisition according to the resolution parameter and the frame rate parameter. The electronic device 100 may obtain an original image obtained by the image sensor and transmit the image to the image signal processing unit 310, and the image front-end processing module 311 and the image back-end processing module 312 of the image signal processing unit 310 may process the original image obtained by the image sensor to obtain the first image. For example, the content of the first image may refer to the swipe code application interface 220 shown in FIG. 2B. Alternatively, the first image may be displayed on a display screen of the electronic device 100. Here, the electronic apparatus 100 does not display the first image.
Thereafter, the image signal processing unit 310 may transmit the first image to the barcode image processing unit 320.
Alternatively, the 3A module 313 may acquire the image output by the image front-end processing module 311, and determine whether the sharpness of the image is greater than or equal to a preset threshold. When the 3A module 313 determines that the sharpness of the image is smaller than the preset threshold, the focusing mode parameter, the resolution parameter, and the frame rate parameter may be adjusted and sent to the focusing module 306 and the image sensor module 307. The electronic device 100 may re-acquire one frame of the original image through the image sensor and send the frame of the original image to the image signal processing unit 310 until the 3A module 313 determines that the sharpness of the image is greater than or equal to the preset threshold.
S705, the electronic device 100 may adjust the position and size of the barcode in the first image to obtain a second image.
After the barcode image processing unit 320 of the electronic device 100 obtains the first image, the barcode recognition module 321 may recognize the barcode region of the first image through an image recognition algorithm, and the position adjustment module 322 may transform the center coordinate of the barcode to the center of the screen. Finally, the barcode correction module 323 can convert the size of the barcode into a preset barcode size through an image conversion algorithm. To this end, the electronic device 100 obtains a second image, where the second image includes the transformed barcode.
Specifically, in some application scenarios, the barcode recognition module 321 may acquire an image output by the image back-end processing module 312, and recognize whether the image includes a barcode. When the barcode recognition module 321 recognizes that the barcode is included in the image, the coordinates of the center point of the barcode and the coordinates of the center of the screen (also called center coordinates) may be recorded. And sends the center point coordinates, the center coordinates, and the image to the position adjustment module 322. The position adjustment module 322 may move the image area including the barcode to the center of the screen according to the center point coordinates and the center coordinates, i.e., transform the center point coordinates to the center coordinates. The position adjustment module 322 may also scale and crop the image gracefully. The position adjustment module 322 may send the image subjected to the position conversion to the barcode correction module 323. The barcode correction module 323 may convert the size of the barcode in the image into a preset barcode size through an image conversion algorithm. The preset barcode size may be a standard barcode size, and the preset barcode size may be stored in the ROM.
Optionally, the barcode recognition module 321 may obtain coordinates of a center of a barcode scanning frame of the barcode scanning application, and send the coordinates of the center of the barcode scanning frame to the position adjustment module 322, and the position module 322 may scale and transform the coordinates of the center point of the barcode and the coordinates of the center of the barcode scanning frame to the coordinates of the center of the barcode scanning frame.
A schematic diagram of a method for acquiring a corrected barcode provided in an embodiment of the present application is described below.
For example, as shown in fig. 6, in some possible application scenarios, during image acquisition, due to a difference between a position and a posture of the electronic device 100, a barcode image acquired by the electronic device 100 may be rotated and scaled, so that the electronic device 100 cannot recognize barcode information. Therefore, the electronic device 100 needs to correct the captured barcode image. The electronic device 100 can acquire a barcode image of a standard size through the following several steps.
(1) The barcode region is identified.
The electronic apparatus 100 may acquire one frame of image output from the image signal processing unit 310. The electronic apparatus 100 searches for an image area including the barcode in the image by the feature of the barcode while recording the center point coordinates (x1, y1) of the barcode and the center coordinates O (x0, y0) of the screen.
(2) And adjusting the position of the bar code.
The electronic apparatus 100 adjusts the position of the image area including the barcode to the center of a coordinate system having the center coordinates of the screen as the origin according to the center coordinates of the barcode. Thus, the coordinates of the center point of the barcode are transformed from (x1, y1) to (x0, y 0). Meanwhile, the electronic device 100 can also perform appropriate scaling and cropping on the barcode image.
(3) And correcting the bar code.
The electronic device 100 may transform and map the barcode through an image transformation algorithm (e.g., an affine transformation algorithm, a perspective transformation algorithm) to obtain an image of the barcode including a standard barcode size.
S706, the electronic device 100 may display the second image.
The code scanning application of the electronic device 100 may display the second image. Illustratively, the content of the second image may be referenced to a swipe code application interface 230, such as FIG. 2C.
S707, the electronic device 100 may identify barcode information corresponding to the barcode in the second image.
The electronic device 100 may recognize the barcode in the second image to obtain a corresponding bitstream, and obtain barcode information corresponding to the barcode through the bitstream.
S708, the electronic device 100 may perform a first operation based on the barcode information.
The electronic device 100 may determine the type of the barcode information and perform a corresponding operation. If the barcode information is text information, the first operation may be to display the barcode information on the electronic device 100. If the barcode information is a page link, the first operation may be to display a page corresponding to the page link (for example, a page to which a friend is added, a page to which payment is paid, and the like). In some possible application scenarios, the electronic device 100 fails to recognize the barcode, and the electronic device 100 may display a prompt for the failure to scan the barcode.
Alternatively, the electronic device 100 may display the first image before displaying the second image.
In a possible implementation manner, the electronic device 100 may perform the determination of the code scanning scene through the barcode recognition module 321. When the barcode recognition module 321 recognizes that the image collected by the camera includes the barcode through the image recognition algorithm, it is determined that the camera is currently in the code scanning scene. When the barcode recognition module 321 recognizes that the image does not include a barcode, it is determined that the image is not currently in a code scanning scene.
Specifically, the electronic device 100 may, after receiving an input to turn on the code scanning function by the user, the code scanning application may call a camera interface (e.g., a configurable streams interface) to transfer the first parameter information to the focusing module 306 and the image sensor module 307 of the hardware abstraction layer. Wherein the first parameter information may be stored in a hardware abstraction implementation layer. After the focusing module 306 drives the focusing motor IC to focus through the focusing motor and the image sensor module 307 drives the image sensor 307 to adjust the frame rate, the image obtained by the image sensor can be sent to the image signal processing unit 310. After the image front-end processing module 311 and the image back-end processing module 312 of the image signal processing unit process the image, the processed image may be sent to the barcode recognition module 321. The barcode recognition module 321 receives the image output by the image back-end processing module 312, and can recognize whether the image includes a barcode through an image recognition algorithm. If the barcode recognition module 321 recognizes that the image includes a barcode, it is determined that the image is a scanned scene, and the barcode recognition module 321 may send the result to the parameter adjustment module 304. The parameter adjustment module 304 may extract first parameter information that is temporarily stored in the hardware abstraction layer, and simultaneously acquire a plurality of parameter modes supported by the camera from the image sensor driver. The parameter adjustment module 304 may filter the target pattern from the plurality of parameter patterns based on the first parameter information. The step of the parameter adjusting module 304 acquiring the target pattern and the subsequent step of correcting the barcode may refer to the embodiment described in fig. 7, which is not described herein again.
Optionally, the parameter adjustment module 304 may further obtain the first parameter information through a specific interface (e.g., getAppConfiguration interface).
In one possible implementation, after the electronic device 100 detects the code scanning scene, the electronic device 100 may scan the code using the auto-focus mode. Meanwhile, the electronic apparatus 100 may determine whether the position or the posture of the electronic apparatus 100 in the three-dimensional space is changed at intervals of a preset time (e.g., 1ms) (e.g., the electronic apparatus 100 may detect whether the position and the posture of the electronic apparatus 100 are changed by the gyro sensor 106A and the acceleration sensor 106B). If the electronic device 100 detects that the time for which the position and the posture of the electronic device 100 in the three-dimensional space remain unchanged exceeds the preset time, recording the current focal length of the camera, and executing code scanning operation by using a fixed-focus mode. In the fixed focus mode, the electronic apparatus 100 may switch to another focus mode (e.g., an auto focus mode) supported by the electronic apparatus 100 in response to an operation of the user to switch the focus mode. Alternatively, when the electronic device 100 detects that an image with a barcode cannot be recognized within a preset time (e.g., 2S), or when the electronic device 100 fails to recognize the barcode, the electronic device 100 may switch the focusing mode to the auto-focusing mode. In this way, the electronic device 100 can reasonably configure the focusing mode, and is suitable for a code scanning scene requiring a fixed focal length. For example, the electronic device 100 may act as a barcode scanner, sequentially identifying barcodes for a plurality of items.
In one possible implementation, the parameter adjusting module 305 of the electronic device 100 may further obtain an ambient illumination intensity of an environment where the electronic device 100 is located (for example, obtain an illumination intensity of a current environment through the ambient light sensor 106C or the image sensor 106D), and when the electronic device 100 detects that the illumination intensity is lower than a preset intensity (for example, 15lux), the electronic device 100 may obtain a preset low-luminance frame rate (for example, 20fps), and simultaneously send the preset low-luminance frame rate to the image sensor module 307. Among them, the preset low luminance frame rate may be stored in a memory (e.g., ROM, RAM, etc.).
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

Claims (17)

1. A code scanning method is applied to an electronic device installed with a code scanning application, and comprises the following steps:
after receiving code scanning input of a user for code scanning application, the electronic equipment determines that the electronic equipment is in a code scanning scene;
the electronic equipment selects a target mode from one or more parameter modes supported by a camera on the electronic equipment based on parameter information of the code scanning application, wherein the parameter information comprises one or more of resolution, frame rate and focusing mode;
the electronic equipment acquires a first image based on shooting parameters corresponding to the target mode, wherein the first image comprises a bar code;
and the electronic equipment displays a second image, wherein the second image comprises the corrected bar code.
2. The method of claim 1, wherein the electronic device includes a scan determination module, and after receiving a scan input from a user for a scan application, the method further comprises:
the code scanning application starts code scanning activity;
and the code scanning application sends the parameter information of the code scanning application to the code scanning judgment module.
3. The method of claim 2, wherein the electronic device includes an activity manager, and after the scan application starts the scan activity, the method further comprises:
the activity manager acquires an activity name of the scanning code activity;
and the activity manager sends the activity name to the code scanning judgment module.
4. The method according to claim 3, wherein the determining that the electronic device is in a code scanning scenario specifically includes:
after receiving the activity name of the code scanning activity, a code scanning judgment module of the electronic equipment acquires a preset list, wherein the preset list stores all activity names for executing code scanning operation by all applications providing a code scanning function;
when the code scanning judgment module determines that the preset list comprises the activity name of the code scanning activity, the code scanning judgment module determines that the electronic equipment is in a code scanning scene.
5. The method of any one of claims 2-4, wherein the code scanning application sends parameter information of the code scanning application to the code scanning determination module through a first interface.
6. The method of claim 1, wherein the electronic device includes a scan determination module, and after receiving a scan input from a user for a scan application, the method further comprises:
the code scanning application sends a camera calling parameter to the code scanning judgment module through a second interface, the code scanning application sends the parameter information to the code scanning judgment module through a first interface, and the second interface is different from the first interface;
the electronic device determines that the electronic device is in a code scanning scene, and specifically includes:
after the code scanning judgment module receives the camera calling parameter sent by the code scanning application through the second interface, the code scanning judgment module determines that the value of the camera calling parameter is a preset value, and the code scanning judgment module determines that the electronic equipment is in a code scanning scene.
7. The method of claim 1, wherein the electronic device includes a barcode identification module, and wherein after receiving a scan input from a user for a scan application, the method further comprises:
the electronic equipment responds to the code scanning input and acquires a third image;
the electronic device determines that the electronic device is in a code scanning scene, and specifically includes:
when the barcode recognition module recognizes that the third image comprises the barcode, the barcode recognition module determines that the electronic equipment is in a barcode scanning scene.
8. The method according to any one of claims 2-6, wherein the electronic device includes a parameter adjustment module, and the code scanning determination module determines that the electronic device is in a code scanning scenario, the method further comprising:
the code scanning judgment module sends the information of the current code scanning scene and the parameter information of the code scanning application to the parameter adjustment module;
in response to receiving the parameter information of the code scanning application, the parameter adjusting module acquires one or more parameter modes supported by a camera of the electronic equipment;
the electronic device selects a target mode from one or more parameter modes supported by a camera on the electronic device based on the parameter information of the code scanning application, and specifically includes:
the parameter adjustment module selects a target mode from one or more parameter modes supported by the camera based on parameter information of the code scanning application.
9. The method of claim 8, wherein the parameter adjustment module selects a target mode from one or more parameter modes supported by the camera based on the parameter information of the code scanning application, and specifically comprises:
the parameter adjusting module determines M first modes with the minimum difference between the aspect ratio of the resolution and the aspect ratio of the resolution in the parameter information from a plurality of parameter modes of the camera, wherein M is a positive integer;
when M is equal to 1, the parameter adjustment module determines the first mode as the target mode;
when M is larger than 1, the parameter adjusting module determines N second modes with the largest width-height product of the resolution from the M first modes, wherein N is a positive integer and is less than or equal to M;
when N is equal to 1, the parameter adjustment module determines the second mode as the target mode;
when N is larger than 1, the parameter adjusting module determines that the focusing mode is O third modes of the automatic focusing mode from the N second modes, wherein O is a positive integer and O is less than or equal to N;
when O is equal to 1, the parameter adjustment module determines the third mode as the target mode;
when O is larger than 1, the parameter adjusting module determines P fourth modes with the maximum frame rate value from the O third modes, wherein P is a positive integer and is less than or equal to O;
when P is equal to 1, the parameter adjustment module determines the fourth mode as the target mode;
when P is larger than 1, the parameter adjusting module randomly selects one parameter mode from the P fourth modes to determine the parameter mode as the target mode.
10. The method of claim 7, wherein the electronic device comprises a parameter adjustment module, and the barcode recognition module determines that the electronic device is in a code scanning scenario, the method further comprising:
the bar code identification module sends the information of the current code scanning scene to the parameter adjustment module;
in response to receiving the information currently in the code scanning scene, the parameter adjusting module acquires parameter information of the code scanning application;
the parameter adjusting module acquires one or more parameter modes supported by a camera of the electronic equipment;
the parameter adjustment module selects a target mode from one or more parameter modes supported by the camera based on parameter information of the code scanning application.
11. The method of claim 1, wherein before the electronic device displays the second image, the method further comprises:
and the electronic equipment corrects the bar code contained in the first image to obtain a second image.
12. The method according to claim 11, wherein the electronic device includes a barcode recognition module, a position adjustment module, and a barcode correction module, and the electronic device corrects the barcode included in the first image, specifically:
the bar code identification module identifies that the first image comprises a bar code;
the bar code identification module records the coordinates of the center point and the coordinates of the center of the bar code;
the bar code identification module sends the center point coordinate, the center coordinate and the first image to the position adjustment module;
the position adjusting module moves an image area including a bar code in the first image to the center of a screen of the electronic equipment based on the central point coordinate and the central coordinate, and then sends the adjusted first image to the bar code correcting module;
and the bar code correction module converts the size of the bar code in the first image into a preset bar code size through an image conversion algorithm.
13. The method of claim 5, wherein the first interface is a configureStreams interface.
14. The method of claim 6, wherein the first interface is a configureStreams interface and the second interface is a setCameraSemeneMode interface.
15. The method according to claim 6 or 14, wherein the code scanning determination module determines that the value of the camera call parameter is a preset value, and specifically comprises:
the camera call parameters include a camera call parameter "modeType" and a camera call parameter "modeStatus"; the preset values of the camera calling parameters are specifically as follows: if the value of the camera call parameter "modeType" indicates "code scanning mode" and the value of the camera call parameter "modeStatus" indicates "open mode", it can be determined that the current scene is a code scanning scene.
16. An electronic device, comprising: one or more processors, a display screen, one or more memories, one or more cameras; wherein the display screen, the one or more cameras, one or more memories coupled with the one or more processors, the one or more memories for storing computer program code, the computer program code comprising computer instructions that, when executed by the one or more processors, cause the electronic device to perform the method of any of claims 1-15.
17. A computer-readable storage medium comprising instructions that, when executed on an electronic device, cause the electronic device to perform the method of any of claims 1-15.
CN202110477843.0A 2021-04-29 2021-04-29 Code scanning method and device Active CN113919382B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110477843.0A CN113919382B (en) 2021-04-29 2021-04-29 Code scanning method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110477843.0A CN113919382B (en) 2021-04-29 2021-04-29 Code scanning method and device

Publications (2)

Publication Number Publication Date
CN113919382A true CN113919382A (en) 2022-01-11
CN113919382B CN113919382B (en) 2023-04-28

Family

ID=79232688

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110477843.0A Active CN113919382B (en) 2021-04-29 2021-04-29 Code scanning method and device

Country Status (1)

Country Link
CN (1) CN113919382B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115081467A (en) * 2022-07-22 2022-09-20 深圳市成为信息股份有限公司 Method for collecting original image by handset, handset and storage medium
CN115079886A (en) * 2022-07-21 2022-09-20 荣耀终端有限公司 Two-dimensional code recognition method, electronic device, and storage medium
CN116341586A (en) * 2023-02-27 2023-06-27 荣耀终端有限公司 Code scanning method, electronic equipment and storage medium
CN116709017A (en) * 2022-09-26 2023-09-05 荣耀终端有限公司 Code scanning method and electronic equipment
WO2024055817A1 (en) * 2022-09-15 2024-03-21 荣耀终端有限公司 Code scanning method and electronic device

Citations (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102790862A (en) * 2012-07-30 2012-11-21 成都西可科技有限公司 Method for dynamically improving effect of cell phone front camera
CN104008361A (en) * 2014-06-16 2014-08-27 北京握奇智能科技有限公司 Two-dimensional code scanning, locating and prompting method and system
US20160203352A1 (en) * 2013-09-20 2016-07-14 Flashback Survey, Inc. Using scanable codes to obtain a service
CN106407868A (en) * 2016-08-26 2017-02-15 乐视控股(北京)有限公司 Two-dimensional scanning processing method and mobile terminal
CN109214225A (en) * 2018-07-04 2019-01-15 青岛海信移动通信技术股份有限公司 A kind of scan method, device, mobile terminal and the storage medium of figure bar code
WO2019041324A1 (en) * 2017-09-01 2019-03-07 深圳传音通讯有限公司 Shooting frame rate selection method for terminal, terminal, and computer readable storage medium
CN109670362A (en) * 2017-10-16 2019-04-23 上海商米科技有限公司 Bar code scanning method and device
CN109725699A (en) * 2017-10-20 2019-05-07 华为终端(东莞)有限公司 Recognition methods, device and the equipment of identification code
CN110059518A (en) * 2019-04-22 2019-07-26 广东小天才科技有限公司 A kind of barcode scanning method, device and mobile terminal
CN110378165A (en) * 2019-05-31 2019-10-25 阿里巴巴集团控股有限公司 Two-dimensional code identification method, two dimensional code fixation and recognition method for establishing model and its device
CN110738067A (en) * 2019-09-30 2020-01-31 百富计算机技术(深圳)有限公司 Method and device for improving code scanning efficiency
CN110765799A (en) * 2019-10-21 2020-02-07 高新兴科技集团股份有限公司 Client code scanning identification method, device, equipment and storage medium
CN111008540A (en) * 2019-11-29 2020-04-14 联想(北京)有限公司 Bar code identification method and equipment and computer storage medium
CN111064893A (en) * 2019-12-27 2020-04-24 上海摩勤智能技术有限公司 Code scanning and photographing compatible method and electronic terminal
CN111107292A (en) * 2019-02-28 2020-05-05 华为技术有限公司 Video frame rate control method and related device
CN112333397A (en) * 2020-03-26 2021-02-05 华为技术有限公司 Image processing method and electronic device
CN112489322A (en) * 2020-11-18 2021-03-12 上海商米科技集团股份有限公司 Quick code scanning method for POS machine product
CN112532857A (en) * 2019-09-18 2021-03-19 华为技术有限公司 Shooting method and equipment for delayed photography

Patent Citations (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102790862A (en) * 2012-07-30 2012-11-21 成都西可科技有限公司 Method for dynamically improving effect of cell phone front camera
US20160203352A1 (en) * 2013-09-20 2016-07-14 Flashback Survey, Inc. Using scanable codes to obtain a service
CN104008361A (en) * 2014-06-16 2014-08-27 北京握奇智能科技有限公司 Two-dimensional code scanning, locating and prompting method and system
CN106407868A (en) * 2016-08-26 2017-02-15 乐视控股(北京)有限公司 Two-dimensional scanning processing method and mobile terminal
WO2019041324A1 (en) * 2017-09-01 2019-03-07 深圳传音通讯有限公司 Shooting frame rate selection method for terminal, terminal, and computer readable storage medium
CN109670362A (en) * 2017-10-16 2019-04-23 上海商米科技有限公司 Bar code scanning method and device
CN109725699A (en) * 2017-10-20 2019-05-07 华为终端(东莞)有限公司 Recognition methods, device and the equipment of identification code
CN109214225A (en) * 2018-07-04 2019-01-15 青岛海信移动通信技术股份有限公司 A kind of scan method, device, mobile terminal and the storage medium of figure bar code
CN111107292A (en) * 2019-02-28 2020-05-05 华为技术有限公司 Video frame rate control method and related device
CN110059518A (en) * 2019-04-22 2019-07-26 广东小天才科技有限公司 A kind of barcode scanning method, device and mobile terminal
CN110378165A (en) * 2019-05-31 2019-10-25 阿里巴巴集团控股有限公司 Two-dimensional code identification method, two dimensional code fixation and recognition method for establishing model and its device
CN112532857A (en) * 2019-09-18 2021-03-19 华为技术有限公司 Shooting method and equipment for delayed photography
CN110738067A (en) * 2019-09-30 2020-01-31 百富计算机技术(深圳)有限公司 Method and device for improving code scanning efficiency
CN110765799A (en) * 2019-10-21 2020-02-07 高新兴科技集团股份有限公司 Client code scanning identification method, device, equipment and storage medium
CN111008540A (en) * 2019-11-29 2020-04-14 联想(北京)有限公司 Bar code identification method and equipment and computer storage medium
CN111064893A (en) * 2019-12-27 2020-04-24 上海摩勤智能技术有限公司 Code scanning and photographing compatible method and electronic terminal
CN112333397A (en) * 2020-03-26 2021-02-05 华为技术有限公司 Image processing method and electronic device
CN112489322A (en) * 2020-11-18 2021-03-12 上海商米科技集团股份有限公司 Quick code scanning method for POS machine product

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115079886A (en) * 2022-07-21 2022-09-20 荣耀终端有限公司 Two-dimensional code recognition method, electronic device, and storage medium
CN115081467A (en) * 2022-07-22 2022-09-20 深圳市成为信息股份有限公司 Method for collecting original image by handset, handset and storage medium
CN115081467B (en) * 2022-07-22 2023-02-03 深圳市成为信息股份有限公司 Method for collecting original image by handset, handset and storage medium
WO2024055817A1 (en) * 2022-09-15 2024-03-21 荣耀终端有限公司 Code scanning method and electronic device
CN116709017A (en) * 2022-09-26 2023-09-05 荣耀终端有限公司 Code scanning method and electronic equipment
CN116341586A (en) * 2023-02-27 2023-06-27 荣耀终端有限公司 Code scanning method, electronic equipment and storage medium
CN116341586B (en) * 2023-02-27 2023-12-01 荣耀终端有限公司 Code scanning method, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN113919382B (en) 2023-04-28

Similar Documents

Publication Publication Date Title
CN113919382B (en) Code scanning method and device
US9235916B2 (en) Image processing device, imaging device, computer-readable storage medium, and image processing method
CN109729279B (en) Image shooting method and terminal equipment
US9002061B2 (en) Image processing device, image processing method and computer-readable medium
US9906732B2 (en) Image processing device, image capture device, image processing method, and program
US9799105B2 (en) Image processing device, imaging device, image processing method, and program for restoration processing based on a point spread function and a frame after a frame to be processed
US20230283920A1 (en) Electronic device comprising image sensor and method of operating same
US20230209193A1 (en) Image stabilization method and electronic device therefor
CN116744120B (en) Image processing method and electronic device
CN113810590A (en) Image processing method, electronic device, medium, and system
US9462205B2 (en) Image processing device, imaging device, image processing method, and non-transitory computer readable medium
US11917295B2 (en) Method for correcting shaking at high magnification and electronic device therefor
CN115359105B (en) Depth-of-field extended image generation method, device and storage medium
CN115988311A (en) Image processing method and electronic equipment
CN116301459B (en) Code scanning method and related device
CN116723416B (en) Image processing method and electronic equipment
CN116051368B (en) Image processing method and related device
CN116389885B (en) Shooting method, electronic equipment and storage medium
US20230199330A1 (en) Electronic device for processing continuous shooting input and method thereof
EP4270928A1 (en) Electronic device comprising image sensor and operating method therefor
EP4228246A1 (en) Electronic device capable of auto-focusing and method for operating same
US20230147540A1 (en) Electronic device and image processing method thereof
WO2023160220A1 (en) Image processing method and electronic device
US20230328375A1 (en) Imaging apparatus, focus control method, and focus control program
EP4304188A1 (en) Photographing method and apparatus, medium and chip

Legal Events

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