CN116320784B - Image processing method and device - Google Patents

Image processing method and device Download PDF

Info

Publication number
CN116320784B
CN116320784B CN202211324972.7A CN202211324972A CN116320784B CN 116320784 B CN116320784 B CN 116320784B CN 202211324972 A CN202211324972 A CN 202211324972A CN 116320784 B CN116320784 B CN 116320784B
Authority
CN
China
Prior art keywords
image
alignment
camera
information
shake
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211324972.7A
Other languages
Chinese (zh)
Other versions
CN116320784A (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 CN202211324972.7A priority Critical patent/CN116320784B/en
Publication of CN116320784A publication Critical patent/CN116320784A/en
Application granted granted Critical
Publication of CN116320784B publication Critical patent/CN116320784B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Studio Devices (AREA)

Abstract

The embodiment of the application provides an image processing method and device, which are applied to electronic equipment with a first camera and a second camera: the method comprises the steps of obtaining a first image shot by a first camera and a second image shot by a second camera, outputting an image shot after an optical anti-shake stroke for an optical anti-shake function by at least one of the first image and the second image, aligning information of the first image to information of a first reference pixel to obtain a first alignment matrix, aligning information of the second image to information of a second reference pixel to obtain a second alignment matrix, performing distortion transformation on the first image based on the first alignment matrix to obtain a first alignment image, performing distortion transformation on the second image based on the second alignment matrix to obtain a second alignment image, obtaining offset between the first alignment image and the second alignment image, wherein the information comprises the optical anti-shake stroke, so that the offset removes the influence of the optical anti-shake, and further obtaining a better alignment effect.

Description

Image processing method and device
Technical Field
The present application relates to the field of electronic information technologies, and in particular, to an image processing method and apparatus.
Background
Cameras are applications commonly found on electronic devices that acquire captured images or videos by invoking a camera. To meet different shooting needs of users, electronic devices often provide multiple types of cameras, including but not limited to wide-angle cameras, ultra-wide-angle cameras, and tele cameras.
Under the condition that the cameras of different types are switched, it is possible that a user can visually experience the jump of the image, for example, when the camera is switched from the wide-angle camera to the tele camera, the user can feel the jump of the view angle of the preview image of the camera, so that the user experience is reduced.
Therefore, how to reduce the possibility of the jump of the visual effect of the image caused by the switching of the camera so as to improve the function of the camera is one of the problems to be solved at present.
Disclosure of Invention
The application provides an image processing method, which aims to solve the problem of how to reduce the possibility of image visual effect jump caused by camera switching, thereby improving the function of a camera.
In order to achieve the above object, the present application provides the following technical solutions:
a first aspect of the present application provides an image processing method applied to an electronic device, the electronic device having a plurality of cameras, the plurality of cameras including a first camera and a second camera, at least one of the plurality of cameras being configured with an optical anti-shake function, the method comprising: obtaining a first image shot by a first camera and a second image shot by a second camera, outputting an image shot after an optical anti-shake stroke for an optical anti-shake function by at least one of the first image and the second image, aligning information of the first image to information of a preset first reference pixel to obtain a first alignment matrix, aligning information of the second image to information of a preset second reference pixel to obtain a second alignment matrix, wherein the information comprises the optical anti-shake stroke, performing distortion transformation on the first image based on the first alignment matrix to obtain a first alignment image, performing distortion transformation on the second image based on the second alignment matrix to obtain a second alignment image, obtaining an offset between the first alignment image and the second alignment image, performing moving processing on the first image or the second image based on the offset under the condition that the optical anti-shake function is closed to obtain an image alignment result. It can be understood that the manner of obtaining the alignment matrix and obtaining the alignment image eliminates the influence of the optical anti-shake distance in the alignment image, so that the image alignment result obtained based on the offset avoids the influence of the optical anti-shake distance, thereby having better alignment effect.
In some implementations, aligning information of the first image to information of a preset first reference pixel, and obtaining the first alignment matrix includes: based on the exposure time of the first image, the alignment time of the first image is acquired, and the information of sampling pixels in the first image is subjected to distortion transformation to the information of pixels exposed in the alignment time, so that a first alignment matrix is obtained. The alignment effect is poor due to inconsistent image time of the camera can be eliminated by aligning the pixels to the pixels exposed in the alignment time.
In some implementations, based on the exposure time of the first image, acquiring the alignment time of the first image includes: the alignment time of the first image is obtained based on the average value of the exposure time of the plurality of pixel points in the first image, so as to further optimize the alignment effect, or the alignment time of the first image is selected from the exposure time of the pixel points in the first image.
In some implementations, the information further includes: gyroscope information so as to reduce the problem of poor alignment effect caused by inconsistent read-write settings of cameras.
In some implementations, the electronic device is further configured with an electronic anti-shake function, and after performing a moving process on the first image or the second image based on the offset, the method further includes: and performing electronic anti-shake processing based on the first image and the second image to obtain an electronic anti-shake result, and obtaining a displayed image based on the aligned image and the electronic anti-shake result. Electronic anti-shake performed on the basis of optical shake release can further reduce the degradation effect of shake on image quality.
In some implementations, the first camera is a main camera, the second camera is a tele camera, a focal length range of the main camera is smaller than a focal length range of the second camera, and moving the first image or the second image includes: and performing moving processing on the first image to obtain a better alignment effect.
In some implementations, the electronic device runs an operating system, the operating system includes a camera hardware abstraction layer, the camera hardware abstraction layer includes a calculation module, and the calculation module is configured to align information of a first image to information of a preset first reference pixel to obtain a first alignment matrix, and align information of a second image to information of the preset second reference pixel to obtain a second alignment matrix. And an alignment matrix is obtained between SATs, so that the alignment matrix after eliminating the influence of the optical anti-shake stroke is transmitted to the SAT module, and the accuracy of the output result of the SAT is improved.
In some implementations, the operating system further includes a camera algorithm library, where the camera algorithm library includes a spatial alignment transformation algorithm module, and the spatial alignment transformation algorithm module is configured to perform a warp transformation on a first image based on a first alignment matrix to obtain a first alignment image, perform a warp transformation on a second image based on a second alignment matrix to obtain a second alignment image, and obtain an offset between the first alignment image and the second alignment image, where the offset is the same as the offset between the first alignment image and the second alignment image when the optical anti-shake function is turned off because the alignment matrix does not have an influence of an optical anti-shake stroke, and perform a shift process on the first image or the second image based on the offset, so that the alignment result has a better alignment effect, and thus an image jump caused by a handover of a called camera is eliminated.
A second aspect of the present application provides an electronic device comprising: the image processing device comprises a memory and a processor, wherein the memory is used for storing an application program, and the processor is used for running the application program to realize the image processing method provided by the first aspect of the application.
A third aspect of the present application provides a readable storage medium having stored thereon a program which, when read and run by a computer device, implements the image processing method provided by the first aspect of the present application.
A fourth aspect of the application provides a computer program product comprising: computer program code which, when run on an electronic device, causes the electronic device to perform the image processing method provided by the first aspect of the application.
Drawings
FIG. 1a is an exemplary diagram of a preview interface with a camera's magnification of "1X";
fig. 1b is an exemplary diagram of a preview interface with a shooting magnification of "5X" of a camera;
fig. 2 is a diagram illustrating a hardware structure of an electronic device according to an embodiment of the present application;
FIG. 3 is a diagram illustrating an exemplary software framework of an electronic device according to an embodiment of the present application;
FIG. 4 is a flowchart of an image processing method according to an embodiment of the present application;
Fig. 5 is an exemplary diagram of obtaining exposure time and sampling pixel points according to an embodiment of the present application;
fig. 6 is a diagram of a transformation example of baseline based on a front-end processing result and an alignment matrix according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. The terminology used in the following examples is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the application and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include, for example, "one or more" such forms of expression, unless the context clearly indicates to the contrary. It should also be understood that in embodiments of the present application, "one or more" means one, two, or more than two; "and/or", describes an association relationship of the association object, indicating that three relationships may exist; for example, a and/or B may represent: a alone, a and B together, and B alone, wherein A, B may be singular or plural. The character "/" generally indicates that the context-dependent object is an "or" relationship.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
The plurality of the embodiments of the present application is greater than or equal to two. It should be noted that, in the description of the embodiments of the present application, the terms "first," "second," and the like are used for distinguishing between the descriptions and not necessarily for indicating or implying a relative importance, or alternatively, for indicating or implying a sequential order.
In the following embodiments of the present application, it is assumed that a wide-angle camera, a main camera, and a telephoto camera are provided on an electronic apparatus, and examples of correspondence of three types of cameras and photographing magnification are:
The magnification is between [0.1, 1), the image shot by the wide-angle camera is sent and displayed, the magnification is between [1,4], the image shot by the main camera is sent and displayed, the magnification is more than 4, and the image shot by the long-focus camera is sent and displayed.
Taking a scene of a video shot by a camera as an example, the multiplying power is between [0.1, 1), the preview interface of the camera of the electronic equipment displays images shot by the wide-angle camera, the multiplying power is between [1,4], the preview interface of the camera displays images shot by the main camera, the multiplying power is greater than 4, and the preview interface of the camera displays images shot by the tele camera.
As shown in fig. 1a, after a user starts a camera of an electronic device, a preview interface a of the camera is displayed in the electronic device, and the camera captures an image using a default shooting magnification of 1 (which may also be referred to as "1X"), the default shooting magnification being indicated only on a magnification identification control A1 of the preview interface a and not being displayed in other areas of the preview interface a.
Fig. 1b is an example in which the user changes the photographing magnification from "1X" to "5X" (i.e., magnification 5) by operating on the preview interface a, and unlike fig. 1a, marks are also made at other positions on the preview interface a, such as "5X" in fig. 1b, in addition to the indication on the magnification identification control A1, to prompt the user for the current photographing magnification.
Based on the corresponding relation between the three types of cameras and the shooting multiplying power, in the process of changing the shooting multiplying power from 1X to 5X, the camera called by the camera is switched from the main camera to the tele camera. In an embodiment of the present application, a camera-invoked video camera may be understood as a video camera that captures images displayed by the camera. For example, if the image currently displayed by the camera is an image with a magnification of "5X", the camera currently called by the camera is a tele camera. Although it is possible that the main camera is also capturing images, the images captured by the main camera are not displayed.
In the case of the camera switching, the user can feel the jump of the visual effect of the image in the preview interface, taking fig. 1a and fig. 1b as examples, the preview interface a of fig. 1a calls the image collected by the main camera for the camera, the preview interface a of fig. 1b calls the image collected by the tele camera for the camera, and compared with fig. 1a, the view angle (fov) of the collected image can be seen from the reference line in the preview interface a.
In summary, when the camera invoked by the camera switches, the image displayed by the camera (or the image in the stored video) may jump in view angle, and this jump may deteriorate the use experience of the user.
To mitigate this jump in viewing angle, a spatial alignment transformation (Spatial Alignment Transform, SAT) can be performed on the previously displayed image and the subsequently displayed image.
However, the inventors found during the course of the study that:
because the different cameras are inconsistent in drawing time and inconsistent in reading and writing settings, SAT has limited effect, namely jump exists between two images after SAT.
In addition, the optical anti-shake and electronic anti-shake functions of the electronic device configuration affect the SAT effect.
The optical anti-shake function can be simply understood as: the light is corrected to return to the position of the optical center by the movement of the lens, thereby reducing the influence of shake. It can be seen that optical anti-shake requires shifting the lens of the camera, which is referred to as an optical anti-shake stroke.
Electronic anti-shake can be simply understood as: the amplitude of the shake is detected through an acceleration sensor and a gyroscope, and a software algorithm is used for correcting the image. In the electronic anti-shake processing process, the image is cut.
According to the sequence of performing optical anti-shake, performing SAT based on the optical anti-shake result, performing electronic anti-shake based on the optical anti-shake result, performing fusion processing on the SAT result and the electronic anti-shake result, and cutting the fusion processing result to obtain the final displayed image, it is known that the offset of SAT movement and the optical anti-shake stroke both have influence on cutting of the fusion processing result, and cutting has a certain limit, namely, the image cannot be cut in a limited way, so that the display effect of the image is affected.
Therefore, the total amount of shift of the SAT shift and the optical anti-shake distance is constant, and it is understood that the shift of the SAT shift and the optical anti-shake distance are in a relationship that they are offset from each other, for example, in the case where the optical anti-shake distance is large, the shift of the SAT shift is small.
In summary, the optical anti-shake may affect the processing effect of the SAT, and there is a jump between the two images after the SAT. Moreover, if the processing effect of the SAT is to be ensured, in the case that the shift amount of the SAT movement is large, especially, the direction of the shift amount of the SAT movement and the movement direction of the lens in the optical anti-shake process, the lens cannot be ensured to be moved by a sufficient optical anti-shake stroke, and therefore, the SAT may also cause the optical anti-shake failure.
In addition, since both SAT and electronic anti-shake use optical anti-shake processing results, and the processing sequence is combined, it is known that the process of clipping the fusion processing results corresponds to the optical anti-shake process being used twice, and there is a risk of over clipping.
In addition, some cameras may be provided with optical anti-shake components, while other cameras are not provided with optical anti-shake components, or the optical anti-shake strokes of different cameras may be different, which may cause the alignment effect of SAT.
In summary, because of the differences between the image time and the read-write settings of different cameras and the effects of the optical anti-shake and anti-shake technologies of electronic devices, the effect of eliminating the jump of the transmitted and displayed image by the conventional SAT needs to be improved.
In order to solve the above-mentioned problems, the embodiment of the present application provides an image processing method, and in combination with the scenes shown in fig. 1a and 1b, it can be understood that the image processing method provided in the embodiment of the present application is applied to an electronic device, where at least two types of cameras are provided, and examples of the at least two types of cameras are a wide-angle camera, a main camera, and a tele camera, but not limited thereto. And, the switching of the magnification is only an example condition that the images displayed by the cameras in succession are photographed by different types of cameras, and is not limited. The scenes to which the image processing method according to the following embodiments is applied include, but are not limited to: at least one of previewing, capturing video, and playing video with a camera. Electronic devices include, but are not limited to, cell phones, tablet computers, desktop, laptop, notebook, ultra mobile personal computers (Ultra-mobile Personal Computer, UMPC), handheld computers, netbooks, personal digital assistants (Personal Digital Assistant, PDA), wearable electronic devices, smart watches, and like electronic devices with cameras.
As shown in fig. 2, for example, the electronic device 100 may include a processor 110, an internal memory 120, a display 130, a camera 140, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, and the like.
It is to be understood that the structure illustrated in the present embodiment does not constitute a specific limitation on the electronic apparatus. In other embodiments, the electronic device may include more or fewer components than shown, or certain components may be combined, or certain components may be split, or different arrangements of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
The processor 110 may include one or more processing units, such as: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc. Wherein the different processing units may be separate devices or may be integrated in one or more processors. It will be appreciated that an ISP can implement hardware-based image processing functionality.
The internal memory 120 may be used to store computer-executable program code that includes instructions. The processor 110 executes various functional applications of the electronic device 100 and data processing by executing instructions stored in the internal memory 110. The internal memory 120 may include a storage program area and a storage data area. The storage program area may store an application program (such as a sound playing function, an image playing function, etc.) required for at least one function of the operating system, etc. The storage data area may store data created during use of the electronic device (e.g., audio data, phonebook, etc.), and so forth. In addition, the internal memory 120 may include a high-speed random access memory, and may also include a nonvolatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (universal flash storage, UFS), and the like. The processor 110 performs various functional applications of the electronic device and data processing by executing instructions stored in the internal memory 120 and/or instructions stored in a memory provided in the processor.
The electronic device implements display functions through the GPU, the display 130, and the application processor, etc. The GPU is a microprocessor for image processing, and is connected to the display 130 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
The display screen 130 is used to display images, videos, and the like. The display 130 includes a display panel. The display panel may employ a liquid crystal display (liquid crystal display, LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED) or an active-matrix organic light-emitting diode (matrix organic light emitting diode), a flexible light-emitting diode (flex), a mini, a Micro-led, a quantum dot light-emitting diode (quantum dot light emitting diodes, QLED), or the like. In some embodiments, the electronic device may include 1 or N display screens 130, N being a positive integer greater than 1.
The electronic device 100 may implement photographing functions through an ISP, a camera 140, a video codec, a GPU, a display screen 194, an application processor, and the like.
The ISP is used to process the data fed back by the camera 140. For example, when photographing, the shutter is opened, light is transmitted to the camera photosensitive element through the lens, the optical signal is converted into an electric signal, and the camera photosensitive element transmits the electric signal to the ISP for processing and is converted into an image visible to naked eyes. ISP can also optimize 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 140.
The camera 140 is used to capture still images or video. The object generates an optical image through the lens and projects the optical image onto the photosensitive element. The photosensitive element may be a charge coupled device (charge coupled device, CCD) or a Complementary Metal Oxide Semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, which is then transferred to the ISP to be converted into a digital image signal. In some implementations, the ISP outputs the digital image signal to DSP processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV, or the like format. In some embodiments, the electronic device 100 may include 1 or N cameras 140, N being a positive integer greater than 1.
The camera 140 includes various types of cameras, such as a wide-angle camera, a main camera, and a tele camera.
The digital signal processor is used for processing digital signals, and can process other digital signals besides digital image signals. For example, when the electronic device 100 selects a frequency bin, the digital signal processor is used to fourier transform the frequency bin energy, or the like.
Video codecs are used to compress or decompress digital video. The electronic device 100 may support one or more video codecs. In this way, the electronic device 100 may play or record video in a variety of encoding formats, such as: dynamic picture experts group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
The internal memory 120 may be used to store computer executable program code including instructions. The processor 110 executes various functional applications of the electronic device 100 and data processing by executing instructions stored in the internal memory 120. The internal memory 120 may include a storage program area and a storage data area. The storage program area may store an application program (such as a sound playing function, an image playing function, etc.) required for at least one function of the operating system, etc. The storage data area may store data created during use of the electronic device 100 (e.g., audio data, phonebook, etc.), and so on. In addition, the internal memory 120 may include a high-speed random access memory, and may also include a nonvolatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (universal flash storage, UFS), and the like. The processor 110 performs various functional applications and data processing of the electronic device 100 by executing instructions stored in the internal memory 120 and/or instructions stored in a memory provided in the processor.
The electronic device 100 may implement audio functions through an audio module 170, a speaker 170A, a microphone 170B, an application processor, and the like. Such as music playing, recording, etc.
The audio module 170 is used to convert digital audio information into an analog audio signal output and also to convert an analog audio input into a digital audio signal. The audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be disposed in the processor 110, or a portion of the functional modules of the audio module 170 may be disposed in the processor 110.
The speaker 170A, also referred to as a "horn," is used to convert audio electrical signals into sound signals. The electronic device 100 may listen to music, or to hands-free conversations, through the speaker 170A.
In some embodiments, speaker 170A may play video information with special effects as mentioned in embodiments of the present application.
Microphone 170B, also referred to as a "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or transmitting voice information, the user can sound near the microphone 170B through the mouth, inputting a sound signal to the microphone 170B.
In some embodiments, the microphone 170B may collect sound of the environment in which the electronic device is located during the process of capturing video information with special effects by the camera.
The wireless communication function of the electronic device 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modem processor, a baseband processor, and the like.
The antennas 1 and 2 are used for transmitting and receiving electromagnetic wave signals.
The mobile communication module 150 may provide a solution for wireless communication including 2G/3G/4G/5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (low noise amplifier, LNA), etc. The mobile communication module 150 may receive electromagnetic waves from the antenna 1, perform processes such as filtering, amplifying, and the like on the received electromagnetic waves, and transmit the processed electromagnetic waves to the modem processor for demodulation. The mobile communication module 150 can amplify the signal modulated by the modem processor, and convert the signal into electromagnetic waves through the antenna 1 to radiate.
The wireless communication module 160 may provide solutions for wireless communication including wireless local area network (wireless local area networks, WLAN) (e.g., wireless fidelity (wireless fidelity, wi-Fi) network), bluetooth (BT), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field wireless communication technology (near field communication, NFC), infrared technology (IR), etc., as applied to the electronic device 100. The wireless communication module 160 may be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the electromagnetic wave signals, filters the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 may also receive a signal to be transmitted from the processor 110, frequency modulate it, amplify it, and convert it to electromagnetic waves for radiation via the antenna 2.
In addition, an operating system is run on the components. Such as iOS operating systems, android operating systems, windows operating systems, etc. Running applications may be installed on the operating system.
Fig. 3 includes a software architecture block diagram of an electronic device in accordance with an embodiment of the present application.
The layered architecture divides the software into several layers, each with distinct roles and branches. The layers communicate with each other through a software interface. In some embodiments, the Android system includes four layers, from top to bottom, an application layer, an application framework layer, a Hardware Abstraction Layer (HAL), and a kernel layer, respectively.
The application layer may include a series of application packages. As shown in fig. 3, the application package may include applications such as cameras, gallery, and the like. In some embodiments, the camera is used to invoke some type of webcam to take a picture. The user can select the camera by operating in the interface of the camera, and an example of camera selection or switching is the aforementioned user selection of shooting magnification.
The application framework layer provides an application programming interface (application programming interface, API) and programming framework for application programs of the application layer. The application framework layer includes a number of predefined functions. Taking fig. 3 as an example, a camera access interface may be included in the application framework layer, including camera management and camera devices.
The HAL includes a camera hardware abstraction layer and a camera algorithm library. The camera hardware abstraction layer comprises a camera device 1 and a camera device 2, it being understood that fig. 3 exemplifies an electronic device with two cameras, the camera device 1 being used for managing a first camera and the camera device 2 being used for managing a second camera.
The camera apparatus 1 and the camera apparatus 2 each include a calculation module, and functions of the calculation module will be described in connection with the following procedures.
The camera algorithm library comprises various algorithm modules for processing images, and the algorithm modules related to the embodiment of the application comprise a Space Alignment Transformation (SAT) module and an electronic anti-shake module.
The kernel layer is a layer between hardware and software. The kernel layer contains at least a camera device driver and a graphics processor driver. Wherein the camera device driver includes at least a camera driver, an ISP driver, and the like, collectively referred to as a camera device driver in fig. 3.
Although the Android system is taken as an example for explanation, the basic principle of the embodiment of the application is also applicable to electronic devices based on iOS, windows and other operating systems. Only a few examples of the modules are shown in fig. 3, it being understood that other modules may be included, i.e. fig. 3 is not limiting of the software framework of the electronic device.
Also shown in fig. 3 are some of the hardware modules of the hardware layer associated with the image processing method provided by the embodiment of the present application, including a camera, an Image Signal Processor (ISP), an optical anti-shake (OIS) component, and a graphics processor. The camera is exemplified as including a camera 1 and a camera 2.
In fig. 3, the optical anti-shake unit is taken as an example of the configuration of the camera 1, and it is understood that the optical anti-shake unit may be configured or not configured in the camera 2. In the case where the camera 1 and the camera 2 are each provided with an optical anti-shake member, OIS strokes obtained by the respective optical anti-shake members of the two cameras may also be different.
It will be appreciated that each module in the software framework interacts with the hardware through a corresponding driver in the kernel layer.
As shown in connection with fig. 2 and 3, it is assumed that the user adjusts the photographing magnification from "1X" to "5X" at the preview interface of the camera, and in the process, the camera is switched from invoking the main camera to invoking the tele camera. Based on this scenario, the main camera is called as camera 1, the tele camera is called as camera 2, and in some implementations, the execution flow of the image processing method according to the embodiments of the present application is as shown in fig. 4:
S01, transmitting an opening instruction to the camera by the camera so as to control the camera to acquire images.
In combination with a scene shot by the camera, the camera responds to the operation of starting the camera by a user and transmits a starting instruction to the camera.
In some implementations, both camera 1 and camera 2 capture images in response to an on command, but at any one time, the images captured (and subsequently processed) by either camera 1 or camera 2 are displayed in the camera. That is, in the case where a plurality of cameras each capture an image, only an image captured by one camera is sent to the camera for display.
In combination with the above scenario, assuming that after the user starts the camera, the default shooting magnification of the camera is "1X", and the shooting magnification expected by the user is "5X", in the process that the user increases the shooting magnification step by step on the preview interface of the camera, the camera displays an image shot by the camera 1 if the shooting magnification is not greater than "4X", and displays an image shot by the camera 2 if the shooting magnification is greater than "4X".
In other implementations, in order to save resources, only the camera 1 may be called for shooting, and in the case that the shooting magnification reaches a certain value, such as "3X", the camera 1 and the camera 2 are called for shooting.
In connection with the example of the software framework shown in fig. 3, in some implementations, after the camera is turned on, an on command is sent to the camera access interface, which sends the on command to the camera device driver through the camera hardware abstraction layer, which controls the camera 1 and the camera 2 to capture images.
It will be appreciated that in order to highlight the interaction between the software layer and the hardware layer and the image processing flow disclosed in the embodiment of the present application, the interaction between the camera application and each module in the application framework layer, the system library, and the kernel layer is not reflected in fig. 4. The camera shown in fig. 4 is a generic name of the camera 1 and the camera 2 shown in fig. 3.
In this embodiment, it is assumed that the electronic device is dithered due to a user' S hand shake or in a motion state, and the dithering triggers the execution S02.
S02, the optical anti-shake component controls the camera to move the OIS stroke.
The control flow of the OIS component is not described in detail here.
In the present embodiment, it is assumed that the camera 1 and the camera 2 are each provided with an optical anti-shake member, collectively referred to as an optical anti-shake member shown in fig. 4.
S03, the collected image after the optical anti-shake processing is transmitted to the ISP by the camera after the optical anti-shake processing.
It can be understood that the camera after the optical anti-shake processing is a camera after the OIS stroke is moved, and the collected image is recorded as an image after the optical anti-shake processing.
S04, performing front-end processing on the image acquired by the camera by the ISP to obtain a front-end processing result.
It will be appreciated that in the case where the camera 1 and the camera 2 each acquire an image, the ISP performs front-end processing on the images acquired by the camera 1 and the camera 2, respectively. In some implementations, front-end processing includes, but is not limited to: dead spot correction, lens shading correction, and white balance.
The structure and specific flow for implementing front-end processing in the ISP will not be described in detail here.
S05, the ISP transmits the front-end processing result to the camera device driver.
S06, the camera device drives to acquire alignment time.
The alignment time can be understood as the exposure time of the pixel as the alignment reference point.
In some implementations, the alignment time may be configured in the camera device driver by an upper module, including but not limited to an application such as a camera.
In other implementations, the alignment time is randomly selected by the camera device driver. Taking the front end processing result Image1 of the Image acquired by the camera 1 as an example, the camera device drives to randomly select one exposure time from exposure times of each pixel point of the Image1 as an alignment time.
In still other implementations, the camera device drives an alignment time calculated based on exposure times of the plurality of pixels. Taking Image1 as an example, as shown in fig. 5, the average of the exposure time t1 of the upper left pixel, the exposure time t2 of the upper right pixel, the exposure time t3 of the lower left pixel, and the exposure time t4 of the lower right pixel in Image1 is calculated as the alignment time. It can be understood that the alignment time obtained based on this calculation method corresponds to the exposure time of the center pixel of Image 1. The calculation mode of the alignment time can obtain more accurate alignment results.
It is understood that the alignment time is obtained based on Image1 or Image2 as a front end processing result of the Image acquired by the camera 2, and the manner in which the alignment time is obtained from Image2 is the same as that in which the alignment time is obtained from Image 1.
S07, the camera device drives to obtain information of sampling pixel points from the front-end processing result.
In order to improve accuracy of the alignment result, the number of sampling pixel points is multiple, and the sampling pixel points are uniformly distributed in the front-end processing result. Taking Image1 as an example, one example is to take 7 pixel points uniformly spaced among a plurality of rows (e.g., each row) of pixels in Image1 as sampling pixel points of Image 1. In order to ensure accuracy of the alignment result, the Image2, which is the front-end processing result of the Image acquired by the camera 2, is sampled in the same manner. Fig. 5 shows sampling pixel points of any one line of Image1 and Image 2.
In order to solve the problem of poor alignment effect caused by the difference of read-write settings of the camera, in this embodiment, the information of the sampling pixel point includes gyroscope information of the sampling pixel point, and in order to solve the influence of optical anti-shake alignment effect, the information of the sampling pixel point further includes OIS travel of the sampling pixel point. The information of each sampling pixel point forms a matrix, such as g1, g2 and … … g7 shown in fig. 5. Taking g1 as an example, g1 in Image1 is a matrix of gyroscope information and OIS run of the first sampling point in Image 1. G1 in Image2 is a matrix of gyroscope information and OIS run of the first sampling point in Image 2.
In order to save resources, it can be understood that the execution conditions of S06 and S07 include: the shooting multiplying power is switched and the optical anti-shake function is started. It can be understood that under the condition that the shooting multiplying power is switched, the camera called by the camera is not necessarily switched, but in order to ensure that the anti-jump effect can be timely obtained under the condition that the camera called by the camera is switched, in this embodiment, the anti-jump processing is started when the shooting multiplying power is switched.
In order to save resources, the execution conditions of S06 and S07 further include that, in the case of displaying the image captured by the target camera, the used capturing magnification is larger than the preset value corresponding to the target camera. The target camera is any one camera on the electronic equipment, and the function of the preset numerical value is as follows: beyond the preset value, there is a high possibility that the magnification will be continuously adjusted to switch the camera head of the camera. Based on the above-mentioned effects, the preset value is a preset magnification value based on the magnification range corresponding to the target camera.
For example, the target camera is a wide-angle camera, the magnification range corresponding to the wide-angle camera is [0.1, 1), and the preset value can be 0.8. For example, the target camera is a main camera, the corresponding multiplying power range of the main camera is [1,4], and the preset value can be 3. It can be understood that the preset value is within the corresponding magnification range of the target camera, and further, in order to save resources, is larger than the intermediate value of the magnification range.
S08, the camera device driver transmits the alignment time, the information of the sampling pixel points and the front-end processing result to the camera hardware abstraction layer.
S09, the calculation module in the camera device of the camera hardware abstraction layer calculates the pixel (may be referred to as P) exposed by the front-end processing result to the alignment time based on the alignment time and the pose information of the sampling pixel point align_time ) An aligned alignment matrix.
In some implementations, an integration operation of gyroscope information and OIS travel is performed for each sampling pixel to obtain pose information. Taking g1 as an example, integrating the gyroscope information and OIS travel of g1 to obtain pose information of g1. It can be understood that, after the integration operation of the gyroscope information and OIS journey is performed on each sampling pixel, pose information of each sampling pixel is obtained. Integrating the gyroscope information and OIS travel of the pixels aligned with the time exposure to obtain pose information of the pixels aligned with the time exposure, which is called P align_time Pose information, the pose information of each sampling pixel point is matched with P align_time And (4) performing alignment operation (such as division) on the pose information to obtain an alignment value.
It will be appreciated that taking g1, g2, … … g7 as an example, 7 sampling pixel points can obtain 7 sets of pose values (one set for each sampling point), and the 7 sets of pose values are all equal to P align_time The pose information is aligned to obtain 7 sets of aligned values, and in some examples, the 7 sets of aligned values of the sampling pixel points in the same row are used as an alignment matrix. Thus, a plurality of alignment matrices are available for both Image1 and Image 2.
The alignment matrix of Image1 is referred to as warp1. The alignment matrix of Image2 is called warp2.
It can be appreciated that the calculation module in the camera device 1 is based on the information of the sampling pixel point of Image1 and P align_time Information of (pixels aligned with time exposure in Image 1) is calculated to obtain warp1, and a calculation module in the camera device 2 is based on information of sampling pixel points of Image2 and P align_time Information of (time-exposure-aligned pixels in Image 2) is calculated to obtain warp2.
Based on the obtaining manner of the alignment matrix and the mechanism of the optical anti-shake moving camera, the obtained warp1 can remove the influence of the optical anti-shake stroke of the first camera (in the case that the first camera is executed with the optical anti-shake function), and the obtained warp2 can remove the influence of the optical anti-shake stroke of the second camera (in the case that the second camera is executed with the optical anti-shake function).
S10, the camera hardware abstraction layer transmits an alignment matrix and a front-end processing result to the space alignment conversion module.
It is understood that the computation module of the camera hardware abstraction layer transmits the alignment matrix and the front-end processing result to the spatial alignment transformation module.
S11, the camera hardware abstraction layer transmits a front-end processing result to the electronic anti-shake module.
It can be appreciated that the front-end processing result is specifically transmitted to the electronic anti-shake module by the camera device of the camera hardware abstraction layer.
S12, the space alignment transformation module obtains an alignment image based on the alignment matrix and the front-end processing result.
In some implementations, the spatial alignment transformation module performs matrix multiplication on Image1 and warp1 to obtain an aligned Image1 Performing matrix multiplication on the Image2 and the warp2 to obtain an aligned Image2
S13, the space alignment transformation module obtains a transformation datum line baseline based on the alignment image.
baseline can be understood as the offset between aligned images.
Fig. 6 shows an example of a transformation to obtain baseline based on the front-end processing result and the alignment matrix. It can be understood that, based on the definition of the alignment time and the information of the sampling pixels including gyroscope information and optical anti-shake distance, and the processing of S08-S09, the factors of the image drawing time, the read-write setting and the optical anti-shake distance of the camera are removed from the obtained alignment image, so that the influence of the image drawing time, the read-write setting and the optical anti-shake distance of the camera on the SAT result can be reduced.
S14, the space alignment conversion module is driven by the image processor, and the image processor is called to move the front end processing result of the camera 1 by Baseline to obtain an alignment result.
In the scenario that the slave camera of the embodiment calls the master camera to switch to the tele camera, because the anti-jump effect obtained after the master camera moves baseline is better than the anti-jump effect obtained after the tele camera moves baseline, the front end processing result of the camera 1 is moved baseline in S14, and an alignment result is obtained.
S15, the electronic anti-shake module performs electronic anti-shake processing on the front-end processing result to obtain an electronic anti-shake result.
It is understood that the steps performed in S14 and S15 are not limited.
S16, the space alignment module transmits the alignment result to the camera hardware abstraction layer.
It can be understood that the spatial alignment module transmits the alignment result to the camera device 1 because it is the alignment result obtained by shifting the front-end processing result of the camera 1 by baseline.
S17, the electronic anti-shake module transmits the electronic anti-shake result to the camera hardware abstraction layer.
It can be understood that the anti-shake result of Image1 is transmitted to the camera apparatus 1, and the anti-shake result of Image2 is transmitted to the camera apparatus 2.
S18, the camera hardware abstraction layer transmits the alignment result and the electronic anti-shake result to the ISP through camera equipment driving.
S19, based on the alignment result and the electronic anti-shake result, the ISP carries out back-end processing to obtain a transmission and display image.
A send-display image may be understood as an image to be sent to a camera for display. In combination with the above steps, the displayed image is the image displayed before the camera 1 is switched to the camera 2.
Post-processing includes, but is not limited to: noise reduction, color space conversion, and dynamic range compression. The structure and specific flow for implementing post-processing in the ISP will not be described in detail here.
S20, the ISP transmits the display image to the camera.
In some implementations, the ISP transmits the send image to the camera device driver, which transmits the send image to the camera device 1, the camera device 1 transmits the send image to the camera access interface, which transmits the send image to the camera.
S21, displaying the transmitted image by the camera.
The flow shown in fig. 4 has the following advantages:
the alignment time can remove the influence of the difference of the image time of the cameras on the alignment effect.
The alignment matrix is obtained in such a way that the obtained alignment matrix removes the influence of gyroscope information and OIS run on the pixels. Therefore, obtaining an alignment image based on the alignment matrix can shield the influence of the read-write setting difference of the camera and the optical anti-shake stroke. Thus further ensuring the accuracy of the alignment results of the SAT.
In addition, the alignment result of the SAT is not affected by the optical anti-shake, so that the back-end processing based on the alignment result and the electronic anti-shake result does not repeatedly consider the optical anti-shake stroke. In summary, the sent and displayed image has a better alignment effect, so that after the called camera is switched, the jump between the displayed image and the image displayed before the switching is smaller, and even the image can not be visually sensed.
In combination with the scenario shown in fig. 1a and fig. 1b, in the case where the camera needs to display the "5X" image, the electronic device performs alignment processing on the image captured by the main camera toward the "5X" image based on the corresponding steps in the flow shown in fig. 4, and displays the processed alignment result as the previous image of the "5X" image, so that after the "5X" image is displayed, the viewing angle between the two images displayed before and after has a smaller jump.
It will be appreciated that in order to obtain a better anti-jump effect, the alignment process with the image to be displayed in the next pair may be performed for each image to be displayed, and is not limited to the scene of focal length change.

Claims (10)

1. An image processing method, applied to an electronic device, the electronic device having a plurality of cameras, the plurality of cameras including a first camera and a second camera, at least one of the plurality of cameras being configured with an optical anti-shake function, the method comprising:
Obtaining a first image shot by the first camera and a second image shot by the second camera, wherein at least one of the first image and the second image is an image shot after outputting an optical anti-shake stroke for the optical anti-shake function;
aligning the information of the first image to the information of a preset first reference pixel to obtain a first alignment matrix, and aligning the information of the second image to the information of a preset second reference pixel to obtain a second alignment matrix; the information comprises the optical anti-shake distance, the first reference pixel is a pixel in the first image, which is exposed at the alignment time of the first image, the second reference pixel is a pixel in the second image, which is exposed at the alignment time of the second image, the alignment time of the first image is acquired based on the exposure time of the first image, and the alignment time of the second image is acquired based on the exposure time of the second image;
performing distortion transformation on the first image based on the first alignment matrix to obtain a first alignment image, and performing distortion transformation on the second image based on the second alignment matrix to obtain a second alignment image;
Obtaining an offset between the first alignment image and the second alignment image, the offset being the same as the offset between the first alignment image and the second alignment image with the optical anti-shake function off;
and carrying out moving processing on the first image or the second image based on the offset to obtain an image alignment result.
2. The method according to claim 1, wherein aligning the information of the first image to the information of the preset first reference pixel, to obtain a first alignment matrix, includes:
acquiring alignment time of the first image based on exposure time of the first image;
and performing warping transformation on the information of the sampling pixels in the first image to the information of the pixels subjected to alignment time exposure to obtain the first alignment matrix.
3. The method of claim 2, wherein the acquiring an alignment time of the first image based on an exposure time of the first image comprises:
and obtaining the alignment time of the first image based on the average value of the exposure time of the plurality of pixel points in the first image, or selecting the alignment time of the first image from the exposure time of the pixel points in the first image.
4. A method according to any one of claims 1-3, wherein the information further comprises:
gyroscope information.
5. The method of any of claims 1-4, wherein the electronic device is further configured with an electronic anti-shake function;
after the shifting process is performed on the first image or the second image based on the offset, the method further includes:
based on the first image and the second image, performing electronic anti-shake processing to obtain an electronic anti-shake result;
and obtaining a displayed image based on the aligned image and the electronic anti-shake result.
6. The method of any one of claims 1-5, wherein the first camera is a primary camera and the second camera is a tele camera, the focal range of the primary camera being less than the focal range of the second camera;
the moving processing of the first image or the second image includes:
and performing movement processing on the first image.
7. The method of any of claims 1-6, wherein the electronic device runs an operating system, the operating system comprising a camera hardware abstraction layer;
The camera hardware abstraction layer comprises a calculation module;
the calculation module is used for aligning the information of the first image to the information of a preset first reference pixel to obtain a first alignment matrix, and aligning the information of the second image to the information of a preset second reference pixel to obtain a second alignment matrix.
8. The method of claim 7, wherein the operating system further comprises a camera algorithm library comprising a spatial alignment transformation algorithm module;
the spatial alignment transformation algorithm module is used for performing distortion transformation on the first image based on the first alignment matrix to obtain a first alignment image, performing distortion transformation on the second image based on the second alignment matrix to obtain a second alignment image, obtaining offset between the first alignment image and the second alignment image, wherein the offset is the same as the offset between the first alignment image and the second alignment image under the condition that the optical anti-shake function is closed, and performing moving processing on the first image or the second image based on the offset to obtain an image alignment result.
9. An electronic device, comprising:
a memory and a processor;
the memory is used for storing application programs;
the processor is configured to run the application program to implement the image processing method of any one of claims 1-8.
10. A readable storage medium having stored thereon a program, characterized in that the image processing method according to any one of claims 1-8 is implemented when the program is read and run by a computer device.
CN202211324972.7A 2022-10-27 2022-10-27 Image processing method and device Active CN116320784B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211324972.7A CN116320784B (en) 2022-10-27 2022-10-27 Image processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211324972.7A CN116320784B (en) 2022-10-27 2022-10-27 Image processing method and device

Publications (2)

Publication Number Publication Date
CN116320784A CN116320784A (en) 2023-06-23
CN116320784B true CN116320784B (en) 2023-11-28

Family

ID=86800169

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211324972.7A Active CN116320784B (en) 2022-10-27 2022-10-27 Image processing method and device

Country Status (1)

Country Link
CN (1) CN116320784B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020088134A1 (en) * 2018-10-31 2020-05-07 Oppo广东移动通信有限公司 Video correction method and device, electronic apparatus, and computer-readable storage medium
CN112153282A (en) * 2020-09-18 2020-12-29 Oppo广东移动通信有限公司 Image processing architecture, method, storage medium and electronic device
CN112261387A (en) * 2020-12-21 2021-01-22 展讯通信(上海)有限公司 Image fusion method and device for multi-camera module, storage medium and mobile terminal
CN113556464A (en) * 2021-05-24 2021-10-26 维沃移动通信有限公司 Shooting method and device and electronic equipment
CN113660408A (en) * 2020-05-12 2021-11-16 华为技术有限公司 Anti-shake method and device for video shooting
US11190689B1 (en) * 2020-07-29 2021-11-30 Google Llc Multi-camera video stabilization
CN113793259A (en) * 2021-11-15 2021-12-14 深圳思谋信息科技有限公司 Image zooming method, computer device and storage medium
CN113875220A (en) * 2019-08-26 2021-12-31 Oppo广东移动通信有限公司 Shooting anti-shake method and device, terminal and storage medium
CN114827391A (en) * 2021-01-28 2022-07-29 北京小米移动软件有限公司 Camera switching method, camera switching device and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108353131B (en) * 2016-10-17 2021-05-04 华为技术有限公司 Method and terminal device for acquiring image

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020088134A1 (en) * 2018-10-31 2020-05-07 Oppo广东移动通信有限公司 Video correction method and device, electronic apparatus, and computer-readable storage medium
CN113875220A (en) * 2019-08-26 2021-12-31 Oppo广东移动通信有限公司 Shooting anti-shake method and device, terminal and storage medium
CN113660408A (en) * 2020-05-12 2021-11-16 华为技术有限公司 Anti-shake method and device for video shooting
US11190689B1 (en) * 2020-07-29 2021-11-30 Google Llc Multi-camera video stabilization
CN112153282A (en) * 2020-09-18 2020-12-29 Oppo广东移动通信有限公司 Image processing architecture, method, storage medium and electronic device
CN112261387A (en) * 2020-12-21 2021-01-22 展讯通信(上海)有限公司 Image fusion method and device for multi-camera module, storage medium and mobile terminal
CN114827391A (en) * 2021-01-28 2022-07-29 北京小米移动软件有限公司 Camera switching method, camera switching device and storage medium
CN113556464A (en) * 2021-05-24 2021-10-26 维沃移动通信有限公司 Shooting method and device and electronic equipment
CN113793259A (en) * 2021-11-15 2021-12-14 深圳思谋信息科技有限公司 Image zooming method, computer device and storage medium

Also Published As

Publication number Publication date
CN116320784A (en) 2023-06-23

Similar Documents

Publication Publication Date Title
AU2013297221B2 (en) Image processing method and apparatus
US9860448B2 (en) Method and electronic device for stabilizing video
US8284256B2 (en) Imaging apparatus and computer readable recording medium
US10027909B2 (en) Imaging device, imaging method, and image processing device
US9906732B2 (en) Image processing device, image capture device, image processing method, and program
KR101256326B1 (en) Image capturing apparatus, image capturing method, and storage medium storing program for image capturing
WO2021190613A9 (en) Photographic method and device
CN106688227A (en) Multi-imaging apparatus, multi-imaging method, program, and recording medium
CN113660408B (en) Anti-shake method and device for video shooting
CN115526787B (en) Video processing method and device
CN115359105B (en) Depth-of-field extended image generation method, device and storage medium
US8373773B2 (en) Imaging apparatus for generating a wide-angle image
US11222235B2 (en) Method and apparatus for training image processing model, and storage medium
CN107071277B (en) Optical drawing shooting device and method and mobile terminal
US20240179397A1 (en) Video processing method and electronic device
WO2023231697A1 (en) Photographing method and related device
CN115550544B (en) Image processing method and device
CN116320784B (en) Image processing method and device
US20230421889A1 (en) Photographing Method and Electronic Device
CN115988311A (en) Image processing method and electronic equipment
EP4274248A1 (en) Photographing method and electronic device
CN116012262B (en) Image processing method, model training method and electronic equipment
US20240214669A1 (en) Image display method and electronic device
CN116721038A (en) Color correction method, electronic device, and storage medium
CN117135420A (en) Image synchronization method and related equipment thereof

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