WO2022017261A1 - Image synthesis method and electronic device - Google Patents

Image synthesis method and electronic device Download PDF

Info

Publication number
WO2022017261A1
WO2022017261A1 PCT/CN2021/106666 CN2021106666W WO2022017261A1 WO 2022017261 A1 WO2022017261 A1 WO 2022017261A1 CN 2021106666 W CN2021106666 W CN 2021106666W WO 2022017261 A1 WO2022017261 A1 WO 2022017261A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
target
shooting angle
information
background image
Prior art date
Application number
PCT/CN2021/106666
Other languages
French (fr)
Chinese (zh)
Inventor
饶刚
董辰
卢曰万
丁欣
周恒�
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2022017261A1 publication Critical patent/WO2022017261A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/95Computational photography systems, e.g. light-field imaging systems
    • H04N23/951Computational photography systems, e.g. light-field imaging systems by using two or more images to influence resolution, frame rate or aspect ratio
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/80Camera processing pipelines; Components thereof
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/222Studio circuitry; Studio devices; Studio equipment
    • H04N5/262Studio circuits, e.g. for mixing, switching-over, change of character of image, other special effects ; Cameras specially adapted for the electronic generation of special effects
    • H04N5/265Mixing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/222Studio circuitry; Studio devices; Studio equipment
    • H04N5/262Studio circuits, e.g. for mixing, switching-over, change of character of image, other special effects ; Cameras specially adapted for the electronic generation of special effects
    • H04N5/272Means for inserting a foreground image in a background image, i.e. inlay, outlay

Definitions

  • the present application relates to the technical field of intelligent terminals, and in particular, to an image synthesis method and an electronic device.
  • Cutout and background change is a process of separating a specified person image from a first image specified by a user, and synthesizing the separated person image into a second image to obtain a target image.
  • the second image in the synthesized target image is used as the background image of the separated person image, thereby realizing the background replacement of the person image.
  • the prior art mainly focuses on how to better separate the person image from the first image, and when synthesizing the separated person image into the second image, the user often scales the person image, and then the electronic device
  • the target image is obtained by directly synthesizing the person image and the second image.
  • the target image synthesized in this way often has problems such as mismatch between the character image and the background image, resulting in serious visual distortion of the target image and affecting user experience.
  • the present application provides an image synthesis method and electronic device, which can improve the problem of serious visual distortion of a target image and improve user experience.
  • an embodiment of the present application provides an image synthesis method, which is applied to an electronic device, including:
  • 3D perspective transformation is performed on the second image according to the shooting angle information of the first image and the shooting angle information of the second image, so that the shooting angle of the second image reaches or is close to the shooting angle of the first image, and the target background image is obtained;
  • the foreground image separated from the first image is combined with the target background image to obtain the target image.
  • the method performs 3D perspective transformation on the second image according to the shooting angle information of the first image and the shooting angle information of the second image, so that the shooting angle of the second image reaches or is close to the shooting angle of the first image, and the target background image is obtained, thereby Compared with the second image, the shooting angle of the target background image is the same or closer to the shooting angle of the first image, that is, the shooting angle of the foreground image and the target background image is the same or closer.
  • the target image obtained by the method of the embodiment of the present application is more visually reasonable and coordinated, thereby improving the problem of serious visual distortion of the target image in the prior art, and improving the user experience. experience.
  • acquiring the second image includes:
  • the background images to be selected that match the preset classification information of the first image; the displayed background images to be selected are sorted from small to large according to the shooting angle difference between the background images to be selected and the first image; the background images to be selected The shooting angle difference value with the first image is calculated according to the shooting angle information of the background image to be selected and the shooting angle information of the first image;
  • the background image to be selected indicated by the selection operation is used as the second image.
  • the background images to be selected displayed to the user are sorted according to the shooting angle difference between the background image to be selected and the first image from small to large, so that the shooting angles of the background images to be selected preferentially browsed by the user are closer to each other.
  • the shooting angle of the first image so that the fusion of the person image and the background image in the target image obtained after image synthesis according to the background image to be selected by the user is relatively more reasonable, natural and coordinated.
  • acquiring a background image to be selected that matches the preset classification information of the first image includes:
  • the background image to be selected is sorted by the server according to the difference value of the shooting angle between the background image to be selected and the first image, the background image to be selected and the first image are sorted by the server.
  • the difference value of the shooting angle between the images is calculated by the server according to the shooting angle information of the background image to be selected and the shooting angle information of the first image.
  • image synthesis is performed on the foreground image separated from the first image and the target background image to obtain the target image, including:
  • Display the target background image receive the user's position designation operation on the target background image, and obtain the position information of the user's designated position on the target background image;
  • the target foreground image is synthesized to the position indicated by the position information in the target background image to obtain the target image.
  • the size of the foreground image can be made closer to the size of the image obtained by real shooting, so that the target image is visually more reasonable and coordinated.
  • the method before synthesizing the target foreground image to the position indicated by the position information on the target background image, before obtaining the target image, the method further includes:
  • the colors of the target foreground image and the target eyepiece image can be made closer, and the synthesized target image has high fusion at the boundary of the two images, so that the target Images are more visually plausible and coordinated.
  • the shooting angle information includes: a shooting attitude angle
  • the shooting attitude angle includes: a pitch angle, an azimuth angle, and a roll angle.
  • an electronic device including:
  • a display screen ; one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, the one or more computer programs including instructions that, when executed by the device, cause The device performs the following steps:
  • 3D perspective transformation is performed on the second image, so that the shooting angle information of the second image reaches or is close to the shooting angle information of the first image, and the target background image is obtained;
  • the foreground image separated from the first image is synthesized into the target background image to obtain the target image.
  • the step of acquiring the second image includes:
  • the displayed background images to be selected are sorted according to the difference value of the shooting angle between the background images to be selected and the first image;
  • the shooting angle difference value between the images is calculated according to the shooting angle information of the background image to be selected and the shooting angle information of the first image;
  • the background image to be selected indicated by the selection operation is used as the second image.
  • the step of obtaining a background image to be selected that matches the preset classification information of the first image includes:
  • the background image to be selected is sorted by the server according to the difference value of the shooting angle between the background image to be selected and the first image, the background image to be selected and the first image are sorted by the server.
  • the difference value of the shooting angle between the images is calculated by the server according to the shooting angle information of the background image to be selected and the shooting angle information of the first image.
  • the steps of performing image synthesis between the foreground image separated from the first image and the target background image to obtain the target image include:
  • Display the target background image receive the user's position designation operation on the target background image, and obtain the position information of the user's designated position on the target background image;
  • the target foreground image is synthesized to the position indicated by the position information in the target background image to obtain the target image.
  • the method when the instruction is executed by the device, before the step of synthesizing the target foreground image to the position indicated by the position information on the target background image, the method further includes:
  • embodiments of the present application provide a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program runs on a computer, causes the computer to execute the method of any one of the first aspect.
  • the present application provides a computer program for performing the method of the first aspect when the computer program is executed by a computer.
  • the program in the fourth aspect may be stored in whole or in part on a storage medium packaged with the processor, or may be stored in part or in part in a memory not packaged with the processor.
  • 1 is a schematic structural diagram of an electronic device of the application
  • FIG. 2 is a schematic diagram of the software structure of the electronic device of the application.
  • FIG. 3 is a GUI schematic diagram of the image synthesis method of the application.
  • FIG. 5 is a schematic diagram of a method for establishing a mobile phone coordinate system and a first coordinate system of the present application
  • 6A is a schematic block diagram of some steps of the image synthesis method of the present application.
  • 6B is a schematic block diagram of some steps of the image synthesis method of the present application.
  • FIG. 7 is a flowchart of another embodiment of the image synthesis method of the present application.
  • FIG. 8 is a structural diagram of an embodiment of an image synthesizing apparatus of the present application.
  • the user after the person image is separated from the first image, the user generally automatically scales the person image to an appropriate size, and then directly combines it into the second image to obtain the target image.
  • the above-mentioned person image may also be referred to as a foreground image
  • the second image may also be referred to as a background image.
  • the present application proposes an image synthesis method and electronic device, which can improve the problem of serious visual distortion of a target image obtained by synthesizing a foreground image (such as the above-mentioned person image) and a background image, and improve the quality of the target image obtained by image synthesis.
  • a foreground image such as the above-mentioned person image
  • a background image such as the above-mentioned background image
  • the image synthesis method of the present application can be applied to electronic devices, such as mobile terminals (mobile phones), tablet computers (PADs), personal computers (PCs), smart screens, in-vehicle devices and other devices.
  • electronic devices such as mobile terminals (mobile phones), tablet computers (PADs), personal computers (PCs), smart screens, in-vehicle devices and other devices.
  • FIG. 1 shows a schematic structural diagram of an electronic device 100 .
  • the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (subscriber identification module, SIM) card interface 195 and so on.
  • SIM Subscriber identification module
  • the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and ambient light. Sensor 180L, bone conduction sensor 180M, etc.
  • the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100 .
  • the electronic device 100 may include more or less components than shown, or combine some components, or separate some components, or arrange different 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, for example, 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), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (neural-network processing unit, NPU), etc. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
  • application processor application processor, AP
  • modem processor graphics processor
  • ISP image signal processor
  • controller video codec
  • digital signal processor digital signal processor
  • baseband processor baseband processor
  • neural-network processing unit neural-network processing unit
  • the controller can generate an operation control signal according to the instruction operation code and timing signal, and complete the control of fetching and executing instructions.
  • a memory may also be provided in the processor 110 for storing instructions and data.
  • the memory in processor 110 is cache memory. This memory may hold instructions or data that have just been used or recycled by the processor 110 . If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby increasing the efficiency of the system.
  • the processor 110 may include one or more interfaces.
  • the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transceiver (universal asynchronous transmitter) receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / or universal serial bus (universal serial bus, USB) interface, etc.
  • I2C integrated circuit
  • I2S integrated circuit built-in audio
  • PCM pulse code modulation
  • PCM pulse code modulation
  • UART universal asynchronous transceiver
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • SIM subscriber identity module
  • USB universal serial bus
  • the I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL).
  • the processor 110 may contain multiple sets of I2C buses.
  • the processor 110 can be respectively coupled to the touch sensor 180K, the charger, the flash, the camera 193 and the like through different I2C bus interfaces.
  • the processor 110 may couple the touch sensor 180K through the I2C interface, so that the processor 110 and the touch sensor 180K communicate with each other through the I2C bus interface, so as to realize the touch function of the electronic device 100 .
  • the I2S interface can be used for audio communication.
  • the processor 110 may contain multiple sets of I2S buses.
  • the processor 110 may be coupled with the audio module 170 through an I2S bus to implement communication between the processor 110 and the audio module 170 .
  • the audio module 170 can transmit audio signals to the wireless communication module 160 through the I2S interface, so as to realize the function of answering calls through a Bluetooth headset.
  • the PCM interface can also be used for audio communications, sampling, quantizing and encoding analog signals.
  • the audio module 170 and the wireless communication module 160 may be coupled through a PCM bus interface.
  • the audio module 170 can also transmit audio signals to the wireless communication module 160 through the PCM interface, so as to realize the function of answering calls through the Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
  • the UART interface is a universal serial data bus used for asynchronous communication.
  • the bus may be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication.
  • a UART interface is typically used to connect the processor 110 with the wireless communication module 160 .
  • the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function.
  • the audio module 170 can transmit audio signals to the wireless communication module 160 through the UART interface, so as to realize the function of playing music through the Bluetooth headset.
  • the MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193 .
  • MIPI interfaces include camera serial interface (CSI), display serial interface (DSI), etc.
  • the processor 110 communicates with the camera 193 through a CSI interface, so as to realize the photographing function of the electronic device 100 .
  • the processor 110 communicates with the display screen 194 through the DSI interface to implement the display function of the electronic device 100 .
  • the GPIO interface can be configured by software.
  • the GPIO interface can be configured as a control signal or as a data signal.
  • the GPIO interface may be used to connect the processor 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, and the like.
  • the GPIO interface can also be configured as I2C interface, I2S interface, UART interface, MIPI interface, etc.
  • the USB interface 130 is an interface that conforms to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, and the like.
  • the USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio through the headphones.
  • the interface can also be used to connect other electronic devices, such as AR devices.
  • the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration, and does not constitute a structural limitation of the electronic device 100 .
  • the electronic device 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
  • the charging management module 140 is used to receive charging input from the charger.
  • the charger may be a wireless charger or a wired charger.
  • the charging management module 140 may receive charging input from the wired charger through the USB interface 130 .
  • the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100 . While the charging management module 140 charges the battery 142 , it can also supply power to the electronic device through the power management module 141 .
  • the power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 110 .
  • the power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160.
  • the power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, battery health status (leakage, impedance).
  • the power management module 141 may also be provided in the processor 110 .
  • the power management module 141 and the charging management module 140 may also be provided in the same device.
  • 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, the modulation and demodulation processor, the baseband processor, and the like.
  • Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
  • the antenna 1 can be multiplexed as a diversity antenna of the wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
  • the mobile communication module 150 may provide wireless communication solutions including 2G/3G/4G/5G etc. applied on the electronic device 100 .
  • the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA) and the like.
  • the mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation.
  • the mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and then turn it into an electromagnetic wave for radiation through the antenna 1 .
  • at least part of the functional modules of the mobile communication module 150 may be provided in the processor 110 .
  • at least part of the functional modules of the mobile communication module 150 may be provided in the same device as at least part of the modules of the processor 110 .
  • the modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high-frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low frequency baseband signal. Then the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the low frequency baseband signal is processed by the baseband processor and passed to the application processor.
  • the application processor outputs sound signals through audio devices (not limited to the speaker 170A, the receiver 170B, etc.), or displays images or videos through the display screen 194 .
  • the modem processor may be a stand-alone device.
  • the modem processor may be independent of the processor 110, and may be provided in the same device as the mobile communication module 150 or other functional modules.
  • the wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellites Wireless communication solutions such as global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared technology (IR).
  • WLAN wireless local area networks
  • BT Bluetooth
  • GNSS global navigation satellite system
  • FM frequency modulation
  • NFC near field communication
  • IR infrared technology
  • the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 .
  • the wireless communication module 160 can also receive the signal to be sent from the processor 110 , perform frequency modulation on it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2 .
  • the antenna 1 of the electronic device 100 is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology.
  • the wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc.
  • the GNSS may include a global positioning system (global positioning system, GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (quasi -zenith satellite system, QZSS) and/or satellite based augmentation systems (SBAS).
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • BDS Beidou navigation satellite system
  • QZSS quasi-zenith satellite system
  • SBAS satellite based augmentation systems
  • the electronic device 100 implements a display function through a GPU, a display screen 194, an application processor, and the like.
  • the GPU is a microprocessor for image processing, and is connected to the display screen 194 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 alter display information.
  • Display screen 194 is used to display images, videos, and the like.
  • Display screen 194 includes a display panel.
  • the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (active-matrix organic light).
  • LED diode AMOLED
  • flexible light-emitting diode flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (quantum dot light emitting diodes, QLED) and so on.
  • the electronic device 100 may include one or N display screens 194 , where N is a positive integer greater than one.
  • the electronic device 100 may implement a shooting function through an ISP, a camera 193, 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 193 .
  • the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye.
  • ISP can also perform algorithm optimization on image noise, brightness, and skin tone.
  • ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
  • the ISP may be provided in the camera 193 .
  • Camera 193 is used to capture still images or video.
  • the object is projected through the lens to generate an optical image onto the photosensitive element.
  • the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
  • CMOS complementary metal-oxide-semiconductor
  • the photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal.
  • the ISP outputs the digital image signal to the DSP for processing.
  • DSP converts digital image signals into standard RGB, YUV and other formats of image signals.
  • the electronic device 100 may include 1 or N cameras 193 , where N is a positive integer greater than 1.
  • a digital signal processor is used to process digital signals, in addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy and so on.
  • Video codecs are used to compress or decompress digital video.
  • the electronic device 100 may support one or more video codecs.
  • the electronic device 100 can play or record videos of various encoding formats, such as: Moving Picture Experts Group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4 and so on.
  • MPEG Moving Picture Experts Group
  • MPEG2 moving picture experts group
  • MPEG3 MPEG4
  • MPEG4 Moving Picture Experts Group
  • the NPU is a neural-network (NN) computing processor.
  • NN neural-network
  • Applications such as intelligent cognition of the electronic device 100 can be implemented through the NPU, such as image recognition, face recognition, speech recognition, text understanding, and the like.
  • the external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100 .
  • the external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example to save files like music, video etc in external memory card.
  • Internal memory 121 may be used to store computer executable program code, which includes instructions.
  • the internal memory 121 may include a storage program area and a storage data area.
  • the storage program area can store an operating system, an application program required for at least one function (such as a sound playback function, an image playback function, etc.), and the like.
  • the storage data area may store data (such as audio data, phone book, etc.) created during the use of the electronic device 100 and the like.
  • the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, universal flash storage (UFS), and the like.
  • the processor 110 executes various functional applications and data processing of the electronic device 100 by executing instructions stored in the internal memory 121 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 receiver 170B, a microphone 170C, an earphone interface 170D, an application processor, and the like. Such as music playback, recording, etc.
  • the audio module 170 is used for converting digital audio information into analog audio signal output, and also for converting analog audio input into digital audio signal. Audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be provided in the processor 110 , or some functional modules of the audio module 170 may be provided in the processor 110 .
  • Speaker 170A also referred to as a "speaker" is used to convert audio electrical signals into sound signals.
  • the electronic device 100 can listen to music through the speaker 170A, or listen to a hands-free call.
  • the receiver 170B also referred to as "earpiece" is used to convert audio electrical signals into sound signals.
  • the voice can be answered by placing the receiver 170B close to the human ear.
  • the microphone 170C also called “microphone” or “microphone” is used to convert sound signals into electrical signals.
  • the user can make a sound by approaching the microphone 170C through a human mouth, and input the sound signal into the microphone 170C.
  • the electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, which can implement a noise reduction function in addition to collecting sound signals. In other embodiments, the electronic device 100 may further be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and implement directional recording functions.
  • the earphone jack 170D is used to connect wired earphones.
  • the earphone interface 170D can be the USB interface 130, or can be a 3.5mm open mobile terminal platform (OMTP) standard interface, a cellular telecommunications industry association of the USA (CTIA) standard interface.
  • OMTP open mobile terminal platform
  • CTIA cellular telecommunications industry association of the USA
  • the pressure sensor 180A is used to sense pressure signals, and can convert the pressure signals into electrical signals.
  • the pressure sensor 180A may be provided on the display screen 194 .
  • the capacitive pressure sensor may be comprised of at least two parallel plates of conductive material.
  • the electronic device 100 determines the intensity of the pressure according to the change in capacitance.
  • a touch operation acts on the display screen 194
  • the electronic device 100 detects the intensity of the touch operation according to the pressure sensor 180A.
  • the electronic device 100 may also calculate the touched position according to the detection signal of the pressure sensor 180A.
  • touch operations acting on the same touch position but with different touch operation intensities may correspond to different operation instructions.
  • the instruction for viewing the short message is executed.
  • the instruction to create a new short message is executed.
  • the gyro sensor 180B may be used to determine the motion attitude of the electronic device 100 .
  • the angular velocity of electronic device 100 about three axes ie, x, y, and z axes
  • the gyro sensor 180B can be used for image stabilization.
  • the gyro sensor 180B detects the shaking angle of the electronic device 100, calculates the distance that the lens module needs to compensate according to the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse motion to achieve anti-shake.
  • the gyro sensor 180B can also be used for navigation and somatosensory game scenarios.
  • the air pressure sensor 180C is used to measure air pressure.
  • the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist in positioning and navigation.
  • the magnetic sensor 180D includes a Hall sensor.
  • the electronic device 100 can detect the opening and closing of the flip holster using the magnetic sensor 180D.
  • the electronic device 100 can detect the opening and closing of the flip according to the magnetic sensor 180D. Further, according to the detected opening and closing state of the leather case or the opening and closing state of the flip cover, characteristics such as automatic unlocking of the flip cover are set.
  • the acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes).
  • the magnitude and direction of gravity can be detected when the electronic device 100 is stationary. It can also be used to identify the posture of electronic devices, and can be used in applications such as horizontal and vertical screen switching, pedometers, etc.
  • the electronic device 100 can measure the distance through infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.
  • Proximity light sensor 180G may include, for example, light emitting diodes (LEDs) and light detectors, such as photodiodes.
  • the light emitting diodes may be infrared light emitting diodes.
  • the electronic device 100 emits infrared light to the outside through light emitting diodes.
  • Electronic device 100 uses photodiodes to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100 . When insufficient reflected light is detected, the electronic device 100 may determine that there is no object near the electronic device 100 .
  • the electronic device 100 can use the proximity light sensor 180G to detect that the user holds the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power.
  • Proximity light sensor 180G can also be used in holster mode, pocket mode automatically unlocks and locks the screen.
  • the ambient light sensor 180L is used to sense ambient light brightness.
  • the electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness.
  • the ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures.
  • the ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket, so as to prevent accidental touch.
  • the fingerprint sensor 180H is used to collect fingerprints.
  • the electronic device 100 can use the collected fingerprint characteristics to realize fingerprint unlocking, accessing application locks, taking pictures with fingerprints, answering incoming calls with fingerprints, and the like.
  • the temperature sensor 180J is used to detect the temperature.
  • the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold value, the electronic device 100 reduces the performance of the processor located near the temperature sensor 180J in order to reduce power consumption and implement thermal protection.
  • the electronic device 100 when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 caused by the low temperature.
  • the electronic device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.
  • Touch sensor 180K also called “touch device”.
  • the touch sensor 180K may be disposed on the display screen 194 , and the touch sensor 180K and the display screen 194 form a touch screen, also called a “touch screen”.
  • the touch sensor 180K is used to detect a touch operation on or near it.
  • the touch sensor can pass the detected touch operation to the application processor to determine the type of touch event.
  • Visual output related to touch operations may be provided through display screen 194 .
  • the touch sensor 180K may also be disposed on the surface of the electronic device 100 , which is different from the location where the display screen 194 is located.
  • the bone conduction sensor 180M can acquire vibration signals.
  • the bone conduction sensor 180M can acquire the vibration signal of the vibrating bone mass of the human voice.
  • the bone conduction sensor 180M can also contact the pulse of the human body and receive the blood pressure beating signal.
  • the bone conduction sensor 180M can also be disposed in the earphone, combined with the bone conduction earphone.
  • the audio module 170 can analyze the voice signal based on the vibration signal of the vocal vibration bone block obtained by the bone conduction sensor 180M, so as to realize the voice function.
  • the application processor can analyze the heart rate information based on the blood pressure beat signal obtained by the bone conduction sensor 180M, and realize the function of heart rate detection.
  • the keys 190 include a power-on key, a volume key, and the like. Keys 190 may be mechanical keys. It can also be a touch key.
  • the electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100 .
  • Motor 191 can generate vibrating cues.
  • the motor 191 can be used for vibrating alerts for incoming calls, and can also be used for touch vibration feedback.
  • touch operations acting on different applications can correspond to different vibration feedback effects.
  • the motor 191 can also correspond to different vibration feedback effects for touch operations on different areas of the display screen 194 .
  • Different application scenarios for example: time reminder, receiving information, alarm clock, games, etc.
  • the touch vibration feedback effect can also support customization.
  • the indicator 192 can be an indicator light, which can be used to indicate the charging state, the change of the power, and can also be used to indicate a message, a missed call, a notification, and the like.
  • the SIM card interface 195 is used to connect a SIM card.
  • the SIM card can be contacted and separated from the electronic device 100 by inserting into the SIM card interface 195 or pulling out from the SIM card interface 195 .
  • the electronic device 100 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
  • the SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card and so on. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the plurality of cards may be the same or different.
  • the SIM card interface 195 can also be compatible with different types of SIM cards.
  • the SIM card interface 195 is also compatible with external memory cards.
  • the electronic device 100 interacts with the network through the SIM card to implement functions such as call and data communication.
  • the electronic device 100 employs an eSIM, ie: an embedded SIM card.
  • the eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100 .
  • the software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture.
  • the embodiment of the present invention takes an Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100 as an example.
  • FIG. 2 is a block diagram of a software structure of an electronic device 100 according to an embodiment of the present invention.
  • the layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Layers communicate with each other through software interfaces.
  • the Android system is divided into four layers, which are, from top to bottom, an application layer, an application framework layer, an Android runtime (Android runtime) and a system library, and a kernel layer.
  • the application layer can include a series of application packages.
  • the application package can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and so on.
  • the application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer.
  • the application framework layer includes some predefined functions.
  • the application framework layer may include window managers, content providers, view systems, telephony managers, resource managers, notification managers, and the like.
  • a window manager is used to manage window programs.
  • the window manager can get the size of the display screen, determine whether there is a status bar, lock the screen, take screenshots, etc.
  • Content providers are used to store and retrieve data and make these data accessible to applications.
  • the data may include video, images, audio, calls made and received, browsing history and bookmarks, phone book, etc.
  • the view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and so on. View systems can be used to build applications.
  • a display interface can consist of one or more views.
  • the display interface including the short message notification icon may include a view for displaying text and a view for displaying pictures.
  • the phone manager is used to provide the communication function of the electronic device 100 .
  • the management of call status including connecting, hanging up, etc.).
  • the resource manager provides various resources for the application, such as localization strings, icons, pictures, layout files, video files and so on.
  • the notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages, and can disappear automatically after a brief pause without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc.
  • the notification manager can also display notifications in the status bar at the top of the system in the form of graphs or scroll bar text, such as notifications of applications running in the background, and notifications on the screen in the form of dialog windows. For example, text information is prompted in the status bar, a prompt sound is issued, the electronic device vibrates, and the indicator light flashes.
  • Android Runtime includes core libraries and a virtual machine. Android runtime is responsible for scheduling and management of the Android system.
  • the core library consists of two parts: one is the function functions that the java language needs to call, and the other is the core library of Android.
  • the application layer and the application framework layer run in virtual machines.
  • the virtual machine executes the java files of the application layer and the application framework layer as binary files.
  • the virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, safety and exception management, and garbage collection.
  • a system library can include multiple functional modules. For example: surface manager (surface manager), media library (Media Libraries), 3D graphics processing library (eg: OpenGL ES), 2D graphics engine (eg: SGL), etc.
  • surface manager surface manager
  • media library Media Libraries
  • 3D graphics processing library eg: OpenGL ES
  • 2D graphics engine eg: SGL
  • the Surface Manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications.
  • the media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files.
  • the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • the 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
  • 2D graphics engine is a drawing engine for 2D drawing.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer contains at least display drivers, camera drivers, audio drivers, and sensor drivers.
  • FIG. 3 is an example diagram of a graphical user interface (graphical user interface, GUI) of the image synthesis method according to the embodiment of the present application.
  • GUI graphical user interface
  • the electronic device is a mobile phone as an example to illustrate the image synthesis method provided by the embodiment of the present application.
  • the user selects an image as the first image whose background needs to be changed.
  • the user clicks on the background change control.
  • the mobile phone detects the user's operation and displays the recommended image to the user.
  • the way of displaying the background image is not limited.
  • the background image is displayed to the user through paging.
  • the background image of the displayed first page is shown, the first page A total of 9 background images are displayed; the background images shown here are obtained based on the first image, and are sorted from small to large according to the difference in shooting angle between the background image and the first image.
  • the user selects a background image from the displayed background images (in FIG.
  • the user selects the background image 1 by clicking as an example) as the second image; correspondingly, the mobile phone detects the user's selection operation and displays the user's selection to the user.
  • the background image as shown in part 33 in FIG. 3, presents the second image 320 to the user.
  • the user designates a position in the displayed second image 320 as the position where the character image separated from the first image is synthesized into the second image, and clicks the OK control.
  • the mobile phone receives the user's position designation operation, and the first image is combined.
  • the person images separated in the image 310 are synthesized to the position designated by the user in the second image 320 to obtain the target image.
  • the rationality and fusion of the target image obtained by using the image synthesis method of the present application are relatively higher.
  • FIG. 4 is a flowchart of an embodiment of an image synthesis method of the present application. As shown in FIG. 4 , the method may include:
  • Step 401 Preset a material library of background images on the server side.
  • the images in the material library may be images captured by an electronic device such as a mobile phone, which are authorized by the user to which the electronic device belongs and uploaded to the server, or may be images shot or collected by the material library provider.
  • the source of the image in the material library is not limited in this embodiment of the present application.
  • Each image in the material library can be set with: angle label and category label.
  • the angle tag is used to record the shooting angle information of the image, such as the shooting attitude angle
  • the classification tag is used to record the classification information of the image.
  • the material library can classify and store the images in the material library according to the classification tags of the images.
  • the shooting attitude angle is used to describe the angle at which the electronic device rotates around the xyz axis of the first coordinate system.
  • the method for establishing the first coordinate system is: take the origin of the mobile phone coordinate system as the origin of the first coordinate
  • the positive direction of the axis is the due west direction of the geography
  • the positive direction of the y-axis is the vertical upward direction
  • the positive direction of the z-axis is the due north direction of the geography.
  • the shooting attitude angle may include three angle parameters, namely: pitch angle ⁇ , azimuth angle ⁇ and roll angle ⁇ .
  • three types of angle parameters will be described respectively.
  • a method for establishing the coordinate system of a vertical screen mobile phone is shown, wherein, taking the physical center of the mobile phone as the origin, the right, top, and front three directions of the mobile phone are the positive directions of the x, y, and z axes, respectively.
  • the mobile phone coordinate system coincides with the first coordinate system.
  • Pitch angle ⁇ When the plane where the xz axis of the mobile phone coordinate system is located is parallel to the plane where the xz axis of the first coordinate system is located (that is, the ground or the horizontal plane), the elevation angle is 0 degrees.
  • the pitch angle is from 0 to -90 degrees change; if the top is getting closer and closer to the user and the bottom is getting farther and farther away from the user (at this time, it can be understood that the rear camera of the mobile phone is gradually shooting towards the sky), the pitch angle changes from 0 to 90 degrees.
  • Azimuth ⁇ The mobile phone rotates around the y-axis of the first coordinate system, the front of the mobile phone is 0 degrees to the true north, rotate clockwise, the azimuth changes from 0 to 360 degrees, 0 degrees true north, 90 degrees east, positive 180 degrees south, 270 degrees west.
  • Roll angle ⁇ When the plane where the yz axis of the mobile phone coordinate system is located coincides with the plane where the yz axis of the first coordinate system is located (that is, it is perpendicular to the horizontal plane), the roll angle of the mobile phone is 0 degrees, and the mobile phone surrounds the first coordinate system. If the z-axis is rotated, the roll angle changes from 0 to 90 degrees if it is rotated clockwise; if it is rotated counterclockwise, the roll angle changes from 0 to -90 degrees.
  • the vertical screen mobile phone is used as an example in Fig. 5, and it can also be extended to any electronic device, such as a horizontal screen mobile phone, etc.
  • a horizontal screen mobile phone it is only necessary to change the vertical screen mobile phone in the figure to a horizontal screen.
  • screen phones the definition of shooting attitude angle remains unchanged.
  • Classification tags of images may include, but are not limited to, tags of the following categories: scene information, and/or light information, and/or season information, and/or weather information, and the like.
  • the scene information is used to record the shooting scene of the image
  • the parameter values may include: indoor and outdoor; the light information is used to record the brightness and darkness of the image, and the parameter values may include: bright and dark; the season information is used to record the shooting season of the image,
  • the parameter values may include: spring, summer, autumn, and winter; the weather information is used to record the weather conditions when the image is taken, and the parameter values may include: sunny, rainy, snowy, and the like.
  • images can be classified and stored according to the above-mentioned classification tags of the images, so that the images in the material library are stored in a more orderly manner.
  • the user uses an electronic device to shoot an image, and after the user authorizes the electronic device, the classification information of the image and the image (with the classification label of the image in the material library) (corresponding to the recorded information), and shooting angle information (corresponding to the information recorded by the angle label of the image in the material library) are uploaded to the server where the material library is located, and the server classifies the images according to the classification information of the uploaded images and saves them to the material library. under the corresponding category.
  • Step 402 The electronic device acquires the user's background replacement operation for the first image.
  • This step may correspond to part 31 in FIG. 3 , and will not be repeated here.
  • Step 403 The electronic device acquires the shooting angle information and classification information of the first image, and uploads the acquired information to the server.
  • the shooting angle information may be the shooting attitude angle; the classification information may include: parameter values corresponding to each classification label in the material library.
  • the classification label of the image in the material library includes scene information, and the classification information of the image in this step may include: the parameter value of the scene information.
  • the shooting angle information and the classification information of the first image may be correspondingly determined by the electronic device when shooting the first image, and stored as parameters of the first image.
  • the electronic device can obtain the motion data of the electronic device based on sensors such as acceleration sensor and magnetic sensor set in itself, and use the Euler kinematic equation to calculate the Euler angle based on the electronic device coordinate system and the first coordinate system of the electronic device.
  • the Euler angle calculated by the motion data when the electronic device captures the first image includes three components, namely the pitch angle ⁇ , the azimuth angle ⁇ and the roll angle ⁇ corresponding to the shooting attitude angle of the first image.
  • the classification information of the first image may be determined by the electronic device, for example:
  • the scene information may be manually set by the user, or may be determined by inputting the first image into a preset scene recognition model.
  • a scene recognition model can be preset in the electronic device, the scene recognition model can be obtained by training a convolutional neural network, and the training principle can be: collecting a certain number of images in indoor and outdoor scenes as training. sample, and set a scene label marked indoor or outdoor for each training sample, input the training sample into the convolutional neural network for training, and obtain a scene recognition model, which is a binary classification that can recognize indoor and outdoor images. device;
  • the light information may be determined by the electronic device based on the brightness of the image.
  • the season information may be determined by the electronic device based on the time when the first image was captured and the geographic location of the electronic device. For example, when the electronic device captured the first image in January and in Beijing, the season information of the first image is: winter; The electronic device captures the first image in January in Sydney, and the season information of the first image is summer.
  • the weather information can be obtained by the electronic device from a weather forecast related App installed on the electronic device when the first image is taken, and then the weather information of the first image is determined as sunny, rainy, or snowy.
  • Step 404 The server finds the background image to be selected according to the classification information of the first image.
  • the material set is classified and stored according to the classification label.
  • the classification information of the first image corresponds to the classification label of the image in the material library. According to the classification information of the first image, several pieces corresponding to the classification information of the first image can be found from the material library. Image, the image found from the material library is the background image to be selected.
  • the classification information of the first image is: indoor, bright, you can find it from the material library Several images under the classification branch of scene information-indoor, light information-bright are used as background images to be selected.
  • Searching for the background image to be selected according to the classification information of the first image can filter out the images in the material library that do not match the classification information of the first image, so as to prevent the background image to be displayed to the user from being too complicated and unreasonable.
  • An image is an image taken indoors and in winter, and the person in the first image is wearing thick clothes, and the information recorded in the classification tag is (indoor, summer) or (outdoor, summer) images do not need to be selected as backgrounds
  • the image is displayed to the user as a recommended background image in the subsequent steps. Otherwise, it is obviously unreasonable to recommend an image of a summer garden to the user as a background image.
  • the information recorded in the classification label can be The image for (outdoor, winter) is found from the material library, and then recommended to the user as the candidate background image.
  • Step 405 The server calculates the difference value of the shooting angle between each background image to be selected and the first image according to the shooting angle information of the first image and the shooting angle information of the background image to be selected.
  • calculating a shooting angle difference value between a background image to be selected and the first image may include:
  • Step 406 The server sorts the background images to be selected according to the angle difference values corresponding to each background image to be selected, and sends the background images to be selected to the electronic device in the sorted order.
  • the server finds the background image to be selected according to the classification information of the first picture, calculates the shooting angle difference value according to the shooting angle information of each background image to be selected and the shooting angle information of the first picture, and calculates the shooting angle difference value based on the shooting angle difference value.
  • the background images to be selected can be sorted in descending order of the difference value of the shooting angle.
  • the shooting angle of the background image to be selected first browsed by the user can be closer to that of the first image. According to the shooting angle, the fusion of the person image and the background image in the target image obtained after image synthesis according to the background image to be selected by the user is relatively more reasonable, natural and coordinated.
  • Step 407 The electronic device receives the background image to be selected sent by the server, and displays the background image to be selected to the user.
  • this step may correspond to part 32 in FIG. 3 , and details are not described here.
  • Step 408 The electronic device receives the user's selection operation for a displayed background image, and uses the background image selected by the user as the second image.
  • this step may correspond to part 32 in FIG. 3 , and details are not described here.
  • Step 409 The electronic device acquires shooting angle information of the second image.
  • the shooting angle information of the second image may be acquired by the electronic device from the server after the second image is determined, or carried when the server sends the background image to be selected to the electronic device for display.
  • Step 410 The electronic device performs three-dimensional (3D, three dimensional) perspective transformation on the second image according to the shooting angle information of the first image and the shooting angle information of the second image, so that the shooting angle of the second image reaches or is close to the first image the shooting angle to get the target background image.
  • 3D, three dimensional three-dimensional
  • the 3D perspective transformation of the second image can be realized by using the 3D Kens Burns Effect (3D Kens Burns Effect) algorithm.
  • 3D Kens Burns Effect 3D Kens Burns Effect
  • a virtual camera is set for the second image according to the shooting attitude angle of the second image. position, and perform 3D scene geometry estimation on the image in the second image to obtain an estimated distance between each pixel in the second image and the virtual camera; rotate the shooting direction of the virtual camera to the shooting attitude angle of the first image , and then adjust the second image according to the rotation of the virtual camera.
  • the estimated value of the distance between the pixel and the virtual camera can also be regarded as the estimated value of the actual distance between the real object corresponding to the pixel and the electronic device that captures the second image.
  • the pitch angle ⁇ is rotated first, then the roll angle ⁇ is rotated, and finally the azimuth angle ⁇ is rotated.
  • the rotation of the shooting attitude angle of the virtual camera under this algorithm has a certain angle limit.
  • the processing The shooting attitude angle of the target background image can be made the same as the shooting attitude angle of the first image.
  • the angle difference between the shooting attitude angle of the second image and the shooting attitude angle of the first image exceeds the angle limit, it may not be possible to make the target
  • the shooting attitude angle of the background image is the same as the shooting attitude angle of the first image, but through this process, the shooting attitude angle of the target background image can be made closer to the shooting attitude angle of the first image.
  • the shooting angle of the second image can reach or be close to the shooting angle of the first image, thereby reducing the shooting angle difference between the person image and the second image, so that the difference between the person image and the second image is reduced.
  • the shooting angles should be as close to or even consistent as possible, so that the target image obtained after image synthesis is more reasonable, natural and coordinated.
  • Step 411 The electronic device displays the target background image to the user, obtains the position information of the person image in the target background image specified by the user, and determines the first estimated distance value corresponding to the position information.
  • the implementation of this step can correspond to part 33 in FIG. 3; or, the electronic device can also separate the person image from the first image, place the person image on the target background image, and drag the person image by the user, thereby specifying the person image in the The position in the target background image.
  • the location information may be information of a point or information of an area.
  • the estimated value of the distance between the pixel and the virtual camera can generally be obtained when performing 3D perspective transformation on the second image in step 410. If the distance between each pixel in the second image and the virtual camera is not determined during the processing in step 410 The estimated value can be calculated by, for example, the 3D Kens Burns Effect algorithm shown in step 410. According to the distance estimation value between the pixel at the location information and the virtual camera, the first distance estimation value corresponding to the location information can be obtained. Wherein, if the location information indicates a point, the estimated distance between the pixel corresponding to the point and the virtual camera may be determined as the first estimated distance corresponding to the location information.
  • the estimated distance between one pixel or multiple pixels and the virtual camera, to determine the first estimated distance corresponding to the location information if the estimated distance corresponding to the location information is determined according to the estimated distance between multiple pixels included in the area and the virtual camera.
  • the first distance estimation value corresponding to the position information can be determined by calculating the mean value of the distance estimation values corresponding to a plurality of pixels.
  • Step 412 The electronic device separates the person image from the first image, and scales the person image according to the first estimated distance value corresponding to the position information to obtain the target person image.
  • the step of separating the person image from the first image by the electronic device may be performed between steps 402 and 412 of scaling the person image according to the first estimated distance value corresponding to the position information, and steps 403 to 411
  • the order of execution between them is not limited.
  • the person image may be automatically separated by the electronic device, or the user may select the person image to be separated from the first image. If selected by the user, the first image can be displayed to the user, and the user can perform an area selection operation.
  • the electronic device can determine the person image to be separated based on the user's area selection operation, and then separate the person image from the first image. .
  • this step according to the principle that the distance between the human eyes is basically the same, it can be pre-determined that at different shooting distances between the person being photographed and the camera, the average distance between the human eyes in the captured images with the same resolution
  • the number of pixels occupied for example, if the distance between the human and the camera is 10m, the number of pixels occupied by the average distance between the human eyes in the captured image is x1, and the distance between the human and the camera is 20m.
  • the number of pixels is x2, and so on.
  • the electronic device may obtain the number of pixels occupied by the distance between the human eyes of the separated person image, determine the second estimated distance value corresponding to the person image according to the number of pixels occupied by the distance between the human eyes, and determine the first distance corresponding to the position information according to the number of pixels occupied by the distance between the human eyes.
  • the estimated value and the second estimated distance corresponding to the person image are scaled to the person image, that is, the target person image can be obtained.
  • the second estimated distance value is also the estimated value of the distance between the person corresponding to the person image and the electronic device that photographed the first image when the first image is photographed.
  • the 3D Kens Burns Effect algorithm can be used to calculate the estimated distance of each pixel in the first image relative to the virtual camera, so that the estimated distance corresponding to the pixels included in the person image can be obtained.
  • the second distance estimation value corresponding to the person image can be determined according to the distance estimation value corresponding to the pixels included in the person image, for example, taking the average value of the distance estimation values of all the pixels included in the person image, or taking a certain preset position such as the eye The distance estimate of the pixel, etc.
  • the target person image can be obtained by scaling the person image according to the first estimated distance value corresponding to the position information and the second estimated distance value corresponding to the person image.
  • the image of the person is scaled according to the first estimated distance value corresponding to the position information, so that the size of the image of the person is closer to the size of the person photographed when the person actually stands at the same position in the actual scene corresponding to the second image, thereby It makes the synthesized target image more reasonable, natural and coordinated visually.
  • Step 413 The electronic device adjusts the color parameters of the target person image and/or the target background image, and synthesizes the adjusted target person image and the target background image to obtain the target image.
  • Color parameters may include color temperature, and/or contrast, among others.
  • the color parameters of the target person image and the target background image can be made closer, thereby making the synthesized target image more natural and reasonable.
  • the color temperature of the target background image can be calculated, and the color temperature of the target person image can be adjusted accordingly, so that the color temperature of the target person image is closer to the color temperature of the target background image.
  • the color temperature calculation method of the image will not be repeated in this embodiment of the present application.
  • the color temperature estimation method in the automatic white balance algorithm may be used to calculate the color temperature of the target background image.
  • the target image obtained after synthesis can be visually more harmonious, reasonable and natural in color.
  • Step 414 The electronic device presents the target image to the user.
  • This step may correspond to part 34 in FIG. 3 , and will not be repeated here.
  • the image of the person edited by the user is directly synthesized into the background image selected by the user according to the size of the image. , it is easy to cause problems such as poor overall coordination of the synthesized image, image distortion, scene logic errors, and light and shadow differences, resulting in distorted and unnatural synthesized images.
  • the image synthesis method of the embodiment of the present application solves the above-mentioned problems existing in the process of cutout and background replacement, reduces the difference in shooting angle between the first image and the second image, and can also reduce the difference in scene logic and color. And/or the difference in the depth of the field of view and the scene, the target image obtained after image synthesis is visually more reasonable, natural, and coordinated, and the user experience is improved.
  • the method of the embodiment of the present application can also be extended from the person image to the image of any object. , such as animal images, object images, etc., the image that is separated from the first image and needs to be synthesized with the second image is called the foreground image hereinafter.
  • the method in this embodiment of the present application can be extended to a method for synthesizing images in the video, so as to replace the background image of the image in the video.
  • each frame of image in the video can be used as the first image in the embodiment of the present application. .
  • FIG. 7 is a flowchart of an embodiment of an image synthesis method of the present application, which can be applied to an electronic device. As shown in FIG. 7 , the method may include:
  • Step 701 receive the background replacement operation of the user for the first image, and obtain the shooting angle information of the first image;
  • Step 702 Acquire a second image and shooting angle information of the second image
  • Step 703 Perform 3D perspective transformation on the second image according to the shooting angle information of the first image and the shooting angle information of the second image, so that the shooting angle of the second image reaches or is close to the shooting angle of the first image, and the target background image is obtained;
  • Step 704 Perform image synthesis on the foreground image separated from the first image and the target background image to obtain a target image.
  • the foreground image may be the person image in the embodiment shown in FIG. 4 , or may be an image of other existing objects, such as animal images, object images, and the like.
  • the electronic device may display the first image to the user, and the user may perform a region selection operation.
  • the electronic device may use the region indicated by the user's region selection operation as the region of the foreground image, and then separate the foreground image from the first image.
  • acquiring the second image in step 702 may include:
  • the background images to be selected that match the preset classification information of the first image; the displayed background images to be selected are sorted from small to large according to the shooting angle difference between the background images to be selected and the first image; the background images to be selected The shooting angle difference value with the first image is calculated according to the shooting angle information of the background image to be selected and the shooting angle information of the first image;
  • the background image to be selected indicated by the selection operation is used as the second image.
  • the electronic device can also obtain the second image locally from the electronic device, for example, the user selects an image in the album of the electronic device as the second image, and accordingly, the electronic device can obtain the first image selected by the user according to the user's operation. Second image.
  • acquiring a background image to be selected that matches the preset classification information of the first image may include:
  • the background image to be selected is sorted by the server according to the difference value of the shooting angle between the background image to be selected and the first image, the background image to be selected and the first image are sorted by the server.
  • the difference value of the shooting angle between the images is calculated by the server according to the shooting angle information of the background image to be selected and the shooting angle information of the first image.
  • step 704 may include:
  • Display the target background image receive the user's position designation operation on the target background image, and obtain the position information of the user's designated position on the target background image;
  • the target foreground image is synthesized to the position indicated by the position information in the target background image to obtain the target image.
  • the target foreground image before synthesizing the target foreground image to the position indicated by the position information on the target background image, before obtaining the target image, it may further include:
  • the shooting angle information may include: a shooting attitude angle, and the shooting attitude angle includes: a pitch angle, an azimuth angle, and a roll angle.
  • FIG. 8 is a structural diagram of an embodiment of an image synthesis apparatus of the present application, which can be applied to electronic equipment. As shown in FIG. 8 , the apparatus 80 may include:
  • the obtaining unit 81 is configured to receive the user's background replacement operation for the first image, obtain the shooting angle information of the first image; obtain the second image and the shooting angle information of the second image;
  • the transformation unit 82 is configured to perform 3D perspective transformation on the second image according to the shooting angle information of the first image and the shooting angle information of the second image, so that the shooting angle of the second image reaches or is close to the shooting angle of the first image, and the target is obtained. background image;
  • the synthesis unit 83 is configured to perform image synthesis between the foreground image separated from the first image and the target background image to obtain the target image.
  • the acquiring unit may be specifically configured to: acquire preset classification information of the first image; acquire and display a background image to be selected that matches the preset classification information of the first image; the background image to be displayed is displayed according to the background image to be selected.
  • the shooting angle difference value between the image and the first image is sorted from small to large; the shooting angle difference value between the background image to be selected and the first image is based on the shooting angle information of the background image to be selected and the shooting angle information of the first image Obtained by calculation; after receiving the user's selection operation on the background image to be selected, the background image to be selected indicated by the selection operation is used as the second image.
  • the acquiring unit may be specifically configured to: send the shooting angle information of the first image and the preset classification information to the server; receive the background image to be selected that matches the preset classification information of the first image sent by the server, and the to-be-selected background image is sent to the server.
  • the background images are sorted by the server according to the shooting angle difference value between the background image to be selected and the first image, and the shooting angle difference value between the background image to be selected and the first image is sorted by the server according to the shooting angle information of the background image to be selected, and The shooting angle information of the first image is calculated.
  • the synthesizing unit can be specifically used to: display the target background image, receive the user's position specifying operation on the target background image, and obtain the position information of the user's specified position on the target background image; determine the first distance corresponding to the position information. estimated value; zoom the foreground image according to the first distance estimated value to obtain the target foreground image; synthesize the target foreground image to the position indicated by the position information in the target background image to obtain the target image.
  • the synthesizing unit may also be used to: adjust the color parameters of the target foreground image and/or the target background image.
  • the shooting angle information may include: a shooting attitude angle, and the shooting attitude angle includes: a pitch angle, an azimuth angle, and a roll angle.
  • the apparatus provided by the embodiment shown in FIG. 8 can be used to implement the technical solutions of the method embodiments shown in FIG. 4 to FIG. 7 of the present application.
  • the implementation principle and technical effect reference may be made to the related descriptions in the method embodiments.
  • each unit of the apparatus shown in FIG. 8 above is only a division of logical functions, and in actual implementation, it may be fully or partially integrated into a physical entity, or may be physically separated.
  • these units can all be implemented in the form of software calling through processing elements; they can also all be implemented in hardware; some units can also be implemented in the form of software calling through processing elements, and some units can be implemented in hardware.
  • the synthesis unit may be a separately established processing element, or may be integrated in a certain chip of an electronic device.
  • the implementation of other units is similar.
  • all or part of these units can be integrated together, and can also be implemented independently.
  • each step of the above-mentioned method or each of the above-mentioned units may be completed by an integrated logic circuit of hardware in the processor element or an instruction in the form of software.
  • the above units may be one or more integrated circuits configured to implement the above method, such as: one or more specific integrated circuits (Application Specific Integrated Circuit; hereinafter referred to as: ASIC), or, one or more microprocessors Digital Singnal Processor (hereinafter referred to as: DSP), or, one or more Field Programmable Gate Array (Field Programmable Gate Array; hereinafter referred to as: FPGA), etc.
  • ASIC Application Specific Integrated Circuit
  • DSP Digital Singnal Processor
  • FPGA Field Programmable Gate Array
  • these units can be integrated together and implemented in the form of a system-on-a-chip (System-On-a-Chip; hereinafter referred to as: SOC).
  • Embodiments of the present application further provide an electronic device, which may include: a display screen; one or more processors; a memory; multiple application programs; and one or more computer programs.
  • the above-mentioned one or more computer programs are stored in the above-mentioned memory, and the above-mentioned one or more computer programs include instructions that, when the above-mentioned instructions are executed by the above-mentioned equipment, cause the above-mentioned equipment to perform the following steps:
  • 3D perspective transformation is performed on the second image according to the shooting angle information of the first image and the shooting angle information of the second image, so that the shooting angle of the second image reaches or is close to the shooting angle of the first image, and the target background image is obtained;
  • the foreground image separated from the first image is combined with the target background image to obtain the target image.
  • the foreground image may be the person image in the embodiment shown in FIG. 4 , or may be an image of other existing objects, such as animal images, object images, and the like.
  • the electronic device may display the first image to the user, and the user may perform a region selection operation.
  • the electronic device may use the region indicated by the user's region selection operation as the region of the foreground image, and then separate the foreground image from the first image.
  • the step of acquiring the second image may include:
  • the displayed background images to be selected are sorted according to the difference value of the shooting angle between the background images to be selected and the first image;
  • the shooting angle difference value between the images is calculated according to the shooting angle information of the background image to be selected and the shooting angle information of the first image;
  • the background image to be selected indicated by the selection operation is used as the second image.
  • the electronic device can also obtain the second image locally from the electronic device, for example, the user selects an image in the album of the electronic device as the second image, and accordingly, the electronic device can obtain the first image selected by the user according to the user's operation. Second image.
  • the step of acquiring a background image to be selected that matches the preset classification information of the first image may include:
  • the background images to be selected that match the preset classification information of the first image sent by the server are received, the background images to be selected are sorted by the server according to the difference in shooting angle between the background images to be selected and the first image, and the background images to be selected are sorted from small to large.
  • the difference value of the shooting angle between the image and the first image is calculated by the server according to the shooting angle information of the background image to be selected and the shooting angle information of the first image.
  • the step of performing image synthesis between the foreground image separated from the first image and the target background image to obtain the target image may include:
  • Display the target background image receive the user's position designation operation on the target background image, and obtain the position information of the user's designated position on the target background image;
  • the target foreground image is synthesized to the position indicated by the position information in the target background image to obtain the target image.
  • the step of synthesizing the target foreground image to the position indicated by the position information on the target background image may further include:
  • the shooting angle information may include: a shooting attitude angle, and the shooting attitude angle includes: a pitch angle, an azimuth angle, and a roll angle.
  • the present application also provides an electronic device, the device includes a storage medium and a central processing unit, the storage medium may be a non-volatile storage medium, and a computer-executable program is stored in the storage medium, and the central processing unit is connected to the central processing unit.
  • the non-volatile storage medium is connected, and the computer-executable program is executed to implement the method provided by the embodiments shown in FIG. 4 to FIG. 7 of the present application.
  • Embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when it runs on a computer, the computer causes the computer to execute the programs provided by the embodiments shown in FIG. 4 to FIG. 7 of the present application. method.
  • An embodiment of the present application further provides a computer program product, where the computer program product includes a computer program that, when running on a computer, enables the computer to execute the methods provided by the embodiments shown in FIGS. 4 to 7 of the present application.
  • “at least one” refers to one or more, and “multiple” refers to two or more.
  • “And/or”, which describes the association relationship of the associated objects means that there can be three kinds of relationships, for example, A and/or B, which can indicate the existence of A alone, the existence of A and B at the same time, and the existence of B alone. where A and B can be singular or plural.
  • the character “/” generally indicates that the associated objects are an “or” relationship.
  • “At least one of the following” and similar expressions refer to any combination of these items, including any combination of single or plural items.
  • At least one of a, b, and c may represent: a, b, c, a and b, a and c, b and c or a and b and c, where a, b, c may be single, or Can be multiple.
  • any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
  • the technical solution of the present application can be embodied in the form of a software product in essence, or the part that contributes to the prior art or the part of the technical solution.
  • the computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes: U disk, mobile hard disk, Read-Only Memory (Read-Only Memory; hereinafter referred to as: ROM), Random Access Memory (Random Access Memory; hereinafter referred to as: RAM), magnetic disk or optical disk and other various A medium on which program code can be stored.
  • ROM Read-Only Memory
  • RAM Random Access Memory
  • magnetic disk or optical disk and other various A medium on which program code can be stored.

Abstract

Provided are an image synthesis method and an electronic device. The method comprises: an electronic device receiving a background replacement operation of a user for a first image, and acquiring photographic angle information of the first image; acquiring a second image and photographic angle information of the second image; performing 3D viewing angle transformation on the second image according to the photographic angle information of the first image and the photographic angle information of the second image, such that a photographic angle of the second image reaches or is approximate to a photographic angle of the first image, so as to obtain a target background image; and performing image synthesis on a foreground image separated from the first image, and the target background image, so as to obtain a target image. By means of the method, the problem of a target image obtained after image synthesis having serious visual distortion can be ameliorated, thereby improving the user experience.

Description

图像合成方法和电子设备Image synthesis method and electronic device 技术领域technical field
本申请涉及智能终端技术领域,特别涉及一种图像合成方法和电子设备。The present application relates to the technical field of intelligent terminals, and in particular, to an image synthesis method and an electronic device.
背景技术Background technique
目前,电子设备的很多图像编辑相关应用(APP,application)中为用户提供抠图换背景的功能。抠图换背景是从用户指定的第一图像中分离出指定人物图像,将分离出来的人物图像合成至第二图像中,得到目标图像的过程。合成得到的目标图像中第二图像作为了分离出来的人物图像的背景图像,实现了人物图像的背景更换。At present, many image editing related applications (APPs, applications) of electronic devices provide users with the function of cutting out images and changing backgrounds. Cutout and background change is a process of separating a specified person image from a first image specified by a user, and synthesizing the separated person image into a second image to obtain a target image. The second image in the synthesized target image is used as the background image of the separated person image, thereby realizing the background replacement of the person image.
现有技术主要专注于如何将人物图像更好的从第一图像中分离出来,而在将分离出来的人物图像合成至第二图像中时,往往由用户对人物图像进行缩放,之后,电子设备将人物图像和第二图像直接合成,得到目标图像。这样合成出来的目标图像往往存在人物图像和背景图像不搭配等问题,造成目标图像在视觉上失真严重,影响用户体验。The prior art mainly focuses on how to better separate the person image from the first image, and when synthesizing the separated person image into the second image, the user often scales the person image, and then the electronic device The target image is obtained by directly synthesizing the person image and the second image. The target image synthesized in this way often has problems such as mismatch between the character image and the background image, resulting in serious visual distortion of the target image and affecting user experience.
发明内容SUMMARY OF THE INVENTION
本申请提供了一种图像合成方法和电子设备,能够改善目标图像视觉上失真严重的问题,提升用户体验。The present application provides an image synthesis method and electronic device, which can improve the problem of serious visual distortion of a target image and improve user experience.
第一方面,本申请实施例提供了一种图像合成方法,应用于电子设备,包括:In a first aspect, an embodiment of the present application provides an image synthesis method, which is applied to an electronic device, including:
接收到用户针对第一图像的背景更换操作,获取第一图像的拍摄角度信息;Receive the background replacement operation of the user for the first image, and obtain the shooting angle information of the first image;
获取第二图像、以及第二图像的拍摄角度信息;acquiring the second image and the shooting angle information of the second image;
根据第一图像的拍摄角度信息和第二图像的拍摄角度信息对第二图像进行3D视角变换,使得第二图像的拍摄角度达到或接近第一图像的拍摄角度,得到目标背景图像;3D perspective transformation is performed on the second image according to the shooting angle information of the first image and the shooting angle information of the second image, so that the shooting angle of the second image reaches or is close to the shooting angle of the first image, and the target background image is obtained;
将从第一图像中分离出的前景图像与目标背景图像进行图像合成,得到目标图像。The foreground image separated from the first image is combined with the target background image to obtain the target image.
该方法根据第一图像的拍摄角度信息和第二图像的拍摄角度信息对第二图像进行3D视角变换,使得第二图像的拍摄角度达到或接近第一图像的拍摄角度,得到目标背景图像,从而相对于第二图像,目标背景图像的拍摄角度与第一图像的拍摄角度相同或更为接近,也即前景图像与目标背景图像的拍摄角度相同或者更为接近,从而相对于现有技术中将前景图像与第二图像进行图像合成得到的图像,本申请实施例的方法得到的目标图像在视觉上更为合理和协调,从而改善了现有技术中目标图像视觉上失真严重的问题,提升用户体验。The method performs 3D perspective transformation on the second image according to the shooting angle information of the first image and the shooting angle information of the second image, so that the shooting angle of the second image reaches or is close to the shooting angle of the first image, and the target background image is obtained, thereby Compared with the second image, the shooting angle of the target background image is the same or closer to the shooting angle of the first image, that is, the shooting angle of the foreground image and the target background image is the same or closer. For the image obtained by performing image synthesis between the foreground image and the second image, the target image obtained by the method of the embodiment of the present application is more visually reasonable and coordinated, thereby improving the problem of serious visual distortion of the target image in the prior art, and improving the user experience. experience.
在一种可能的实现方式中,获取第二图像,包括:In a possible implementation manner, acquiring the second image includes:
获取第一图像的预设分类信息;obtaining preset classification information of the first image;
获取并展示与第一图像的预设分类信息匹配的待选背景图像;展示的待选背景图像按照待选背景图像与第一图像之间的拍摄角度差异值从小到大排序;待选背景图像与第一图像之间的拍摄角度差异值根据待选背景图像的拍摄角度信息、以及第一图像的拍摄角度信息计算得到;Obtain and display the background images to be selected that match the preset classification information of the first image; the displayed background images to be selected are sorted from small to large according to the shooting angle difference between the background images to be selected and the first image; the background images to be selected The shooting angle difference value with the first image is calculated according to the shooting angle information of the background image to be selected and the shooting angle information of the first image;
接收到用户针对于待选背景图像的选择操作,将选择操作指示的待选背景图像作为第二图像。After receiving the user's selection operation on the background image to be selected, the background image to be selected indicated by the selection operation is used as the second image.
该方法中,向用户展示的待选背景图像按照待选背景图像与第一图像之间的拍摄角度差异值从小到大排序,从而使得用户优先浏览到的待选背景图像的拍摄角度更为接近第一图像的拍摄角度,从而根据用户选择的待选背景图像进行图像合成后得到的目标图像中人物图像和背景图像的融合相对更为合理、自然、协调。In this method, the background images to be selected displayed to the user are sorted according to the shooting angle difference between the background image to be selected and the first image from small to large, so that the shooting angles of the background images to be selected preferentially browsed by the user are closer to each other. The shooting angle of the first image, so that the fusion of the person image and the background image in the target image obtained after image synthesis according to the background image to be selected by the user is relatively more reasonable, natural and coordinated.
在一种可能的实现方式中,获取与第一图像的预设分类信息匹配的待选背景图像,包括:In a possible implementation manner, acquiring a background image to be selected that matches the preset classification information of the first image includes:
向服务器发送第一图像的拍摄角度信息、以及预设分类信息;sending the shooting angle information of the first image and the preset classification information to the server;
接收服务器发送的与第一图像的预设分类信息匹配的待选背景图像,待选背景图像由服务器按照待选背景图像与第一图像之间的拍摄角度差异值排序,待选背景图像与第一图像之间的拍摄角度差异值由服务器根据待选背景图像的拍摄角度信息、以及第一图像的拍摄角度信息计算得到。Receive the background image to be selected that matches the preset classification information of the first image sent by the server, the background image to be selected is sorted by the server according to the difference value of the shooting angle between the background image to be selected and the first image, the background image to be selected and the first image are sorted by the server. The difference value of the shooting angle between the images is calculated by the server according to the shooting angle information of the background image to be selected and the shooting angle information of the first image.
在一种可能的实现方式中,将从第一图像中分离出的前景图像与目标背景图像进行图像合成,得到目标图像,包括:In a possible implementation manner, image synthesis is performed on the foreground image separated from the first image and the target background image to obtain the target image, including:
展示目标背景图像,接收到用户在目标背景图像上的位置指定操作,得到用户在目标背景图像上指定位置的位置信息;Display the target background image, receive the user's position designation operation on the target background image, and obtain the position information of the user's designated position on the target background image;
确定位置信息对应的第一距离估计值;determining the first distance estimation value corresponding to the location information;
根据第一距离估计值对前景图像进行缩放,得到目标前景图像;Scaling the foreground image according to the first distance estimation value to obtain the target foreground image;
将目标前景图像合成至目标背景图像中位置信息指示的位置,得到目标图像。The target foreground image is synthesized to the position indicated by the position information in the target background image to obtain the target image.
根据第一距离估计值对前景图像进行缩放,可以使得前景图像的大小更接近于真实拍摄得到的图像大小,使得目标图像在视觉上更为合理和协调。By scaling the foreground image according to the first distance estimation value, the size of the foreground image can be made closer to the size of the image obtained by real shooting, so that the target image is visually more reasonable and coordinated.
在一种可能的实现方式中,将目标前景图像合成至目标背景图像上位置信息指示的位置,得到目标图像之前,还包括:In a possible implementation manner, before synthesizing the target foreground image to the position indicated by the position information on the target background image, before obtaining the target image, the method further includes:
对目标前景图像和/或目标背景图像的颜色参数进行调整。Adjust the color parameters of the target foreground image and/or the target background image.
通过对目标前景图像和/或目标背景图像的颜色参数进行调整,可以使得目标前景图像和目标目镜图像的颜色更为接近,合成得到的目标图像在两个图像的边界处融合性高,使得目标图像在视觉上更为合理和协调。By adjusting the color parameters of the target foreground image and/or the target background image, the colors of the target foreground image and the target eyepiece image can be made closer, and the synthesized target image has high fusion at the boundary of the two images, so that the target Images are more visually plausible and coordinated.
在一种可能的实现方式中,拍摄角度信息包括:拍摄姿态角,拍摄姿态角包括:俯仰角、方位角和横滚角。In a possible implementation manner, the shooting angle information includes: a shooting attitude angle, and the shooting attitude angle includes: a pitch angle, an azimuth angle, and a roll angle.
第二方面,本申请实施例提供一种电子设备,包括:In a second aspect, an embodiment of the present application provides an electronic device, including:
显示屏;一个或多个处理器;存储器;以及一个或多个计算机程序,其中一个或多个计算机程序被存储在存储器中,一个或多个计算机程序包括指令,当指令被设备执行时,使得设备执行以下步骤:a display screen; one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, the one or more computer programs including instructions that, when executed by the device, cause The device performs the following steps:
接收到用户针对第一图像的背景更换操作,获取第一图像的拍摄角度信息;Receive the background replacement operation of the user for the first image, and obtain the shooting angle information of the first image;
获取第二图像、以及第二图像的拍摄角度信息;acquiring the second image and the shooting angle information of the second image;
根据第一图像的拍摄角度信息和第二图像的拍摄角度信息对第二图像进行3D视 角变换,使得第二图像的拍摄角度信息达到或接近第一图像的拍摄角度信息,得到目标背景图像;According to the shooting angle information of the first image and the shooting angle information of the second image, 3D perspective transformation is performed on the second image, so that the shooting angle information of the second image reaches or is close to the shooting angle information of the first image, and the target background image is obtained;
将从第一图像中分离出的前景图像合成至目标背景图像,得到目标图像。The foreground image separated from the first image is synthesized into the target background image to obtain the target image.
在一种可能的实现方式中,当指令被设备执行时,使得获取第二图像的步骤,包括:In a possible implementation manner, when the instruction is executed by the device, the step of acquiring the second image includes:
获取第一图像的预设分类信息;obtaining preset classification information of the first image;
获取并展示与第一图像的预设分类信息匹配的待选背景图像;展示的待选背景图像按照待选背景图像与第一图像之间的拍摄角度差异值排序;待选背景图像与第一图像之间的拍摄角度差异值根据待选背景图像的拍摄角度信息、以及第一图像的拍摄角度信息计算得到;Obtain and display the background images to be selected that match the preset classification information of the first image; the displayed background images to be selected are sorted according to the difference value of the shooting angle between the background images to be selected and the first image; The shooting angle difference value between the images is calculated according to the shooting angle information of the background image to be selected and the shooting angle information of the first image;
接收到用户针对于待选背景图像的选择操作,将选择操作指示的待选背景图像作为第二图像。After receiving the user's selection operation on the background image to be selected, the background image to be selected indicated by the selection operation is used as the second image.
在一种可能的实现方式中,指令被设备执行时,使得获取与第一图像的预设分类信息匹配的待选背景图像的步骤,包括:In a possible implementation manner, when the instruction is executed by the device, the step of obtaining a background image to be selected that matches the preset classification information of the first image includes:
向服务器发送第一图像的拍摄角度信息、以及预设分类信息;sending the shooting angle information of the first image and the preset classification information to the server;
接收服务器发送的与第一图像的预设分类信息匹配的待选背景图像,待选背景图像由服务器按照待选背景图像与第一图像之间的拍摄角度差异值排序,待选背景图像与第一图像之间的拍摄角度差异值由服务器根据待选背景图像的拍摄角度信息、以及第一图像的拍摄角度信息计算得到。Receive the background image to be selected that matches the preset classification information of the first image sent by the server, the background image to be selected is sorted by the server according to the difference value of the shooting angle between the background image to be selected and the first image, the background image to be selected and the first image are sorted by the server. The difference value of the shooting angle between the images is calculated by the server according to the shooting angle information of the background image to be selected and the shooting angle information of the first image.
在一种可能的实现方式中,当指令被设备执行时,使得将从第一图像中分离出的前景图像与目标背景图像进行图像合成,得到目标图像的步骤,包括:In a possible implementation manner, when the instruction is executed by the device, the steps of performing image synthesis between the foreground image separated from the first image and the target background image to obtain the target image include:
展示目标背景图像,接收到用户在目标背景图像上的位置指定操作,得到用户在目标背景图像上指定位置的位置信息;Display the target background image, receive the user's position designation operation on the target background image, and obtain the position information of the user's designated position on the target background image;
确定位置信息对应的第一距离估计值;determining the first distance estimation value corresponding to the location information;
根据第一距离估计值对前景图像进行缩放,得到目标前景图像;Scaling the foreground image according to the first distance estimation value to obtain the target foreground image;
将目标前景图像合成至目标背景图像中位置信息指示的位置,得到目标图像。The target foreground image is synthesized to the position indicated by the position information in the target background image to obtain the target image.
在一种可能的实现方式中,当指令被设备执行时,使得将目标前景图像合成至目标背景图像上位置信息指示的位置的步骤之前,还包括:In a possible implementation manner, when the instruction is executed by the device, before the step of synthesizing the target foreground image to the position indicated by the position information on the target background image, the method further includes:
对目标前景图像和/或目标背景图像的颜色参数进行调整。Adjust the color parameters of the target foreground image and/or the target background image.
第三方面,本申请实施例提供一种计算机可读存储介质,计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行第一方面任一项的方法。In a third aspect, embodiments of the present application provide a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program runs on a computer, causes the computer to execute the method of any one of the first aspect.
第四方面,本申请提供一种计算机程序,当计算机程序被计算机执行时,用于执行第一方面的方法。In a fourth aspect, the present application provides a computer program for performing the method of the first aspect when the computer program is executed by a computer.
在一种可能的设计中,第四方面中的程序可以全部或者部分存储在与处理器封装在一起的存储介质上,也可以部分或者全部存储在不与处理器封装在一起的存储器上。In a possible design, the program in the fourth aspect may be stored in whole or in part on a storage medium packaged with the processor, or may be stored in part or in part in a memory not packaged with the processor.
附图说明Description of drawings
为了更清楚地说明本发明实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得 其它的附图。In order to illustrate the technical solutions of the embodiments of the present invention more clearly, the following briefly introduces the accompanying drawings used in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained from these drawings without any creative effort.
图1为本申请电子设备的结构示意图;1 is a schematic structural diagram of an electronic device of the application;
图2为本申请电子设备的软件结构示意图;2 is a schematic diagram of the software structure of the electronic device of the application;
图3为本申请图像合成方法GUI示意图;3 is a GUI schematic diagram of the image synthesis method of the application;
图4为本申请图像合成方法一个实施例的流程图;4 is a flowchart of an embodiment of an image synthesis method of the present application;
图5为本申请手机坐标系和第一坐标系建立方法示意图;5 is a schematic diagram of a method for establishing a mobile phone coordinate system and a first coordinate system of the present application;
图6A为本申请图像合成方法部分步骤的示意框图;6A is a schematic block diagram of some steps of the image synthesis method of the present application;
图6B为本申请图像合成方法部分步骤的示意框图;6B is a schematic block diagram of some steps of the image synthesis method of the present application;
图7为本申请图像合成方法另一个实施例的流程图;FIG. 7 is a flowchart of another embodiment of the image synthesis method of the present application;
图8为本申请图像合成装置一个实施例的结构图。FIG. 8 is a structural diagram of an embodiment of an image synthesizing apparatus of the present application.
具体实施方式detailed description
本申请的实施方式部分使用的术语仅用于对本申请的具体实施例进行解释,而非旨在限定本申请。The terms used in the embodiments of the present application are only used to explain specific embodiments of the present application, and are not intended to limit the present application.
现有技术中,在将人物图像从第一图像中分离出来后,一般由用户对人物图像自主缩放至合适大小,然后直接合成至第二图像中,得到目标图像。在图像合成时,上述人物图像也可以称为前景图像,第二图像也可以称为背景图像。In the prior art, after the person image is separated from the first image, the user generally automatically scales the person image to an appropriate size, and then directly combines it into the second image to obtain the target image. During image synthesis, the above-mentioned person image may also be referred to as a foreground image, and the second image may also be referred to as a background image.
从技术层面来说,第一图像和第二图像的光线不匹配、拍摄视角不匹配等因素会造成合成得到的目标图像的视角协调差、视觉上失真严重的问题,影响用户体验。From a technical point of view, factors such as the mismatch of light between the first image and the second image, and the mismatch of the shooting angle of view will cause poor coordination of the angle of view and serious visual distortion of the synthesized target image, which will affect the user experience.
从用户层面来说,随着用户对抠图换背景这一功能使用时间的增加,用户对这一功能趣味性上的热度会逐渐减退,与之相对应的,对抠图换背景得到的目标图像的视觉合理性和协调性的要求会逐渐提高。From the user level, as the user's usage time for the function of cutting out the background and changing the background increases, the user's interest in the interest of this function will gradually decrease. The requirements for visual rationality and coordination of images will gradually increase.
为此,本申请提出一种图像合成方法和电子设备,能够改善前景图像(例如上述的人物图像)和背景图像合成后得到的目标图像视觉上失真严重的问题,提高图像合成得到的目标图像的视觉合理性和协调性,提升用户体验。To this end, the present application proposes an image synthesis method and electronic device, which can improve the problem of serious visual distortion of a target image obtained by synthesizing a foreground image (such as the above-mentioned person image) and a background image, and improve the quality of the target image obtained by image synthesis. Visual rationality and coordination to enhance user experience.
本申请的图像合成方法可以适用于电子设备,例如移动终端(手机)、平板电脑(PAD)、个人电脑(PC)、智慧屏、车载设备等设备。The image synthesis method of the present application can be applied to electronic devices, such as mobile terminals (mobile phones), tablet computers (PADs), personal computers (PCs), smart screens, in-vehicle devices and other devices.
图1示出了电子设备100的结构示意图。电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。FIG. 1 shows a schematic structural diagram of an electronic device 100 . The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (subscriber identification module, SIM) card interface 195 and so on. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and ambient light. Sensor 180L, bone conduction sensor 180M, etc.
可以理解的是,本发明实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软 件或软件和硬件的组合实现。It can be understood that, the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100 . In other embodiments of the present application, the electronic device 100 may include more or less components than shown, or combine some components, or separate some components, or arrange different components. The illustrated components may be implemented in hardware, software or a combination of software and hardware.
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 110 may include one or more processing units, for example, 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), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (neural-network processing unit, NPU), etc. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。The controller can generate an operation control signal according to the instruction operation code and timing signal, and complete the control of fetching and executing instructions.
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in processor 110 is cache memory. This memory may hold instructions or data that have just been used or recycled by the processor 110 . If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby increasing the efficiency of the system.
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。In some embodiments, the processor 110 may include one or more interfaces. The interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transceiver (universal asynchronous transmitter) receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / or universal serial bus (universal serial bus, USB) interface, etc.
I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器110可以包含多组I2C总线。处理器110可以通过不同的I2C总线接口分别耦合触摸传感器180K,充电器,闪光灯,摄像头193等。例如:处理器110可以通过I2C接口耦合触摸传感器180K,使处理器110与触摸传感器180K通过I2C总线接口通信,实现电子设备100的触摸功能。The I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may contain multiple sets of I2C buses. The processor 110 can be respectively coupled to the touch sensor 180K, the charger, the flash, the camera 193 and the like through different I2C bus interfaces. For example, the processor 110 may couple the touch sensor 180K through the I2C interface, so that the processor 110 and the touch sensor 180K communicate with each other through the I2C bus interface, so as to realize the touch function of the electronic device 100 .
I2S接口可以用于音频通信。在一些实施例中,处理器110可以包含多组I2S总线。处理器110可以通过I2S总线与音频模块170耦合,实现处理器110与音频模块170之间的通信。在一些实施例中,音频模块170可以通过I2S接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。The I2S interface can be used for audio communication. In some embodiments, the processor 110 may contain multiple sets of I2S buses. The processor 110 may be coupled with the audio module 170 through an I2S bus to implement communication between the processor 110 and the audio module 170 . In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 through the I2S interface, so as to realize the function of answering calls through a Bluetooth headset.
PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。在一些实施例中,音频模块170与无线通信模块160可以通过PCM总线接口耦合。在一些实施例中,音频模块170也可以通过PCM接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。所述I2S接口和所述PCM接口都可以用于音频通信。The PCM interface can also be used for audio communications, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 may be coupled through a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 through the PCM interface, so as to realize the function of answering calls through the Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
UART接口是一种通用串行数据总线,用于异步通信。该总线可以为双向通信总线。它将要传输的数据在串行通信与并行通信之间转换。在一些实施例中,UART接口通常被用于连接处理器110与无线通信模块160。例如:处理器110通过UART接口与无线通信模块160中的蓝牙模块通信,实现蓝牙功能。在一些实施例中,音频模块170可以通过UART接口向无线通信模块160传递音频信号,实现通过蓝牙耳机播放音乐的功能。The UART interface is a universal serial data bus used for asynchronous communication. The bus may be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, a UART interface is typically used to connect the processor 110 with the wireless communication module 160 . For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 through the UART interface, so as to realize the function of playing music through the Bluetooth headset.
MIPI接口可以被用于连接处理器110与显示屏194,摄像头193等外围器件。 MIPI接口包括摄像头串行接口(camera serial interface,CSI),显示屏串行接口(display serial interface,DSI)等。在一些实施例中,处理器110和摄像头193通过CSI接口通信,实现电子设备100的拍摄功能。处理器110和显示屏194通过DSI接口通信,实现电子设备100的显示功能。The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193 . MIPI interfaces include camera serial interface (CSI), display serial interface (DSI), etc. In some embodiments, the processor 110 communicates with the camera 193 through a CSI interface, so as to realize the photographing function of the electronic device 100 . The processor 110 communicates with the display screen 194 through the DSI interface to implement the display function of the electronic device 100 .
GPIO接口可以通过软件配置。GPIO接口可以被配置为控制信号,也可被配置为数据信号。在一些实施例中,GPIO接口可以用于连接处理器110与摄像头193,显示屏194,无线通信模块160,音频模块170,传感器模块180等。GPIO接口还可以被配置为I2C接口,I2S接口,UART接口,MIPI接口等。The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface may be used to connect the processor 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, and the like. The GPIO interface can also be configured as I2C interface, I2S interface, UART interface, MIPI interface, etc.
USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为电子设备100充电,也可以用于电子设备100与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。The USB interface 130 is an interface that conforms to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, and the like. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices.
可以理解的是,本发明实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It can be understood that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration, and does not constitute a structural limitation of the electronic device 100 . In other embodiments of the present application, the electronic device 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接口130接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块140可以通过电子设备100的无线充电线圈接收无线充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。The charging management module 140 is used to receive charging input from the charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from the wired charger through the USB interface 130 . In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100 . While the charging management module 140 charges the battery 142 , it can also supply power to the electronic device through the power management module 141 .
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,显示屏194,摄像头193,和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。在其他一些实施例中,电源管理模块141也可以设置于处理器110中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。The power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 110 . The power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, battery health status (leakage, impedance). In some other embodiments, the power management module 141 may also be provided in the processor 110 . In other embodiments, the power management module 141 and the charging management module 140 may also be provided in the same device.
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。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, the modulation and demodulation processor, the baseband processor, and the like.
天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, the antenna 1 can be multiplexed as a diversity antenna of the wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。The mobile communication module 150 may provide wireless communication solutions including 2G/3G/4G/5G etc. applied on the electronic device 100 . The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA) and the like. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and then turn it into an electromagnetic wave for radiation through the antenna 1 . In some embodiments, at least part of the functional modules of the mobile communication module 150 may be provided in the processor 110 . In some embodiments, at least part of the functional modules of the mobile communication module 150 may be provided in the same device as at least part of the modules of the processor 110 .
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基 带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high-frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low frequency baseband signal. Then the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. The low frequency baseband signal is processed by the baseband processor and passed to the application processor. The application processor outputs sound signals through audio devices (not limited to the speaker 170A, the receiver 170B, etc.), or displays images or videos through the display screen 194 . In some embodiments, the modem processor may be a stand-alone device. In other embodiments, the modem processor may be independent of the processor 110, and may be provided in the same device as the mobile communication module 150 or other functional modules.
无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellites Wireless communication solutions such as global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared technology (IR). The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 . The wireless communication module 160 can also receive the signal to be sent from the processor 110 , perform frequency modulation on it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2 .
在一些实施例中,电子设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code division multiple access,CDMA),宽带码分多址(wideband code division multiple access,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidou navigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。In some embodiments, the antenna 1 of the electronic device 100 is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc. The GNSS may include a global positioning system (global positioning system, GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (quasi -zenith satellite system, QZSS) and/or satellite based augmentation systems (SBAS).
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device 100 implements a display function through a GPU, a display screen 194, an application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the display screen 194 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 alter display information.
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。Display screen 194 is used to display images, videos, and the like. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (active-matrix organic light). emitting diode, AMOLED), flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (quantum dot light emitting diodes, QLED) and so on. In some embodiments, the electronic device 100 may include one or N display screens 194 , where N is a positive integer greater than one.
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。The electronic device 100 may implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传 递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。The ISP is used to process the data fed back by the camera 193 . For example, when taking a photo, the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on image noise, brightness, and skin tone. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP may be provided in the camera 193 .
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或N个摄像头193,N为大于1的正整数。Camera 193 is used to capture still images or video. The object is projected through the lens to generate an optical image onto the photosensitive element. The photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. DSP converts digital image signals into standard RGB, YUV and other formats of image signals. In some embodiments, the electronic device 100 may include 1 or N cameras 193 , where N is a positive integer greater than 1.
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。A digital signal processor is used to process digital signals, in addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy and so on.
视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。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 can play or record videos of various encoding formats, such as: Moving Picture Experts Group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4 and so on.
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。The NPU is a neural-network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transfer mode between neurons in the human brain, it can quickly process the input information, and can continuously learn by itself. Applications such as intelligent cognition of the electronic device 100 can be implemented through the NPU, such as image recognition, face recognition, speech recognition, text understanding, and the like.
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100 . The external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example to save files like music, video etc in external memory card.
内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。处理器110通过运行存储在内部存储器121的指令,和/或存储在设置于处理器中的存储器的指令,执行电子设备100的各种功能应用以及数据处理。Internal memory 121 may be used to store computer executable program code, which includes instructions. The internal memory 121 may include a storage program area and a storage data area. The storage program area can store an operating system, an application program required for at least one function (such as a sound playback function, an image playback function, etc.), and the like. The storage data area may store data (such as audio data, phone book, etc.) created during the use of the electronic device 100 and the like. In addition, the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, universal flash storage (UFS), and the like. The processor 110 executes various functional applications and data processing of the electronic device 100 by executing instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。The electronic device 100 may implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, an application processor, and the like. Such as music playback, recording, etc.
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于处理器110中,或将音频模块170的部分功能模块设置于处理器110中。The audio module 170 is used for converting digital audio information into analog audio signal output, and also for converting analog audio input into digital audio signal. Audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be provided in the processor 110 , or some functional modules of the audio module 170 may be provided in the processor 110 .
扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备100可以通过扬声器170A收听音乐,或收听免提通话。Speaker 170A, also referred to as a "speaker", is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music through the speaker 170A, or listen to a hands-free call.
受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。当电子设备100接听电话或语音信息时,可以通过将受话器170B靠近人耳接听语音。The receiver 170B, also referred to as "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a call or a voice message, the voice can be answered by placing the receiver 170B close to the human ear.
麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。当拨打电话或发送语音信息时,用户可以通过人嘴靠近麦克风170C发声,将声音信号输入到麦克风170C。电子设备100可以设置至少一个麦克风170C。在另一些实施例中,电子设备100可以设置两个麦克风170C,除了采集声音信号,还可以实现降噪功能。在另一些实施例中,电子设备100还可以设置三个,四个或更多麦克风170C,实现采集声音信号,降噪,还可以识别声音来源,实现定向录音功能等。The microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can make a sound by approaching the microphone 170C through a human mouth, and input the sound signal into the microphone 170C. The electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, which can implement a noise reduction function in addition to collecting sound signals. In other embodiments, the electronic device 100 may further be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and implement directional recording functions.
耳机接口170D用于连接有线耳机。耳机接口170D可以是USB接口130,也可以是3.5mm的开放移动电子设备平台(open mobile terminal platform,OMTP)标准接口,美国蜂窝电信工业协会(cellular telecommunications industry association of the USA,CTIA)标准接口。The earphone jack 170D is used to connect wired earphones. The earphone interface 170D can be the USB interface 130, or can be a 3.5mm open mobile terminal platform (OMTP) standard interface, a cellular telecommunications industry association of the USA (CTIA) standard interface.
压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。在一些实施例中,压力传感器180A可以设置于显示屏194。压力传感器180AThe pressure sensor 180A is used to sense pressure signals, and can convert the pressure signals into electrical signals. In some embodiments, the pressure sensor 180A may be provided on the display screen 194 . Pressure sensor 180A
的种类很多,如电阻式压力传感器,电感式压力传感器,电容式压力传感器等。电容式压力传感器可以是包括至少两个具有导电材料的平行板。当有力作用于压力传感器180A,电极之间的电容改变。电子设备100根据电容的变化确定压力的强度。当有触摸操作作用于显示屏194,电子设备100根据压力传感器180A检测所述触摸操作强度。电子设备100也可以根据压力传感器180A的检测信号计算触摸的位置。在一些实施例中,作用于相同触摸位置,但不同触摸操作强度的触摸操作,可以对应不同的操作指令。例如:当有触摸操作强度小于第一压力阈值的触摸操作作用于短消息应用图标时,执行查看短消息的指令。当有触摸操作强度大于或等于第一压力阈值的触摸操作作用于短消息应用图标时,执行新建短消息的指令。There are many types, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor may be comprised of at least two parallel plates of conductive material. When a force is applied to the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the intensity of the touch operation according to the pressure sensor 180A. The electronic device 100 may also calculate the touched position according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities may correspond to different operation instructions. For example, when a touch operation whose intensity is less than the first pressure threshold acts on the short message application icon, the instruction for viewing the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, the instruction to create a new short message is executed.
陀螺仪传感器180B可以用于确定电子设备100的运动姿态。在一些实施例中,可以通过陀螺仪传感器180B确定电子设备100围绕三个轴(即,x,y和z轴)的角速度。陀螺仪传感器180B可以用于拍摄防抖。示例性的,当按下快门,陀螺仪传感器180B检测电子设备100抖动的角度,根据角度计算出镜头模组需要补偿的距离,让镜头通过反向运动抵消电子设备100的抖动,实现防抖。陀螺仪传感器180B还可以用于导航,体感游戏场景。The gyro sensor 180B may be used to determine the motion attitude of the electronic device 100 . In some embodiments, the angular velocity of electronic device 100 about three axes (ie, x, y, and z axes) may be determined by gyro sensor 180B. The gyro sensor 180B can be used for image stabilization. Exemplarily, when the shutter is pressed, the gyro sensor 180B detects the shaking angle of the electronic device 100, calculates the distance that the lens module needs to compensate according to the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse motion to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenarios.
气压传感器180C用于测量气压。在一些实施例中,电子设备100通过气压传感器180C测得的气压值计算海拔高度,辅助定位和导航。The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist in positioning and navigation.
磁传感器180D包括霍尔传感器。电子设备100可以利用磁传感器180D检测翻盖皮套的开合。在一些实施例中,当电子设备100是翻盖机时,电子设备100可以根据磁传感器180D检测翻盖的开合。进而根据检测到的皮套的开合状态或翻盖的开合状态,设置翻盖自动解锁等特性。The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can detect the opening and closing of the flip holster using the magnetic sensor 180D. In some embodiments, when the electronic device 100 is a flip machine, the electronic device 100 can detect the opening and closing of the flip according to the magnetic sensor 180D. Further, according to the detected opening and closing state of the leather case or the opening and closing state of the flip cover, characteristics such as automatic unlocking of the flip cover are set.
加速度传感器180E可检测电子设备100在各个方向上(一般为三轴)加速度的大小。当电子设备100静止时可检测出重力的大小及方向。还可以用于识别电子设备姿态,应用于横竖屏切换,计步器等应用。The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). The magnitude and direction of gravity can be detected when the electronic device 100 is stationary. It can also be used to identify the posture of electronic devices, and can be used in applications such as horizontal and vertical screen switching, pedometers, etc.
距离传感器180F,用于测量距离。电子设备100可以通过红外或激光测量距离。在一些实施例中,拍摄场景,电子设备100可以利用距离传感器180F测距以实现快速对焦。Distance sensor 180F for measuring distance. The electronic device 100 can measure the distance through infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.
接近光传感器180G可以包括例如发光二极管(LED)和光检测器,例如光电二极管。发光二极管可以是红外发光二极管。电子设备100通过发光二极管向外发射红外 光。电子设备100使用光电二极管检测来自附近物体的红外反射光。当检测到充分的反射光时,可以确定电子设备100附近有物体。当检测到不充分的反射光时,电子设备100可以确定电子设备100附近没有物体。电子设备100可以利用接近光传感器180G检测用户手持电子设备100贴近耳朵通话,以便自动熄灭屏幕达到省电的目的。接近光传感器180G也可用于皮套模式,口袋模式自动解锁与锁屏。Proximity light sensor 180G may include, for example, light emitting diodes (LEDs) and light detectors, such as photodiodes. The light emitting diodes may be infrared light emitting diodes. The electronic device 100 emits infrared light to the outside through light emitting diodes. Electronic device 100 uses photodiodes to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100 . When insufficient reflected light is detected, the electronic device 100 may determine that there is no object near the electronic device 100 . The electronic device 100 can use the proximity light sensor 180G to detect that the user holds the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power. Proximity light sensor 180G can also be used in holster mode, pocket mode automatically unlocks and locks the screen.
环境光传感器180L用于感知环境光亮度。电子设备100可以根据感知的环境光亮度自适应调节显示屏194亮度。环境光传感器180L也可用于拍照时自动调节白平衡。环境光传感器180L还可以与接近光传感器180G配合,检测电子设备100是否在口袋里,以防误触。The ambient light sensor 180L is used to sense ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket, so as to prevent accidental touch.
指纹传感器180H用于采集指纹。电子设备100可以利用采集的指纹特性实现指纹解锁,访问应用锁,指纹拍照,指纹接听来电等。The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to realize fingerprint unlocking, accessing application locks, taking pictures with fingerprints, answering incoming calls with fingerprints, and the like.
温度传感器180J用于检测温度。在一些实施例中,电子设备100利用温度传感器180J检测的温度,执行温度处理策略。例如,当温度传感器180J上报的温度超过阈值,电子设备100执行降低位于温度传感器180J附近的处理器的性能,以便降低功耗实施热保护。在另一些实施例中,当温度低于另一阈值时,电子设备100对电池142加热,以避免低温导致电子设备100异常关机。在其他一些实施例中,当温度低于又一阈值时,电子设备100对电池142的输出电压执行升压,以避免低温导致的异常关机。The temperature sensor 180J is used to detect the temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold value, the electronic device 100 reduces the performance of the processor located near the temperature sensor 180J in order to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 caused by the low temperature. In some other embodiments, when the temperature is lower than another threshold, the electronic device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.
触摸传感器180K,也称“触控器件”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器180K也可以设置于电子设备100的表面,与显示屏194所处的位置不同。Touch sensor 180K, also called "touch device". The touch sensor 180K may be disposed on the display screen 194 , and the touch sensor 180K and the display screen 194 form a touch screen, also called a “touch screen”. The touch sensor 180K is used to detect a touch operation on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to touch operations may be provided through display screen 194 . In other embodiments, the touch sensor 180K may also be disposed on the surface of the electronic device 100 , which is different from the location where the display screen 194 is located.
骨传导传感器180M可以获取振动信号。在一些实施例中,骨传导传感器180M可以获取人体声部振动骨块的振动信号。骨传导传感器180M也可以接触人体脉搏,接收血压跳动信号。在一些实施例中,骨传导传感器180M也可以设置于耳机中,结合成骨传导耳机。音频模块170可以基于所述骨传导传感器180M获取的声部振动骨块的振动信号,解析出语音信号,实现语音功能。应用处理器可以基于所述骨传导传感器180M获取的血压跳动信号解析心率信息,实现心率检测功能。The bone conduction sensor 180M can acquire vibration signals. In some embodiments, the bone conduction sensor 180M can acquire the vibration signal of the vibrating bone mass of the human voice. The bone conduction sensor 180M can also contact the pulse of the human body and receive the blood pressure beating signal. In some embodiments, the bone conduction sensor 180M can also be disposed in the earphone, combined with the bone conduction earphone. The audio module 170 can analyze the voice signal based on the vibration signal of the vocal vibration bone block obtained by the bone conduction sensor 180M, so as to realize the voice function. The application processor can analyze the heart rate information based on the blood pressure beat signal obtained by the bone conduction sensor 180M, and realize the function of heart rate detection.
按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。The keys 190 include a power-on key, a volume key, and the like. Keys 190 may be mechanical keys. It can also be a touch key. The electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100 .
马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用(例如拍照,音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于显示屏194不同区域的触摸操作,马达191也可对应不同的振动反馈效果。不同的应用场景(例如:时间提醒,接收信息,闹钟,游戏等)也可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。Motor 191 can generate vibrating cues. The motor 191 can be used for vibrating alerts for incoming calls, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, playing audio, etc.) can correspond to different vibration feedback effects. The motor 191 can also correspond to different vibration feedback effects for touch operations on different areas of the display screen 194 . Different application scenarios (for example: time reminder, receiving information, alarm clock, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。The indicator 192 can be an indicator light, which can be used to indicate the charging state, the change of the power, and can also be used to indicate a message, a missed call, a notification, and the like.
SIM卡接口195用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从 SIM卡接口195拔出,实现和电子设备100的接触和分离。电子设备100可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口195可以支持Nano SIM卡,Micro SIM卡,SIM卡等。同一个SIM卡接口195可以同时插入多张卡。所述多张卡的类型可以相同,也可以不同。SIM卡接口195也可以兼容不同类型的SIM卡。SIM卡接口195也可以兼容外部存储卡。电子设备100通过SIM卡和网络交互,实现通话以及数据通信等功能。在一些实施例中,电子设备100采用eSIM,即:嵌入式SIM卡。eSIM卡可以嵌在电子设备100中,不能和电子设备100分离。The SIM card interface 195 is used to connect a SIM card. The SIM card can be contacted and separated from the electronic device 100 by inserting into the SIM card interface 195 or pulling out from the SIM card interface 195 . The electronic device 100 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card and so on. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the plurality of cards may be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 is also compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as call and data communication. In some embodiments, the electronic device 100 employs an eSIM, ie: an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100 .
电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本发明实施例以分层架构的Android系统为例,示例性说明电子设备100的软件结构。The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. The embodiment of the present invention takes an Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100 as an example.
图2是本发明实施例的电子设备100的软件结构框图。FIG. 2 is a block diagram of a software structure of an electronic device 100 according to an embodiment of the present invention.
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为四层,从上至下分别为应用程序层,应用程序框架层,安卓运行时(Android runtime)和系统库,以及内核层。The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, which are, from top to bottom, an application layer, an application framework layer, an Android runtime (Android runtime) and a system library, and a kernel layer.
应用程序层可以包括一系列应用程序包。The application layer can include a series of application packages.
如图2所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息等应用程序。As shown in Figure 2, the application package can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and so on.
应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。The application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
如图2所示,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,电话管理器,资源管理器,通知管理器等。As shown in Figure 2, the application framework layer may include window managers, content providers, view systems, telephony managers, resource managers, notification managers, and the like.
窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。A window manager is used to manage window programs. The window manager can get the size of the display screen, determine whether there is a status bar, lock the screen, take screenshots, etc.
内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。Content providers are used to store and retrieve data and make these data accessible to applications. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phone book, etc.
视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and so on. View systems can be used to build applications. A display interface can consist of one or more views. For example, the display interface including the short message notification icon may include a view for displaying text and a view for displaying pictures.
电话管理器用于提供电子设备100的通信功能。例如通话状态的管理(包括接通,挂断等)。The phone manager is used to provide the communication function of the electronic device 100 . For example, the management of call status (including connecting, hanging up, etc.).
资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。The resource manager provides various resources for the application, such as localization strings, icons, pictures, layout files, video files and so on.
通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。The notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages, and can disappear automatically after a brief pause without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also display notifications in the status bar at the top of the system in the form of graphs or scroll bar text, such as notifications of applications running in the background, and notifications on the screen in the form of dialog windows. For example, text information is prompted in the status bar, a prompt sound is issued, the electronic device vibrates, and the indicator light flashes.
Android Runtime包括核心库和虚拟机。Android runtime负责安卓系统的调度和管理。Android Runtime includes core libraries and a virtual machine. Android runtime is responsible for scheduling and management of the Android system.
核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。The core library consists of two parts: one is the function functions that the java language needs to call, and the other is the core library of Android.
应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。The application layer and the application framework layer run in virtual machines. The virtual machine executes the java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, safety and exception management, and garbage collection.
系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。A system library can include multiple functional modules. For example: surface manager (surface manager), media library (Media Libraries), 3D graphics processing library (eg: OpenGL ES), 2D graphics engine (eg: SGL), etc.
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。The Surface Manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications.
媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。The media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
2D图形引擎是2D绘图的绘图引擎。2D graphics engine is a drawing engine for 2D drawing.
内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动。The kernel layer is the layer between hardware and software. The kernel layer contains at least display drivers, camera drivers, audio drivers, and sensor drivers.
为了便于理解,本申请以下实施例将以具有图1和图2所示结构的电子设备为例,结合附图和应用场景,对本申请实施例提供的方法进行具体说明。For ease of understanding, the following embodiments of the present application will take the electronic device having the structure shown in FIG. 1 and FIG. 2 as an example, and combine the drawings and application scenarios to specifically describe the methods provided by the embodiments of the present application.
图3是本申请实施例图像合成方法的图形用户界面(graphical user interface,GUI)示例图,在图3中电子设备是手机为例,示例性说明本申请实施例提供的图像合成方法。3 is an example diagram of a graphical user interface (graphical user interface, GUI) of the image synthesis method according to the embodiment of the present application. In FIG. 3 , the electronic device is a mobile phone as an example to illustrate the image synthesis method provided by the embodiment of the present application.
图3的31部分,用户选择一幅图像作为需要更换背景的第一图像,例如31部分的图像310所示,用户点击换背景控件,相应的,手机检测到用户的操作,展示向用户推荐的背景图像,展示的方式不限制,例如在图3的32部分中,通过分页的方式向用户展示背景图像,在图3的32部分中示出了展示的第1页的背景图像,第1页中共展示9个背景图像;这里展示的背景图像是基于第一图像获取到的背景图像,并且按照背景图像与第一图像之间的拍摄角度差异从小到大进行了排序。用户从展示的背景图像中选择一个背景图像(图3中以用户通过点击的方式选择背景图像1作为示例)作为第二图像;相应的,手机检测到用户的选择操作,向用户展示用户选择的背景图像,如图3中33部分所示,将第二图像320展示给用户。In part 31 of FIG. 3, the user selects an image as the first image whose background needs to be changed. For example, as shown in image 310 in part 31, the user clicks on the background change control. Correspondingly, the mobile phone detects the user's operation and displays the recommended image to the user. The way of displaying the background image is not limited. For example, in part 32 of FIG. 3, the background image is displayed to the user through paging. In part 32 of FIG. 3, the background image of the displayed first page is shown, the first page A total of 9 background images are displayed; the background images shown here are obtained based on the first image, and are sorted from small to large according to the difference in shooting angle between the background image and the first image. The user selects a background image from the displayed background images (in FIG. 3, the user selects the background image 1 by clicking as an example) as the second image; correspondingly, the mobile phone detects the user's selection operation and displays the user's selection to the user. The background image, as shown in part 33 in FIG. 3, presents the second image 320 to the user.
用户在展示的第二图像320中指定一个位置作为从第一图像中分离出来的人物图像合成至第二图像的位置,点击确定控件,相应的,手机接收到用户的位置指定操作,将第一图像310中分离出的人物图像合成至第二图像320中用户指定的位置,得到目标图像。使用本申请图像合成方法得到的目标图像的合理性和融合性相对更高。The user designates a position in the displayed second image 320 as the position where the character image separated from the first image is synthesized into the second image, and clicks the OK control. Correspondingly, the mobile phone receives the user's position designation operation, and the first image is combined. The person images separated in the image 310 are synthesized to the position designated by the user in the second image 320 to obtain the target image. The rationality and fusion of the target image obtained by using the image synthesis method of the present application are relatively higher.
以下,举实例对本申请图像合成方法的实现进行更为详细的说明。Hereinafter, the implementation of the image synthesis method of the present application will be described in more detail by taking an example.
图4为本申请图像合成方法的一个实施例流程图,如图4所示,该方法可以包括:FIG. 4 is a flowchart of an embodiment of an image synthesis method of the present application. As shown in FIG. 4 , the method may include:
步骤401:在服务器侧预设背景图像的素材库。Step 401: Preset a material library of background images on the server side.
素材库中的图像可以是电子设备例如手机拍摄的图像,由电子设备所属用户授权并上传至服务器,也可以是素材库提供者拍摄或采集的图像等。素材库中图像的来源本申请实施例不作限定。The images in the material library may be images captured by an electronic device such as a mobile phone, which are authorized by the user to which the electronic device belongs and uploaded to the server, or may be images shot or collected by the material library provider. The source of the image in the material library is not limited in this embodiment of the present application.
素材库中的每一张图像可以设置有:角度标签和分类标签。Each image in the material library can be set with: angle label and category label.
角度标签用于记录图像的拍摄角度信息例如拍摄姿态角;分类标签用于记录图像的分类信息。素材库可以根据图像的分类标签对素材库中的图像进行分类存储。The angle tag is used to record the shooting angle information of the image, such as the shooting attitude angle; the classification tag is used to record the classification information of the image. The material library can classify and store the images in the material library according to the classification tags of the images.
拍摄姿态角用于描述电子设备分别绕第一坐标系的xyz轴旋转的角度,第一坐标系的建立方法为:以手机坐标系的原点作为第一坐标系的原点,第一坐标系的x轴正方向为地理的正西方向,y轴正方向为垂直地面向上的方向,z轴正方向为地理的正北方向。The shooting attitude angle is used to describe the angle at which the electronic device rotates around the xyz axis of the first coordinate system. The method for establishing the first coordinate system is: take the origin of the mobile phone coordinate system as the origin of the first coordinate The positive direction of the axis is the due west direction of the geography, the positive direction of the y-axis is the vertical upward direction, and the positive direction of the z-axis is the due north direction of the geography.
拍摄姿态角可以包括3种角度参数,分别是:俯仰角α、方位角β以及横滚角γ。以下,分别对3种角度参数进行说明。The shooting attitude angle may include three angle parameters, namely: pitch angle α, azimuth angle β and roll angle γ. Hereinafter, three types of angle parameters will be described respectively.
参见图5,示出了竖屏手机坐标系的一种建立方法,其中,以手机的物理中心为原点,手机的右、上、前三个方向分别为x、y、z轴正方向,此时,当手机竖直放置、且手机的正面(一般为设置有显示屏的一面)面向地理的正北方向时,手机坐标系与第一坐标系重合。其中,Referring to FIG. 5, a method for establishing the coordinate system of a vertical screen mobile phone is shown, wherein, taking the physical center of the mobile phone as the origin, the right, top, and front three directions of the mobile phone are the positive directions of the x, y, and z axes, respectively. When the mobile phone is placed vertically and the front of the mobile phone (generally the side with the display screen) faces the geographic north direction, the mobile phone coordinate system coincides with the first coordinate system. in,
俯仰角α:当手机坐标系的xz轴所在的平面与第一坐标系的xz轴所在平面(也即地面或者水平面)平行时,俯仰角是0度,当手机围绕第一坐标系的x轴旋转,且顶部离用户(假设用户位于手机前方)越来越远,底部离过户越来越近时(此时可以理解成,手机的后置摄像头逐渐朝着地面拍摄),俯仰角从0到-90度变化;如果顶部离用户越来越近,底部离用户越来越远时(此时可以理解成,手机的后置摄像头逐渐朝着天空拍摄),俯仰角从0到90度变化。Pitch angle α: When the plane where the xz axis of the mobile phone coordinate system is located is parallel to the plane where the xz axis of the first coordinate system is located (that is, the ground or the horizontal plane), the elevation angle is 0 degrees. When the mobile phone is around the x axis of the first coordinate system Rotate, and when the top is farther and farther away from the user (assuming the user is in front of the phone), and the bottom is getting closer and closer to the transfer (at this time, it can be understood that the rear camera of the mobile phone is gradually shooting towards the ground), the pitch angle is from 0 to -90 degrees change; if the top is getting closer and closer to the user and the bottom is getting farther and farther away from the user (at this time, it can be understood that the rear camera of the mobile phone is gradually shooting towards the sky), the pitch angle changes from 0 to 90 degrees.
方位角β:手机围绕第一坐标系的y轴旋转,手机的正面朝向正北方向为0度,顺时针旋转,方位角从0到360度变化,正北0度、正东90度,正南180度,正西270度。Azimuth β: The mobile phone rotates around the y-axis of the first coordinate system, the front of the mobile phone is 0 degrees to the true north, rotate clockwise, the azimuth changes from 0 to 360 degrees, 0 degrees true north, 90 degrees east, positive 180 degrees south, 270 degrees west.
横滚角γ:当手机坐标系的yz轴所在的平面与第一坐标系的yz轴所在平面重合(也即与水平面垂直)时,手机的横滚角是0度,手机围绕第一坐标系的z轴旋转,若顺时针旋转,横滚角从0到90度变化;如果逆时针旋转,横滚角从0到-90度变化。Roll angle γ: When the plane where the yz axis of the mobile phone coordinate system is located coincides with the plane where the yz axis of the first coordinate system is located (that is, it is perpendicular to the horizontal plane), the roll angle of the mobile phone is 0 degrees, and the mobile phone surrounds the first coordinate system. If the z-axis is rotated, the roll angle changes from 0 to 90 degrees if it is rotated clockwise; if it is rotated counterclockwise, the roll angle changes from 0 to -90 degrees.
需要说明的是,图5中以竖屏手机为例,也可以将其扩展至任一电子设备,例如横屏手机等,对于横屏手机来说,只是将图中的竖屏手机更改为横屏手机,拍摄姿态角的定义依然不变。It should be noted that the vertical screen mobile phone is used as an example in Fig. 5, and it can also be extended to any electronic device, such as a horizontal screen mobile phone, etc. For a horizontal screen mobile phone, it is only necessary to change the vertical screen mobile phone in the figure to a horizontal screen. For screen phones, the definition of shooting attitude angle remains unchanged.
图像的分类标签可以包括但不限于以下种类的标签:场景信息、和/或光线信息、和/或季节信息、和/或天气信息等。Classification tags of images may include, but are not limited to, tags of the following categories: scene information, and/or light information, and/or season information, and/or weather information, and the like.
其中,场景信息用于记录图像的拍摄场景,参数值可以包括:室内、室外;光线信息用于记录图像的明暗程度,参数值可以包括:明、暗;季节信息用于记录图像的拍摄季节,参数值可以包括:春天、夏天、秋天、冬天;天气信息用于记录图像拍摄时的天气情况,参数值可以包括:晴、雨、雪等。The scene information is used to record the shooting scene of the image, and the parameter values may include: indoor and outdoor; the light information is used to record the brightness and darkness of the image, and the parameter values may include: bright and dark; the season information is used to record the shooting season of the image, The parameter values may include: spring, summer, autumn, and winter; the weather information is used to record the weather conditions when the image is taken, and the parameter values may include: sunny, rainy, snowy, and the like.
在素材库中,可以依据图像的上述分类标签对图像分类存储,使得素材库中的图像存储更为有序。In the material library, images can be classified and stored according to the above-mentioned classification tags of the images, so that the images in the material library are stored in a more orderly manner.
参见图6A所示,为用户上传的图像上传至素材库的流程,用户使用电子设备拍摄一张图像,在用户授权后,电子设备将图像、图像的分类信息(与素材库中图像的分类标签记录的信息相对应)、以及拍摄角度信息(与素材库中图像的角度标签记录的信息相对应)上传至素材库所在服务器,服务器根据上传图像的分类信息将图像进行分类进而保存至素材库的对应分类类别下。Referring to FIG. 6A , for the process of uploading an image uploaded by the user to the material library, the user uses an electronic device to shoot an image, and after the user authorizes the electronic device, the classification information of the image and the image (with the classification label of the image in the material library) (corresponding to the recorded information), and shooting angle information (corresponding to the information recorded by the angle label of the image in the material library) are uploaded to the server where the material library is located, and the server classifies the images according to the classification information of the uploaded images and saves them to the material library. under the corresponding category.
步骤402:电子设备获取到用户针对第一图像的背景更换操作。Step 402: The electronic device acquires the user's background replacement operation for the first image.
本步骤可以对应于图3中31部分,这里不赘述。This step may correspond to part 31 in FIG. 3 , and will not be repeated here.
步骤403:电子设备获取第一图像的拍摄角度信息、以及分类信息,将获取到的 上述信息上传服务器。Step 403: The electronic device acquires the shooting angle information and classification information of the first image, and uploads the acquired information to the server.
拍摄角度信息可以为拍摄姿态角;分类信息可以包括:素材库中各分类标签对应的参数值。例如素材库中图像的分类标签包括场景信息,则本步骤中图像的分类信息可以包括:场景信息的参数值。The shooting angle information may be the shooting attitude angle; the classification information may include: parameter values corresponding to each classification label in the material library. For example, the classification label of the image in the material library includes scene information, and the classification information of the image in this step may include: the parameter value of the scene information.
第一图像的拍摄角度信息、以及分类信息可以由电子设备在拍摄第一图像时对应确定,并作为第一图像的参数进行存储。The shooting angle information and the classification information of the first image may be correspondingly determined by the electronic device when shooting the first image, and stored as parameters of the first image.
电子设备可以基于自身中设置的加速度传感器和磁传感器等传感器获取电子设备的运动数据,基于电子设备的电子设备坐标系和第一坐标系,使用欧拉运动学方程计算欧拉角,电子设备基于电子设备拍摄第一图像时的运动数据计算得到的欧拉角包括的三个分量即对应第一图像的拍摄姿态角的俯仰角α、方位角β以及横滚角γ。The electronic device can obtain the motion data of the electronic device based on sensors such as acceleration sensor and magnetic sensor set in itself, and use the Euler kinematic equation to calculate the Euler angle based on the electronic device coordinate system and the first coordinate system of the electronic device. The Euler angle calculated by the motion data when the electronic device captures the first image includes three components, namely the pitch angle α, the azimuth angle β and the roll angle γ corresponding to the shooting attitude angle of the first image.
第一图像的分类信息可以由电子设备确定,例如:The classification information of the first image may be determined by the electronic device, for example:
场景信息可以由用户手动设置,也可以通过将第一图像输入预设的场景识别模型来确定。可选地,可以在电子设备中预设场景识别模型,该场景识别模型可以是通过对卷积神经网络训练得到的,训练原理可以为:采集室内和室外两种场景下一定数量的图像作为训练样本,并为每个训练样本设置标有室内或室外的场景标签,将训练样本输入卷积神经网络进行训练,得到场景识别模型,该场景识别模型是能够对图像进行室内、室外识别的二分类器;The scene information may be manually set by the user, or may be determined by inputting the first image into a preset scene recognition model. Optionally, a scene recognition model can be preset in the electronic device, the scene recognition model can be obtained by training a convolutional neural network, and the training principle can be: collecting a certain number of images in indoor and outdoor scenes as training. sample, and set a scene label marked indoor or outdoor for each training sample, input the training sample into the convolutional neural network for training, and obtain a scene recognition model, which is a binary classification that can recognize indoor and outdoor images. device;
光线信息可以由电子设备基于图像的亮度来确定。The light information may be determined by the electronic device based on the brightness of the image.
季节信息可以由电子设备基于拍摄第一图像时的时间以及电子设备所处地理位置确定,例如:电子设备拍摄第一图像时是1月,处于北京,则第一图像的季节信息为:冬;电子设备拍摄第一图像时是1月,处于悉尼,则第一图像的季节信息为夏。The season information may be determined by the electronic device based on the time when the first image was captured and the geographic location of the electronic device. For example, when the electronic device captured the first image in January and in Beijing, the season information of the first image is: winter; The electronic device captures the first image in January in Sydney, and the season information of the first image is summer.
天气信息可以由电子设备从电子设备安装的天气预报相关App中获取第一图像拍摄时的天气信息,进而确定第一图像的天气信息为:晴、或者雨、或者雪等。The weather information can be obtained by the electronic device from a weather forecast related App installed on the electronic device when the first image is taken, and then the weather information of the first image is determined as sunny, rainy, or snowy.
步骤404:服务器根据第一图像的分类信息查找到待选背景图像。Step 404: The server finds the background image to be selected according to the classification information of the first image.
素材集中按照分类标签进行分类存储,第一图像的分类信息与素材库中图像的分类标签相对应,根据第一图像的分类信息可以从素材库中查找到第一图像的分类信息对应的若干个图像,从素材库中查找到的图像即为待选背景图像。The material set is classified and stored according to the classification label. The classification information of the first image corresponds to the classification label of the image in the material library. According to the classification information of the first image, several pieces corresponding to the classification information of the first image can be found from the material library. Image, the image found from the material library is the background image to be selected.
例如,假设素材库依次根据场景信息(室内、室外)和光线信息(明、暗)这两个分类标签进行分类,第一图像的分类信息为:室内、明,则可以从素材库中查找到场景信息-室内、光线信息-明这一分类分支下的若干个图像作为待选背景图像。For example, assuming that the material library is classified according to the two classification labels of scene information (indoor, outdoor) and light information (bright, dark) in turn, the classification information of the first image is: indoor, bright, you can find it from the material library Several images under the classification branch of scene information-indoor, light information-bright are used as background images to be selected.
根据第一图像的分类信息查找待选背景图像,可以过滤掉素材库中与第一图像的分类信息不匹配的图像,防止后续展示给用户的待选背景图像过于繁杂、不合常理,例如,第一图像是在室内、冬天拍摄的图像,第一图像中的人物穿着厚厚的衣服,则分类标签记录的信息为(室内、夏天)、或者(室外、夏天)的图像就无需作为待选背景图像在后续步骤中作为推荐的背景图像展示给用户,否则,将一幅夏天花园的图像作为背景图像推荐给用户,显然是不符合常理的,通过本步骤的执行,可以将分类标签记录的信息为(室外、冬天)的图像从素材库中查找出来,进而推荐给用户作为待选背景图像。Searching for the background image to be selected according to the classification information of the first image can filter out the images in the material library that do not match the classification information of the first image, so as to prevent the background image to be displayed to the user from being too complicated and unreasonable. An image is an image taken indoors and in winter, and the person in the first image is wearing thick clothes, and the information recorded in the classification tag is (indoor, summer) or (outdoor, summer) images do not need to be selected as backgrounds The image is displayed to the user as a recommended background image in the subsequent steps. Otherwise, it is obviously unreasonable to recommend an image of a summer garden to the user as a background image. Through the execution of this step, the information recorded in the classification label can be The image for (outdoor, winter) is found from the material library, and then recommended to the user as the candidate background image.
步骤405:服务器根据第一图像的拍摄角度信息、以及待选背景图像的拍摄角度信息,计算每个待选背景图像与第一图像之间的拍摄角度差异值。Step 405: The server calculates the difference value of the shooting angle between each background image to be selected and the first image according to the shooting angle information of the first image and the shooting angle information of the background image to be selected.
拍摄角度信息为拍摄姿态角时,计算一个待选背景图像与第一图像之间的拍摄角 度差异值可以包括:When the shooting angle information is the shooting attitude angle, calculating a shooting angle difference value between a background image to be selected and the first image may include:
分别计算待选背景图像与第一图像之间俯仰角α的差值绝对值|Δα|、方位角β的差值绝对值|Δβ|、以及横滚角γ的差值绝对值|Δγ|;Calculate the absolute difference value of the pitch angle α between the background image to be selected and the first image |Δα|, the absolute value of the difference value of the azimuth angle β |Δβ|, and the absolute value of the difference value of the roll angle γ |Δγ|;
根据以下公式计算待选背景图像与第一图像之间的拍摄角度差异值ω:ω=W α|Δα|+W β|Δβ|+W γ|Δγ|;其中,W α是俯仰角的预设权重,W β是方位角的预设权重,W γ是横滚角的预设权重,其中,W β<W γ<W α,权重的具体取值本申请实施例不限定。 [Omega] is calculated photographing angle difference value between the candidate image and the first background image in accordance with the following equation: ω = W α | Δα | + W β | Δβ | + W γ | Δγ |; wherein, W α is the pitch angle of the pre Set the weight, W β is the preset weight of the azimuth angle, and W γ is the preset weight of the roll angle, where W β <W γ <W α , and the specific value of the weight is not limited in the embodiment of the present application.
步骤406:服务器根据每个待选背景图像对应的角度差异值对待选背景图像进行排序,将待选背景图像按照排序顺序发送至电子设备。Step 406: The server sorts the background images to be selected according to the angle difference values corresponding to each background image to be selected, and sends the background images to be selected to the electronic device in the sorted order.
以下,对步骤404~406的过程通过图6B进行说明。如图6B,服务器根据第一图片的分类信息查找到待选背景图像,根据每个待选背景图像的拍摄角度信息、以及第一图片的拍摄角度信息计算拍摄角度差异值,基于拍摄角度差异值对待选背景图像进行排序,可以按照拍摄角度差异值从小到大的顺序对待选背景图像进行排序。Hereinafter, the procedures of steps 404 to 406 will be described with reference to FIG. 6B . As shown in FIG. 6B , the server finds the background image to be selected according to the classification information of the first picture, calculates the shooting angle difference value according to the shooting angle information of each background image to be selected and the shooting angle information of the first picture, and calculates the shooting angle difference value based on the shooting angle difference value. To sort the background images to be selected, the background images to be selected can be sorted in descending order of the difference value of the shooting angle.
通过对待选背景图像按照拍摄角度差异值从小到大的顺序排序后发送至电子设备,由电子设备展示给用户,可以使得用户先浏览到的待选背景图像的拍摄角度更为接近第一图像的拍摄角度,从而根据用户选择的待选背景图像进行图像合成后得到的目标图像中人物图像和背景图像的融合相对更为合理、自然、协调。By sorting the background images to be selected according to the shooting angle difference value from small to large, and then sending them to the electronic device and displaying them to the user by the electronic device, the shooting angle of the background image to be selected first browsed by the user can be closer to that of the first image. According to the shooting angle, the fusion of the person image and the background image in the target image obtained after image synthesis according to the background image to be selected by the user is relatively more reasonable, natural and coordinated.
步骤407:电子设备接收服务器发送的待选背景图像,将待选背景图像展示给用户。Step 407: The electronic device receives the background image to be selected sent by the server, and displays the background image to be selected to the user.
本步骤的实现可以对应图3中32部分,这里不赘述。The implementation of this step may correspond to part 32 in FIG. 3 , and details are not described here.
步骤408:电子设备接收到用户针对于展示的一张背景图像的选择操作,将用户选择的背景图像作为第二图像。Step 408: The electronic device receives the user's selection operation for a displayed background image, and uses the background image selected by the user as the second image.
本步骤的实现可以对应图3中32部分,这里不赘述。The implementation of this step may correspond to part 32 in FIG. 3 , and details are not described here.
步骤409:电子设备获取第二图像的拍摄角度信息。Step 409: The electronic device acquires shooting angle information of the second image.
第二图像的拍摄角度信息可以在确定第二图像后由电子设备从服务器获取,或者在服务器将待选背景图像发送至电子设备进行展示时携带。The shooting angle information of the second image may be acquired by the electronic device from the server after the second image is determined, or carried when the server sends the background image to be selected to the electronic device for display.
步骤410:电子设备根据第一图像的拍摄角度信息和第二图像的拍摄角度信息,对第二图像进行三维(3D,three dimensional)视角变换,使得第二图像的拍摄角度达到或接近第一图像的拍摄角度,得到目标背景图像。Step 410: The electronic device performs three-dimensional (3D, three dimensional) perspective transformation on the second image according to the shooting angle information of the first image and the shooting angle information of the second image, so that the shooting angle of the second image reaches or is close to the first image the shooting angle to get the target background image.
其中,对第二图像进行3D视角变换可以使用3D肯·伯恩斯效应(3D Kens Burns Effect)算法实现,在该算法中,根据第二图像的拍摄姿态角为第二图像设置一个虚拟相机的位置,并对第二图像中的图像进行3D场景几何结构估计,得到第二图像中每个像素与虚拟相机之间的距离估计值;将虚拟相机的拍摄方向向第一图像的拍摄姿态角旋转,进而依据虚拟相机的旋转对第二图像进行调整。Among them, the 3D perspective transformation of the second image can be realized by using the 3D Kens Burns Effect (3D Kens Burns Effect) algorithm. In this algorithm, a virtual camera is set for the second image according to the shooting attitude angle of the second image. position, and perform 3D scene geometry estimation on the image in the second image to obtain an estimated distance between each pixel in the second image and the virtual camera; rotate the shooting direction of the virtual camera to the shooting attitude angle of the first image , and then adjust the second image according to the rotation of the virtual camera.
这里的像素与虚拟相机之间的距离估计值,也可以认为是像素对应的真实物体与拍摄第二图像的电子设备之间的实际距离的估计值。Here, the estimated value of the distance between the pixel and the virtual camera can also be regarded as the estimated value of the actual distance between the real object corresponding to the pixel and the electronic device that captures the second image.
在虚拟相机的旋转过程中,按优先级顺序,先对俯仰角α进行旋转,再对横滚角γ进行旋转,最后对方位角β进行旋转。During the rotation of the virtual camera, in the order of priority, the pitch angle α is rotated first, then the roll angle γ is rotated, and finally the azimuth angle β is rotated.
一般的,该算法下虚拟相机的拍摄姿态角的旋转具有一定的角度限制,在第二图像的拍摄姿态角与第一图像的拍摄姿态角之间的角度差异小于该角度限制时,通过该处理可以使得目标背景图像的拍摄姿态角与第一图像的拍摄姿态角相同,在第二图像的拍摄姿态角与第一图像的拍摄姿态角之间的角度差异超过该角度限制时,可能无法 使得目标背景图像的拍摄姿态角与第一图像的拍摄姿态角相同,但是通过该处理可以使得目标背景图像的拍摄姿态角更为接近第一图像的拍摄姿态角。Generally, the rotation of the shooting attitude angle of the virtual camera under this algorithm has a certain angle limit. When the angular difference between the shooting attitude angle of the second image and the shooting attitude angle of the first image is smaller than the angle limit, the processing The shooting attitude angle of the target background image can be made the same as the shooting attitude angle of the first image. When the angle difference between the shooting attitude angle of the second image and the shooting attitude angle of the first image exceeds the angle limit, it may not be possible to make the target The shooting attitude angle of the background image is the same as the shooting attitude angle of the first image, but through this process, the shooting attitude angle of the target background image can be made closer to the shooting attitude angle of the first image.
通过对第二图像进行3D视角变换,使得第二图像的拍摄角度达到或接近第一图像的拍摄角度,从而降低人物图像和第二图像之间的拍摄角度差别,使得人物图像和第二图像的拍摄角度尽量接近甚至一致,从而图像合成后得到的目标图像更为合理、自然、协调。By performing 3D perspective transformation on the second image, the shooting angle of the second image can reach or be close to the shooting angle of the first image, thereby reducing the shooting angle difference between the person image and the second image, so that the difference between the person image and the second image is reduced. The shooting angles should be as close to or even consistent as possible, so that the target image obtained after image synthesis is more reasonable, natural and coordinated.
步骤411:电子设备将目标背景图像展示给用户,获取用户指定的、人物图像在目标背景图像中的位置信息,确定该位置信息对应的第一距离估计值。Step 411 : The electronic device displays the target background image to the user, obtains the position information of the person image in the target background image specified by the user, and determines the first estimated distance value corresponding to the position information.
本步骤的实现可以对应图3中33部分;或者,电子设备也可以从第一图像中分离出人物图像,将人物图像放置于目标背景图像上,由用户拖动人物图像,从而指定人物图像在目标背景图像中的位置。The implementation of this step can correspond to part 33 in FIG. 3; or, the electronic device can also separate the person image from the first image, place the person image on the target background image, and drag the person image by the user, thereby specifying the person image in the The position in the target background image.
其中,位置信息可以是一个点的信息也可以是一个区域的信息。The location information may be information of a point or information of an area.
像素与虚拟相机之间的距离估计值在步骤410中对第二图像进行3D视角变换时一般即可以得到,如果步骤410处理过程中未确定第二图像中每个像素与虚拟相机之间的距离估计值,可以通过例如步骤410中示出的3D Kens Burns Effect算法计算得到。根据位置信息处的像素与虚拟相机之间的距离估计值,即可得到位置信息对应的第一距离估计值。其中,如果位置信息指示一个点,可以将该点对应的像素与虚拟相机之间的距离估计值确定为位置信息对应的第一距离估计值,如果位置信息指示一个区域,可以根据该区域包括的一个像素或者多个像素与虚拟相机之间的距离估计值,确定位置信息对应的第一距离估计值,如果根据该区域包括的多个像素与虚拟相机之间的距离估计值确定位置信息对应的第一距离估计值,可以通过计算多个像素对应的距离估计值的均值的方式确定位置信息对应的第一距离估计值。The estimated value of the distance between the pixel and the virtual camera can generally be obtained when performing 3D perspective transformation on the second image in step 410. If the distance between each pixel in the second image and the virtual camera is not determined during the processing in step 410 The estimated value can be calculated by, for example, the 3D Kens Burns Effect algorithm shown in step 410. According to the distance estimation value between the pixel at the location information and the virtual camera, the first distance estimation value corresponding to the location information can be obtained. Wherein, if the location information indicates a point, the estimated distance between the pixel corresponding to the point and the virtual camera may be determined as the first estimated distance corresponding to the location information. The estimated distance between one pixel or multiple pixels and the virtual camera, to determine the first estimated distance corresponding to the location information, if the estimated distance corresponding to the location information is determined according to the estimated distance between multiple pixels included in the area and the virtual camera. For the first distance estimation value, the first distance estimation value corresponding to the position information can be determined by calculating the mean value of the distance estimation values corresponding to a plurality of pixels.
步骤412:电子设备从第一图像中分离出人物图像,根据位置信息对应的第一距离估计值对人物图像进行缩放,得到目标人物图像。Step 412: The electronic device separates the person image from the first image, and scales the person image according to the first estimated distance value corresponding to the position information to obtain the target person image.
其中,电子设备从第一图像中分离出人物图像的步骤可以在步骤402与步骤412中根据位置信息对应的第一距离估计值对人物图像进行缩放的步骤之间执行,与步骤403~步骤411之间的执行顺序不限制。人物图像可以由电子设备自动分离,也可以由用户从第一图像中选择需要分离的人物图像。如果由用户选择,可以将第一图像展示给用户,由用户执行区域选择操作,相应的,电子设备可以基于用户的区域选择操作确定需要分离的人物图像,进而从第一图像中分离出人物图像。Wherein, the step of separating the person image from the first image by the electronic device may be performed between steps 402 and 412 of scaling the person image according to the first estimated distance value corresponding to the position information, and steps 403 to 411 The order of execution between them is not limited. The person image may be automatically separated by the electronic device, or the user may select the person image to be separated from the first image. If selected by the user, the first image can be displayed to the user, and the user can perform an area selection operation. Correspondingly, the electronic device can determine the person image to be separated based on the user's area selection operation, and then separate the person image from the first image. .
在一种可能的实现方式中,本步骤可以根据人眼间距是基本相同的原则,预先确定被拍摄的人与相机之间在不同拍摄距离下,人眼平均间距在分辨率相同的拍摄图像中占用的像素数,举例来说,人与相机距离10m,人眼平均间距在拍摄得到的图像中占用的像素数为x1,人与相机距离20m,人眼平均间距在拍摄得到的图像中占用的像素数为x2,等等。In a possible implementation, in this step, according to the principle that the distance between the human eyes is basically the same, it can be pre-determined that at different shooting distances between the person being photographed and the camera, the average distance between the human eyes in the captured images with the same resolution The number of pixels occupied, for example, if the distance between the human and the camera is 10m, the number of pixels occupied by the average distance between the human eyes in the captured image is x1, and the distance between the human and the camera is 20m. The number of pixels is x2, and so on.
在本步骤中,电子设备可以获取分离出的人物图像的人眼间距占用的像素数,根据人眼间距占用的像素数确定人物图像对应的第二距离估计值,根据位置信息对应的第一距离估计值以及人物图像对应的第二距离估计值对人物图像进行缩放,即可以得到目标人物图像。第二距离估计值也即是在拍摄第一图像时人物图像对应的人与拍摄第一图像的电子设备之间的距离估计值。In this step, the electronic device may obtain the number of pixels occupied by the distance between the human eyes of the separated person image, determine the second estimated distance value corresponding to the person image according to the number of pixels occupied by the distance between the human eyes, and determine the first distance corresponding to the position information according to the number of pixels occupied by the distance between the human eyes. The estimated value and the second estimated distance corresponding to the person image are scaled to the person image, that is, the target person image can be obtained. The second estimated distance value is also the estimated value of the distance between the person corresponding to the person image and the electronic device that photographed the first image when the first image is photographed.
在另一种可能的实现方式中,本步骤中可以使用例如3D Kens Burns Effect算法 计算第一图像中各个像素相对于虚拟相机的距离估计值,从而可以得到人物图像包括的像素对应的距离估计值,根据人物图像包括的像素对应的距离估计值可以确定人物图像对应的第二距离估计值,例如取人物图像包括的所有像素的距离估计值的平均值、或者取某一预设位置例如眼部的像素的距离估计值等。根据位置信息对应的第一距离估计值以及人物图像对应的第二距离估计值对人物图像进行缩放,可以得到目标人物图像。In another possible implementation, in this step, for example, the 3D Kens Burns Effect algorithm can be used to calculate the estimated distance of each pixel in the first image relative to the virtual camera, so that the estimated distance corresponding to the pixels included in the person image can be obtained. , the second distance estimation value corresponding to the person image can be determined according to the distance estimation value corresponding to the pixels included in the person image, for example, taking the average value of the distance estimation values of all the pixels included in the person image, or taking a certain preset position such as the eye The distance estimate of the pixel, etc. The target person image can be obtained by scaling the person image according to the first estimated distance value corresponding to the position information and the second estimated distance value corresponding to the person image.
本步骤中根据位置信息对应的第一距离估计值对人物图像进行缩放,可以使得人物图像的大小更趋近于人实际站在第二图像对应的实际场景下同一位置时拍摄的人物大小,从而使得合成后的目标图像在视觉上更为合理、自然、协调。In this step, the image of the person is scaled according to the first estimated distance value corresponding to the position information, so that the size of the image of the person is closer to the size of the person photographed when the person actually stands at the same position in the actual scene corresponding to the second image, thereby It makes the synthesized target image more reasonable, natural and coordinated visually.
步骤413:电子设备对目标人物图像和/或目标背景图像的颜色参数进行调整,将调整后的目标人物图像和目标背景图像进行合成,得到目标图像。Step 413: The electronic device adjusts the color parameters of the target person image and/or the target background image, and synthesizes the adjusted target person image and the target background image to obtain the target image.
颜色参数可以包括色温、和/或对比度等。Color parameters may include color temperature, and/or contrast, among others.
通过对颜色参数的调整,可以使得目标人物图像和目标背景图像的颜色参数更为接近,从而使得合成后的目标图像更为自然和合理。By adjusting the color parameters, the color parameters of the target person image and the target background image can be made closer, thereby making the synthesized target image more natural and reasonable.
在一种实现方式中,可以计算目标背景图像的色温和目标人物图像的色温,据此调整目标人物图像的色温,使得目标人物图像的色温更接近目标背景图像的色温。图像的色温计算方法本申请实施例不再赘述,例如可以使用自动白平衡算法中的色温估计方法来计算目标背景图像的色温。In one implementation, the color temperature of the target background image can be calculated, and the color temperature of the target person image can be adjusted accordingly, so that the color temperature of the target person image is closer to the color temperature of the target background image. The color temperature calculation method of the image will not be repeated in this embodiment of the present application. For example, the color temperature estimation method in the automatic white balance algorithm may be used to calculate the color temperature of the target background image.
本步骤中通过对目标人物图像和/或目标背景图像的颜色参数进行调整,缩小两者之间的颜色差异,可以使得合成后得到的目标图像在视觉上颜色更为协调、合理、自然。In this step, by adjusting the color parameters of the target person image and/or the target background image to reduce the color difference between the two, the target image obtained after synthesis can be visually more harmonious, reasonable and natural in color.
步骤414:电子设备将目标图像展示给用户。Step 414: The electronic device presents the target image to the user.
本步骤可以对应图3中34部分,这里不赘述。This step may correspond to part 34 in FIG. 3 , and will not be repeated here.
现有的抠图换背景的处理中,直接按照用户编辑的人物图像的大小将其合成至用户选择的背景图像中,人物图像和背景图像存在拍摄角度、场景逻辑、光线、视野远近等的差异,很容易造成合成的图像整体协调性差、图像失真、场景逻辑出错以及光影差异等问题,导致合成的图像失真、不自然。In the existing process of cutting out the background and changing the background, the image of the person edited by the user is directly synthesized into the background image selected by the user according to the size of the image. , it is easy to cause problems such as poor overall coordination of the synthesized image, image distortion, scene logic errors, and light and shadow differences, resulting in distorted and unnatural synthesized images.
而本申请实施例的图像合成方法,解决了抠图换背景过程中存在的上述问题,缩小第一图像和第二图像之间存在的拍摄角度差异,另外,还可以缩小场景逻辑差异、颜色差异和/或视野场景深度的差异,使得图像合成后得到的目标图像在视觉上更为合理、自然、协调,提升用户体验。However, the image synthesis method of the embodiment of the present application solves the above-mentioned problems existing in the process of cutout and background replacement, reduces the difference in shooting angle between the first image and the second image, and can also reduce the difference in scene logic and color. And/or the difference in the depth of the field of view and the scene, the target image obtained after image synthesis is visually more reasonable, natural, and coordinated, and the user experience is improved.
以上以分离出第一图像中人物图像与第二图像合成,也即更换第一图像中人物图像的背景图像为例,本申请实施例的方法也可以从人物图像扩展至任一存在物的图像,例如动物图像、物体图像等等,以下将从第一图像中分离出来的、需要与第二图像进行合成的图像称为前景图像。Taking the separation of the person image in the first image and the synthesis of the second image, that is, replacing the background image of the person image in the first image as an example, the method of the embodiment of the present application can also be extended from the person image to the image of any object. , such as animal images, object images, etc., the image that is separated from the first image and needs to be synthesized with the second image is called the foreground image hereinafter.
本申请实施例的方法可以扩展至对视频中图像的合成方法,从而更换视频中图像的背景图像,在对视频处理时,视频中的每一帧图像可以作为本申请实施例中的第一图像。The method in this embodiment of the present application can be extended to a method for synthesizing images in the video, so as to replace the background image of the image in the video. When processing the video, each frame of image in the video can be used as the first image in the embodiment of the present application. .
图7为本申请图像合成方法一个实施例的流程图,可以应用于电子设备,如图7所示,该方法可以包括:FIG. 7 is a flowchart of an embodiment of an image synthesis method of the present application, which can be applied to an electronic device. As shown in FIG. 7 , the method may include:
步骤701:接收到用户针对第一图像的背景更换操作,获取第一图像的拍摄角度 信息;Step 701: receive the background replacement operation of the user for the first image, and obtain the shooting angle information of the first image;
步骤702:获取第二图像、以及第二图像的拍摄角度信息;Step 702: Acquire a second image and shooting angle information of the second image;
步骤703:根据第一图像的拍摄角度信息和第二图像的拍摄角度信息对第二图像进行3D视角变换,使得第二图像的拍摄角度达到或接近第一图像的拍摄角度,得到目标背景图像;Step 703: Perform 3D perspective transformation on the second image according to the shooting angle information of the first image and the shooting angle information of the second image, so that the shooting angle of the second image reaches or is close to the shooting angle of the first image, and the target background image is obtained;
步骤704:将从第一图像中分离出的前景图像与所述目标背景图像进行图像合成,得到目标图像。Step 704: Perform image synthesis on the foreground image separated from the first image and the target background image to obtain a target image.
其中,所述前景图像可以是图4所示实施例中的人物图像,也可以是其他存在物的图像,例如动物图像、物体图像等等。电子设备可以将第一图像展示给用户,由用户执行区域选择操作,相应的,电子设备可以将用户的区域选择操作指示的区域作为前景图像的区域,进而从第一图像中分离出前景图像。The foreground image may be the person image in the embodiment shown in FIG. 4 , or may be an image of other existing objects, such as animal images, object images, and the like. The electronic device may display the first image to the user, and the user may perform a region selection operation. Correspondingly, the electronic device may use the region indicated by the user's region selection operation as the region of the foreground image, and then separate the foreground image from the first image.
可选地,步骤702中获取第二图像,可以包括:Optionally, acquiring the second image in step 702 may include:
获取第一图像的预设分类信息;obtaining preset classification information of the first image;
获取并展示与第一图像的预设分类信息匹配的待选背景图像;展示的待选背景图像按照待选背景图像与第一图像之间的拍摄角度差异值从小到大排序;待选背景图像与第一图像之间的拍摄角度差异值根据待选背景图像的拍摄角度信息、以及第一图像的拍摄角度信息计算得到;Obtain and display the background images to be selected that match the preset classification information of the first image; the displayed background images to be selected are sorted from small to large according to the shooting angle difference between the background images to be selected and the first image; the background images to be selected The shooting angle difference value with the first image is calculated according to the shooting angle information of the background image to be selected and the shooting angle information of the first image;
接收到用户针对于待选背景图像的选择操作,将选择操作指示的待选背景图像作为第二图像。After receiving the user's selection operation on the background image to be selected, the background image to be selected indicated by the selection operation is used as the second image.
可选地,电子设备也可以从电子设备本地获取第二图像,例如用户选择电子设备的相册中的某一图像作为第二图像,相应的,电子设备可以根据用户的操作获取到用户选择的第二图像。Optionally, the electronic device can also obtain the second image locally from the electronic device, for example, the user selects an image in the album of the electronic device as the second image, and accordingly, the electronic device can obtain the first image selected by the user according to the user's operation. Second image.
可选地,获取与第一图像的预设分类信息匹配的待选背景图像,可以包括:Optionally, acquiring a background image to be selected that matches the preset classification information of the first image may include:
向服务器发送第一图像的拍摄角度信息、以及预设分类信息;sending the shooting angle information of the first image and the preset classification information to the server;
接收服务器发送的与第一图像的预设分类信息匹配的待选背景图像,待选背景图像由服务器按照待选背景图像与第一图像之间的拍摄角度差异值排序,待选背景图像与第一图像之间的拍摄角度差异值由服务器根据待选背景图像的拍摄角度信息、以及第一图像的拍摄角度信息计算得到。Receive the background image to be selected that matches the preset classification information of the first image sent by the server, the background image to be selected is sorted by the server according to the difference value of the shooting angle between the background image to be selected and the first image, the background image to be selected and the first image are sorted by the server. The difference value of the shooting angle between the images is calculated by the server according to the shooting angle information of the background image to be selected and the shooting angle information of the first image.
可选地,步骤704可以包括:Optionally, step 704 may include:
展示目标背景图像,接收到用户在目标背景图像上的位置指定操作,得到用户在目标背景图像上指定位置的位置信息;Display the target background image, receive the user's position designation operation on the target background image, and obtain the position information of the user's designated position on the target background image;
确定位置信息对应的第一距离估计值;determining the first distance estimation value corresponding to the location information;
根据第一距离估计值对前景图像进行缩放,得到目标前景图像;Scaling the foreground image according to the first distance estimation value to obtain the target foreground image;
将目标前景图像合成至目标背景图像中位置信息指示的位置,得到目标图像。The target foreground image is synthesized to the position indicated by the position information in the target background image to obtain the target image.
可选地,将目标前景图像合成至目标背景图像上位置信息指示的位置,得到目标图像之前,还可以包括:Optionally, before synthesizing the target foreground image to the position indicated by the position information on the target background image, before obtaining the target image, it may further include:
对目标前景图像和/或目标背景图像的颜色参数进行调整。Adjust the color parameters of the target foreground image and/or the target background image.
可选地,拍摄角度信息可以包括:拍摄姿态角,拍摄姿态角包括:俯仰角、方位角和横滚角。Optionally, the shooting angle information may include: a shooting attitude angle, and the shooting attitude angle includes: a pitch angle, an azimuth angle, and a roll angle.
可以理解的是,上述实施例中的部分或全部步骤骤或操作仅是示例,本申请实施例还可以执行其它操作或者各种操作的变形。此外,各个步骤可以按照上述实施例呈 现的不同的顺序来执行,并且有可能并非要执行上述实施例中的全部操作。It can be understood that, some or all of the steps or operations in the foregoing embodiments are merely examples, and other operations or variations of various operations may also be performed in the embodiments of the present application. Furthermore, the various steps may be performed in a different order than those presented in the above-described embodiments, and it is possible that not all operations in the above-described embodiments are performed.
图8为本申请图像合成装置一个实施例的结构图,可以应用于电子设备,如图8所示,该装置80可以包括:FIG. 8 is a structural diagram of an embodiment of an image synthesis apparatus of the present application, which can be applied to electronic equipment. As shown in FIG. 8 , the apparatus 80 may include:
获取单元81,用于接收到用户针对第一图像的背景更换操作,获取第一图像的拍摄角度信息;获取第二图像、以及第二图像的拍摄角度信息;The obtaining unit 81 is configured to receive the user's background replacement operation for the first image, obtain the shooting angle information of the first image; obtain the second image and the shooting angle information of the second image;
变换单元82,用于根据第一图像的拍摄角度信息和第二图像的拍摄角度信息对第二图像进行3D视角变换,使得第二图像的拍摄角度达到或接近第一图像的拍摄角度,得到目标背景图像;The transformation unit 82 is configured to perform 3D perspective transformation on the second image according to the shooting angle information of the first image and the shooting angle information of the second image, so that the shooting angle of the second image reaches or is close to the shooting angle of the first image, and the target is obtained. background image;
合成单元83,用于将从第一图像中分离出的前景图像与所述目标背景图像进行图像合成,得到目标图像。The synthesis unit 83 is configured to perform image synthesis between the foreground image separated from the first image and the target background image to obtain the target image.
可选地,获取单元具体可以用于:获取第一图像的预设分类信息;获取并展示与第一图像的预设分类信息匹配的待选背景图像;展示的待选背景图像按照待选背景图像与第一图像之间的拍摄角度差异值从小到大排序;待选背景图像与第一图像之间的拍摄角度差异值根据待选背景图像的拍摄角度信息、以及第一图像的拍摄角度信息计算得到;接收到用户针对于待选背景图像的选择操作,将选择操作指示的待选背景图像作为第二图像。Optionally, the acquiring unit may be specifically configured to: acquire preset classification information of the first image; acquire and display a background image to be selected that matches the preset classification information of the first image; the background image to be displayed is displayed according to the background image to be selected. The shooting angle difference value between the image and the first image is sorted from small to large; the shooting angle difference value between the background image to be selected and the first image is based on the shooting angle information of the background image to be selected and the shooting angle information of the first image Obtained by calculation; after receiving the user's selection operation on the background image to be selected, the background image to be selected indicated by the selection operation is used as the second image.
可选地,获取单元具体可以用于:向服务器发送第一图像的拍摄角度信息、以及预设分类信息;接收服务器发送的与第一图像的预设分类信息匹配的待选背景图像,待选背景图像由服务器按照待选背景图像与第一图像之间的拍摄角度差异值排序,待选背景图像与第一图像之间的拍摄角度差异值由服务器根据待选背景图像的拍摄角度信息、以及第一图像的拍摄角度信息计算得到。Optionally, the acquiring unit may be specifically configured to: send the shooting angle information of the first image and the preset classification information to the server; receive the background image to be selected that matches the preset classification information of the first image sent by the server, and the to-be-selected background image is sent to the server. The background images are sorted by the server according to the shooting angle difference value between the background image to be selected and the first image, and the shooting angle difference value between the background image to be selected and the first image is sorted by the server according to the shooting angle information of the background image to be selected, and The shooting angle information of the first image is calculated.
可选地,合成单元具体可以用于:展示目标背景图像,接收到用户在目标背景图像上的位置指定操作,得到用户在目标背景图像上指定位置的位置信息;确定位置信息对应的第一距离估计值;根据第一距离估计值对前景图像进行缩放,得到目标前景图像;将目标前景图像合成至目标背景图像中位置信息指示的位置,得到目标图像。Optionally, the synthesizing unit can be specifically used to: display the target background image, receive the user's position specifying operation on the target background image, and obtain the position information of the user's specified position on the target background image; determine the first distance corresponding to the position information. estimated value; zoom the foreground image according to the first distance estimated value to obtain the target foreground image; synthesize the target foreground image to the position indicated by the position information in the target background image to obtain the target image.
可选地,合成单元还可以用于:对目标前景图像和/或目标背景图像的颜色参数进行调整。Optionally, the synthesizing unit may also be used to: adjust the color parameters of the target foreground image and/or the target background image.
可选地,拍摄角度信息可以包括:拍摄姿态角,拍摄姿态角包括:俯仰角、方位角和横滚角。Optionally, the shooting angle information may include: a shooting attitude angle, and the shooting attitude angle includes: a pitch angle, an azimuth angle, and a roll angle.
图8所示实施例提供的装置可用于执行本申请图4~图7所示方法实施例的技术方案,其实现原理和技术效果可以进一步参考方法实施例中的相关描述。The apparatus provided by the embodiment shown in FIG. 8 can be used to implement the technical solutions of the method embodiments shown in FIG. 4 to FIG. 7 of the present application. For the implementation principle and technical effect, reference may be made to the related descriptions in the method embodiments.
应理解以上图8所示装置的各个单元的划分仅仅是一种逻辑功能的划分,实际实现时可以全部或部分集成到一个物理实体上,也可以物理上分开。且这些单元可以全部以软件通过处理元件调用的形式实现;也可以全部以硬件的形式实现;还可以部分单元以软件通过处理元件调用的形式实现,部分单元通过硬件的形式实现。例如,合成单元可以为单独设立的处理元件,也可以集成在电子设备的某一个芯片中实现。其它单元的实现与之类似。此外这些单元全部或部分可以集成在一起,也可以独立实现。在实现过程中,上述方法的各步骤或以上各个单元可以通过处理器元件中的硬件的集成逻辑电路或者软件形式的指令完成。It should be understood that the division of each unit of the apparatus shown in FIG. 8 above is only a division of logical functions, and in actual implementation, it may be fully or partially integrated into a physical entity, or may be physically separated. And these units can all be implemented in the form of software calling through processing elements; they can also all be implemented in hardware; some units can also be implemented in the form of software calling through processing elements, and some units can be implemented in hardware. For example, the synthesis unit may be a separately established processing element, or may be integrated in a certain chip of an electronic device. The implementation of other units is similar. In addition, all or part of these units can be integrated together, and can also be implemented independently. In the implementation process, each step of the above-mentioned method or each of the above-mentioned units may be completed by an integrated logic circuit of hardware in the processor element or an instruction in the form of software.
例如,以上这些单元可以是被配置成实施以上方法的一个或多个集成电路,例如:一个或多个特定集成电路(Application Specific Integrated Circuit;以下简称:ASIC), 或,一个或多个微处理器(Digital Singnal Processor;以下简称:DSP),或,一个或者多个现场可编程门阵列(Field Programmable Gate Array;以下简称:FPGA)等。再如,这些单元可以集成在一起,以片上系统(System-On-a-Chip;以下简称:SOC)的形式实现。For example, the above units may be one or more integrated circuits configured to implement the above method, such as: one or more specific integrated circuits (Application Specific Integrated Circuit; hereinafter referred to as: ASIC), or, one or more microprocessors Digital Singnal Processor (hereinafter referred to as: DSP), or, one or more Field Programmable Gate Array (Field Programmable Gate Array; hereinafter referred to as: FPGA), etc. For another example, these units can be integrated together and implemented in the form of a system-on-a-chip (System-On-a-Chip; hereinafter referred to as: SOC).
本申请实施例还提供一种电子设备,电子设备可以包括:显示屏;一个或多个处理器;存储器;多个应用程序;以及一个或多个计算机程序。其中上述一个或多个计算机程序被存储在上述存储器中,上述一个或多个计算机程序包括指令,当上述指令被上述设备执行时,使得上述设备执行以下步骤:Embodiments of the present application further provide an electronic device, which may include: a display screen; one or more processors; a memory; multiple application programs; and one or more computer programs. Wherein the above-mentioned one or more computer programs are stored in the above-mentioned memory, and the above-mentioned one or more computer programs include instructions that, when the above-mentioned instructions are executed by the above-mentioned equipment, cause the above-mentioned equipment to perform the following steps:
接收到用户针对第一图像的背景更换操作,获取第一图像的拍摄角度信息;Receive the background replacement operation of the user for the first image, and obtain the shooting angle information of the first image;
获取第二图像、以及第二图像的拍摄角度信息;acquiring the second image and the shooting angle information of the second image;
根据第一图像的拍摄角度信息和第二图像的拍摄角度信息对第二图像进行3D视角变换,使得第二图像的拍摄角度达到或接近第一图像的拍摄角度,得到目标背景图像;3D perspective transformation is performed on the second image according to the shooting angle information of the first image and the shooting angle information of the second image, so that the shooting angle of the second image reaches or is close to the shooting angle of the first image, and the target background image is obtained;
将从第一图像中分离出的前景图像与所述目标背景图像进行图像合成,得到目标图像。The foreground image separated from the first image is combined with the target background image to obtain the target image.
其中,所述前景图像可以是图4所示实施例中的人物图像,也可以是其他存在物的图像,例如动物图像、物体图像等等。电子设备可以将第一图像展示给用户,由用户执行区域选择操作,相应的,电子设备可以将用户的区域选择操作指示的区域作为前景图像的区域,进而从第一图像中分离出前景图像。The foreground image may be the person image in the embodiment shown in FIG. 4 , or may be an image of other existing objects, such as animal images, object images, and the like. The electronic device may display the first image to the user, and the user may perform a region selection operation. Correspondingly, the electronic device may use the region indicated by the user's region selection operation as the region of the foreground image, and then separate the foreground image from the first image.
可选地,获取第二图像的步骤,可以包括:Optionally, the step of acquiring the second image may include:
获取第一图像的预设分类信息;obtaining preset classification information of the first image;
获取并展示与第一图像的预设分类信息匹配的待选背景图像;展示的待选背景图像按照待选背景图像与第一图像之间的拍摄角度差异值排序;待选背景图像与第一图像之间的拍摄角度差异值根据待选背景图像的拍摄角度信息、以及第一图像的拍摄角度信息计算得到;Obtain and display the background images to be selected that match the preset classification information of the first image; the displayed background images to be selected are sorted according to the difference value of the shooting angle between the background images to be selected and the first image; The shooting angle difference value between the images is calculated according to the shooting angle information of the background image to be selected and the shooting angle information of the first image;
接收到用户针对于待选背景图像的选择操作,将选择操作指示的待选背景图像作为第二图像。After receiving the user's selection operation on the background image to be selected, the background image to be selected indicated by the selection operation is used as the second image.
可选地,电子设备也可以从电子设备本地获取第二图像,例如用户选择电子设备的相册中的某一图像作为第二图像,相应的,电子设备可以根据用户的操作获取到用户选择的第二图像。Optionally, the electronic device can also obtain the second image locally from the electronic device, for example, the user selects an image in the album of the electronic device as the second image, and accordingly, the electronic device can obtain the first image selected by the user according to the user's operation. Second image.
可选地,获取与第一图像的预设分类信息匹配的待选背景图像的步骤,可以包括:Optionally, the step of acquiring a background image to be selected that matches the preset classification information of the first image may include:
向服务器发送第一图像的拍摄角度信息、以及预设分类信息;sending the shooting angle information of the first image and the preset classification information to the server;
接收服务器发送的与第一图像的预设分类信息匹配的待选背景图像,待选背景图像由服务器按照待选背景图像与第一图像之间的拍摄角度差异值从小到大排序,待选背景图像与第一图像之间的拍摄角度差异值由服务器根据待选背景图像的拍摄角度信息、以及第一图像的拍摄角度信息计算得到。The background images to be selected that match the preset classification information of the first image sent by the server are received, the background images to be selected are sorted by the server according to the difference in shooting angle between the background images to be selected and the first image, and the background images to be selected are sorted from small to large. The difference value of the shooting angle between the image and the first image is calculated by the server according to the shooting angle information of the background image to be selected and the shooting angle information of the first image.
可选地,将从第一图像中分离出的前景图像与所述目标背景图像进行图像合成,得到目标图像的步骤,可以包括:Optionally, the step of performing image synthesis between the foreground image separated from the first image and the target background image to obtain the target image may include:
展示目标背景图像,接收到用户在目标背景图像上的位置指定操作,得到用户在目标背景图像上指定位置的位置信息;Display the target background image, receive the user's position designation operation on the target background image, and obtain the position information of the user's designated position on the target background image;
确定位置信息对应的第一距离估计值;determining the first distance estimation value corresponding to the location information;
根据第一距离估计值对前景图像进行缩放,得到目标前景图像;Scaling the foreground image according to the first distance estimation value to obtain the target foreground image;
将目标前景图像合成至目标背景图像中位置信息指示的位置,得到目标图像。The target foreground image is synthesized to the position indicated by the position information in the target background image to obtain the target image.
可选地,将目标前景图像合成至目标背景图像上位置信息指示的位置,得到目标图像的步骤之前,还可以包括:Optionally, before the step of synthesizing the target foreground image to the position indicated by the position information on the target background image, the step of obtaining the target image may further include:
对目标前景图像和/或目标背景图像的颜色参数进行调整。Adjust the color parameters of the target foreground image and/or the target background image.
可选地,拍摄角度信息可以包括:拍摄姿态角,拍摄姿态角包括:俯仰角、方位角和横滚角。Optionally, the shooting angle information may include: a shooting attitude angle, and the shooting attitude angle includes: a pitch angle, an azimuth angle, and a roll angle.
本申请还提供一种电子设备,所述设备包括存储介质和中央处理器,所述存储介质可以是非易失性存储介质,所述存储介质中存储有计算机可执行程序,所述中央处理器与所述非易失性存储介质连接,并执行所述计算机可执行程序以实现本申请图4~图7所示实施例提供的方法。The present application also provides an electronic device, the device includes a storage medium and a central processing unit, the storage medium may be a non-volatile storage medium, and a computer-executable program is stored in the storage medium, and the central processing unit is connected to the central processing unit. The non-volatile storage medium is connected, and the computer-executable program is executed to implement the method provided by the embodiments shown in FIG. 4 to FIG. 7 of the present application.
本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行本申请图4~图7所示实施例提供的方法。Embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when it runs on a computer, the computer causes the computer to execute the programs provided by the embodiments shown in FIG. 4 to FIG. 7 of the present application. method.
本申请实施例还提供一种计算机程序产品,该计算机程序产品包括计算机程序,当其在计算机上运行时,使得计算机执行本申请图4~图7所示实施例提供的方法。An embodiment of the present application further provides a computer program product, where the computer program product includes a computer program that, when running on a computer, enables the computer to execute the methods provided by the embodiments shown in FIGS. 4 to 7 of the present application.
本申请实施例中,“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示单独存在A、同时存在A和B、单独存在B的情况。其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项”及其类似表达,是指的这些项中的任意组合,包括单项或复数项的任意组合。例如,a,b和c中的至少一项可以表示:a,b,c,a和b,a和c,b和c或a和b和c,其中a,b,c可以是单个,也可以是多个。In the embodiments of the present application, "at least one" refers to one or more, and "multiple" refers to two or more. "And/or", which describes the association relationship of the associated objects, means that there can be three kinds of relationships, for example, A and/or B, which can indicate the existence of A alone, the existence of A and B at the same time, and the existence of B alone. where A and B can be singular or plural. The character "/" generally indicates that the associated objects are an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, and c may represent: a, b, c, a and b, a and c, b and c or a and b and c, where a, b, c may be single, or Can be multiple.
本领域普通技术人员可以意识到,本文中公开的实施例中描述的各单元及算法步骤,能够以电子硬件、计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art can realize that the units and algorithm steps described in the embodiments disclosed herein can be implemented by a combination of electronic hardware, computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementations should not be considered beyond the scope of this application.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described systems, devices and units may refer to the corresponding processes in the foregoing method embodiments, which will not be repeated here.
在本申请所提供的几个实施例中,任一功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory;以下简称:ROM)、随机存取存储器(Random Access Memory;以下简称:RAM)、磁碟或者光盘等各种可以存储程序代码的介质。In the several embodiments provided in this application, if any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be embodied in the form of a software product in essence, or the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, Read-Only Memory (Read-Only Memory; hereinafter referred to as: ROM), Random Access Memory (Random Access Memory; hereinafter referred to as: RAM), magnetic disk or optical disk and other various A medium on which program code can be stored.
以上所述,仅为本申请的具体实施方式,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。本申请的保护范围应以所述权利要求的保护范围为准。The above are only specific embodiments of the present application. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application. The protection scope of the present application shall be subject to the protection scope of the claims.

Claims (12)

  1. 一种图像合成方法,应用于电子设备,其特征在于,包括:An image synthesis method, applied to electronic equipment, is characterized in that, comprising:
    接收到用户针对第一图像的背景更换操作,获取所述第一图像的拍摄角度信息;receiving the background replacement operation of the user for the first image, and acquiring the shooting angle information of the first image;
    获取第二图像、以及所述第二图像的拍摄角度信息;acquiring a second image and shooting angle information of the second image;
    根据所述第一图像的拍摄角度信息和所述第二图像的拍摄角度信息对所述第二图像进行3D视角变换,使得所述第二图像的拍摄角度达到或接近所述第一图像的拍摄角度,得到目标背景图像;3D perspective transformation is performed on the second image according to the shooting angle information of the first image and the shooting angle information of the second image, so that the shooting angle of the second image reaches or is close to the shooting angle of the first image. Angle, get the target background image;
    将从第一图像中分离出的前景图像与所述目标背景图像进行图像合成,得到目标图像。The foreground image separated from the first image is combined with the target background image to obtain the target image.
  2. 根据权利要求1所述的方法,其特征在于,所述获取第二图像,包括:The method according to claim 1, wherein the acquiring the second image comprises:
    获取所述第一图像的预设分类信息;acquiring preset classification information of the first image;
    获取并展示与所述第一图像的预设分类信息匹配的待选背景图像;展示的所述待选背景图像按照所述待选背景图像与所述第一图像之间的拍摄角度差异值从小到大排序;所述待选背景图像与所述第一图像之间的拍摄角度差异值根据所述待选背景图像的拍摄角度信息、以及所述第一图像的拍摄角度信息计算得到;Acquire and display a background image to be selected that matches the preset classification information of the first image; the background image to be displayed is displayed according to the shooting angle difference between the background image to be selected and the first image. Sorting from the largest to the largest; the difference value of the shooting angle between the background image to be selected and the first image is calculated according to the shooting angle information of the background image to be selected and the shooting angle information of the first image;
    接收到所述用户针对于所述待选背景图像的选择操作,将所述选择操作指示的待选背景图像作为第二图像。After receiving the user's selection operation on the background image to be selected, the background image to be selected indicated by the selection operation is used as the second image.
  3. 根据权利要求2所述的方法,其特征在于,所述获取与所述第一图像的预设分类信息匹配的待选背景图像,包括:The method according to claim 2, wherein the acquiring a background image to be selected that matches the preset classification information of the first image comprises:
    向服务器发送所述第一图像的拍摄角度信息、以及预设分类信息;sending the shooting angle information and preset classification information of the first image to the server;
    接收所述服务器发送的与所述第一图像的预设分类信息匹配的待选背景图像,所述待选背景图像由所述服务器按照所述待选背景图像与所述第一图像之间的拍摄角度差异值排序,所述待选背景图像与所述第一图像之间的拍摄角度差异值由所述服务器根据所述待选背景图像的拍摄角度信息、以及所述第一图像的拍摄角度信息计算得到。Receive a background image to be selected that matches the preset classification information of the first image sent by the server, and the background image to be selected is sent by the server according to the relationship between the background image to be selected and the first image. The shooting angle difference value is sorted, and the shooting angle difference value between the background image to be selected and the first image is determined by the server according to the shooting angle information of the background image to be selected and the shooting angle of the first image. information is calculated.
  4. 根据权利要求1至3任一项所述的方法,其特征在于,所述将从第一图像中分离出的前景图像与所述目标背景图像进行图像合成,得到目标图像,包括:The method according to any one of claims 1 to 3, wherein the image synthesis of the foreground image separated from the first image and the target background image to obtain the target image comprises:
    展示所述目标背景图像,接收到所述用户在所述目标背景图像上的位置指定操作,得到所述用户在所述目标背景图像上指定位置的位置信息;Displaying the target background image, receiving a position specifying operation of the user on the target background image, and obtaining the position information of the position specified by the user on the target background image;
    确定所述位置信息对应的第一距离估计值;determining a first distance estimate corresponding to the location information;
    根据所述第一距离估计值对所述前景图像进行缩放,得到目标前景图像;Scaling the foreground image according to the first distance estimation value to obtain a target foreground image;
    将所述目标前景图像合成至所述目标背景图像中所述位置信息指示的位置,得到目标图像。The target foreground image is synthesized to the position indicated by the position information in the target background image to obtain a target image.
  5. 根据权利要求4所述的方法,其特征在于,所述将所述目标前景图像合成至所述目标背景图像上所述位置信息指示的位置,得到目标图像之前,还包括:The method according to claim 4, wherein before obtaining the target image by synthesizing the target foreground image to the position indicated by the position information on the target background image, the method further comprises:
    对所述目标前景图像和/或所述目标背景图像的颜色参数进行调整。Adjusting the color parameters of the target foreground image and/or the target background image.
  6. 根据权利要求1至3任一项所述的方法,其特征在于,所述拍摄角度信息包 括:拍摄姿态角,所述拍摄姿态角包括:俯仰角、方位角和横滚角。The method according to any one of claims 1 to 3, wherein the shooting angle information includes: a shooting attitude angle, and the shooting attitude angle includes: a pitch angle, an azimuth angle, and a roll angle.
  7. 一种电子设备,其特征在于,包括:An electronic device, comprising:
    显示屏;一个或多个处理器;存储器;以及一个或多个计算机程序,其中所述一个或多个计算机程序被存储在所述存储器中,所述一个或多个计算机程序包括指令,当所述指令被所述设备执行时,使得所述设备执行以下步骤:a display screen; one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, the one or more computer programs comprising instructions for When the instruction is executed by the device, the device is caused to perform the following steps:
    接收到用户针对第一图像的背景更换操作,获取所述第一图像的拍摄角度信息;receiving the background replacement operation of the user for the first image, and acquiring the shooting angle information of the first image;
    获取第二图像、以及所述第二图像的拍摄角度信息;acquiring a second image and shooting angle information of the second image;
    根据所述第一图像的拍摄角度信息和所述第二图像的拍摄角度信息对所述第二图像进行3D视角变换,使得所述第二图像的拍摄角度达到或接近所述第一图像的拍摄角度,得到目标背景图像;3D perspective transformation is performed on the second image according to the shooting angle information of the first image and the shooting angle information of the second image, so that the shooting angle of the second image reaches or is close to the shooting angle of the first image. Angle, get the target background image;
    将从所述第一图像中分离出的前景图像合成至所述目标背景图像,得到目标图像。The target image is obtained by synthesizing the foreground image separated from the first image into the target background image.
  8. 根据权利要求7所述的电子设备,其特征在于,当所述指令被所述设备执行时,使得所述获取第二图像的步骤,包括:The electronic device according to claim 7, wherein when the instruction is executed by the device, the step of obtaining the second image comprises:
    获取所述第一图像的预设分类信息;acquiring preset classification information of the first image;
    获取并展示与所述第一图像的预设分类信息匹配的待选背景图像;展示的所述待选背景图像按照所述待选背景图像与所述第一图像之间的拍摄角度差异值从小到大排序;所述待选背景图像与所述第一图像之间的拍摄角度差异值根据所述待选背景图像的拍摄角度信息、以及所述第一图像的拍摄角度信息计算得到;Acquire and display a background image to be selected that matches the preset classification information of the first image; the background image to be displayed is displayed according to the shooting angle difference between the background image to be selected and the first image. Sorting from the largest to the largest; the difference value of the shooting angle between the background image to be selected and the first image is calculated according to the shooting angle information of the background image to be selected and the shooting angle information of the first image;
    接收到所述用户针对于所述待选背景图像的选择操作,将所述选择操作指示的待选背景图像作为第二图像。After receiving the user's selection operation on the background image to be selected, the background image to be selected indicated by the selection operation is used as the second image.
  9. 根据权利要求8所述的电子设备,其特征在于,所述指令被所述设备执行时,使得所述获取与所述第一图像的预设分类信息匹配的待选背景图像的步骤,包括:The electronic device according to claim 8, wherein when the instruction is executed by the device, the step of obtaining the background image to be selected that matches the preset classification information of the first image comprises:
    向服务器发送所述第一图像的拍摄角度信息、以及预设分类信息;sending the shooting angle information and preset classification information of the first image to the server;
    接收所述服务器发送的与所述第一图像的预设分类信息匹配的待选背景图像,所述待选背景图像由所述服务器按照所述待选背景图像与所述第一图像之间的拍摄角度差异值排序,所述待选背景图像与所述第一图像之间的拍摄角度差异值由所述服务器根据所述待选背景图像的拍摄角度信息、以及所述第一图像的拍摄角度信息计算得到。Receive a background image to be selected that matches the preset classification information of the first image sent by the server, and the background image to be selected is sent by the server according to the relationship between the background image to be selected and the first image. The shooting angle difference value is sorted, and the shooting angle difference value between the background image to be selected and the first image is determined by the server according to the shooting angle information of the background image to be selected and the shooting angle of the first image. information is calculated.
  10. 根据权利要求7至9任一项所述的电子设备,其特征在于,当所述指令被所述设备执行时,使得所述将从第一图像中分离出的前景图像与所述目标背景图像进行图像合成,得到目标图像的步骤,包括:The electronic device according to any one of claims 7 to 9, wherein when the instruction is executed by the device, the foreground image separated from the first image and the target background image are caused to The steps of performing image synthesis to obtain the target image include:
    展示所述目标背景图像,接收到所述用户在所述目标背景图像上的位置指定操作,得到所述用户在所述目标背景图像上指定位置的位置信息;Displaying the target background image, receiving a position specifying operation of the user on the target background image, and obtaining the position information of the position specified by the user on the target background image;
    确定所述位置信息对应的第一距离估计值;determining a first distance estimate corresponding to the location information;
    根据所述第一距离估计值对所述前景图像进行缩放,得到目标前景图像;Scaling the foreground image according to the first distance estimation value to obtain a target foreground image;
    将所述目标前景图像合成至所述目标背景图像中所述位置信息指示的位置,得到目标图像。The target foreground image is synthesized to the position indicated by the position information in the target background image to obtain a target image.
  11. 根据权利要求10所述的电子设备,其特征在于,当所述指令被所述设备执行时,使得所述将所述目标前景图像合成至所述目标背景图像上所述位置信息指示的位置的步骤之前,还包括:The electronic device according to claim 10, wherein when the instruction is executed by the device, the compositing of the target foreground image to the position indicated by the position information on the target background image is made. Before the steps, also include:
    对所述目标前景图像和/或所述目标背景图像的颜色参数进行调整。Adjusting the color parameters of the target foreground image and/or the target background image.
  12. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行权利要求1至6任一项所述的方法。A computer-readable storage medium, characterized in that, a computer program is stored in the computer-readable storage medium, and when it is run on a computer, it causes the computer to execute the method of any one of claims 1 to 6.
PCT/CN2021/106666 2020-07-24 2021-07-16 Image synthesis method and electronic device WO2022017261A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010720955.X 2020-07-24
CN202010720955.XA CN113973173B (en) 2020-07-24 2020-07-24 Image synthesis method and electronic equipment

Publications (1)

Publication Number Publication Date
WO2022017261A1 true WO2022017261A1 (en) 2022-01-27

Family

ID=79585773

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/106666 WO2022017261A1 (en) 2020-07-24 2021-07-16 Image synthesis method and electronic device

Country Status (2)

Country Link
CN (1) CN113973173B (en)
WO (1) WO2022017261A1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114780012A (en) * 2022-06-21 2022-07-22 荣耀终端有限公司 Display method and related device for screen locking wallpaper of electronic equipment
CN116051351A (en) * 2022-08-22 2023-05-02 荣耀终端有限公司 Special effect processing method and electronic equipment
CN116049464A (en) * 2022-08-05 2023-05-02 荣耀终端有限公司 Image sorting method and electronic equipment
CN116309918A (en) * 2023-03-31 2023-06-23 深圳市欧度利方科技有限公司 Scene synthesis method and system based on tablet personal computer
CN116664684A (en) * 2022-12-13 2023-08-29 荣耀终端有限公司 Positioning method, electronic device and computer readable storage medium

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114422736B (en) * 2022-03-28 2022-08-16 荣耀终端有限公司 Video processing method, electronic equipment and computer storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100239174A1 (en) * 2009-03-18 2010-09-23 Samsung Electronics Co., Ltd. Method for creating panorama
CN101859433A (en) * 2009-04-10 2010-10-13 日电(中国)有限公司 Image mosaic device and method
CN106162137A (en) * 2016-06-30 2016-11-23 北京大学 Virtual visual point synthesizing method and device
CN110047061A (en) * 2019-04-26 2019-07-23 杭州智趣智能信息技术有限公司 A kind of image interfusion method, device and the medium of the more backgrounds of multi-angle

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101582254B (en) * 2008-05-13 2011-06-15 华为终端有限公司 Method and device for presenting image
JP5307051B2 (en) * 2010-02-10 2013-10-02 株式会社日立製作所 Stereoscopic image adjusting apparatus and adjusting method
CN102158725B (en) * 2011-05-06 2013-04-10 深圳超多维光电子有限公司 Stereoscopic image generation method and system
US9460123B1 (en) * 2012-12-12 2016-10-04 Amazon Technologies, Inc. Systems and methods for generating an arrangement of images based on image analysis
MX2018006330A (en) * 2015-11-24 2018-08-29 Koninklijke Philips Nv Handling multiple hdr image sources.
JP7238115B2 (en) * 2018-10-15 2023-03-13 華為技術有限公司 Photography scenarios and methods for displaying images on electronic devices
CN110035141B (en) * 2019-02-22 2021-07-09 华为技术有限公司 Shooting method and equipment
CN110445978B (en) * 2019-06-24 2020-12-15 华为技术有限公司 Shooting method and equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100239174A1 (en) * 2009-03-18 2010-09-23 Samsung Electronics Co., Ltd. Method for creating panorama
CN101859433A (en) * 2009-04-10 2010-10-13 日电(中国)有限公司 Image mosaic device and method
CN106162137A (en) * 2016-06-30 2016-11-23 北京大学 Virtual visual point synthesizing method and device
CN110047061A (en) * 2019-04-26 2019-07-23 杭州智趣智能信息技术有限公司 A kind of image interfusion method, device and the medium of the more backgrounds of multi-angle

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114780012A (en) * 2022-06-21 2022-07-22 荣耀终端有限公司 Display method and related device for screen locking wallpaper of electronic equipment
CN114780012B (en) * 2022-06-21 2023-06-20 荣耀终端有限公司 Display method and related device of screen locking wallpaper of electronic equipment
CN116049464A (en) * 2022-08-05 2023-05-02 荣耀终端有限公司 Image sorting method and electronic equipment
CN116049464B (en) * 2022-08-05 2023-10-20 荣耀终端有限公司 Image sorting method and electronic equipment
CN116051351A (en) * 2022-08-22 2023-05-02 荣耀终端有限公司 Special effect processing method and electronic equipment
CN116051351B (en) * 2022-08-22 2023-10-13 荣耀终端有限公司 Special effect processing method and electronic equipment
CN116664684A (en) * 2022-12-13 2023-08-29 荣耀终端有限公司 Positioning method, electronic device and computer readable storage medium
CN116664684B (en) * 2022-12-13 2024-04-05 荣耀终端有限公司 Positioning method, electronic device and computer readable storage medium
CN116309918A (en) * 2023-03-31 2023-06-23 深圳市欧度利方科技有限公司 Scene synthesis method and system based on tablet personal computer
CN116309918B (en) * 2023-03-31 2023-12-22 深圳市欧度利方科技有限公司 Scene synthesis method and system based on tablet personal computer

Also Published As

Publication number Publication date
CN113973173A (en) 2022-01-25
CN113973173B (en) 2023-04-21

Similar Documents

Publication Publication Date Title
CN109814766B (en) Application display method and electronic equipment
WO2021136050A1 (en) Image photographing method and related apparatus
WO2022017261A1 (en) Image synthesis method and electronic device
WO2020259452A1 (en) Full-screen display method for mobile terminal, and apparatus
WO2020077511A1 (en) Method for displaying image in photographic scene and electronic device
WO2022007862A1 (en) Image processing method, system, electronic device and computer readable storage medium
WO2020102978A1 (en) Image processing method and electronic device
CN112532892B (en) Image processing method and electronic device
WO2021258814A1 (en) Video synthesis method and apparatus, electronic device, and storage medium
WO2022100685A1 (en) Drawing command processing method and related device therefor
CN113810603B (en) Point light source image detection method and electronic equipment
CN113542580B (en) Method and device for removing light spots of glasses and electronic equipment
WO2022001258A1 (en) Multi-screen display method and apparatus, terminal device, and storage medium
WO2023284715A1 (en) Object reconstruction method and related device
CN113170037A (en) Method for shooting long exposure image and electronic equipment
CN112087649B (en) Equipment searching method and electronic equipment
CN112150499A (en) Image processing method and related device
CN112700377A (en) Image floodlight processing method and device and storage medium
CN110138999B (en) Certificate scanning method and device for mobile terminal
WO2022156473A1 (en) Video playing method and electronic device
WO2022007707A1 (en) Home device control method, terminal device, and computer-readable storage medium
CN114979457B (en) Image processing method and related device
WO2021057626A1 (en) Image processing method, apparatus, device, and computer storage medium
CN114756184A (en) Collaborative display method, terminal device and computer-readable storage medium
CN113542574A (en) Shooting preview method under zooming, terminal, storage medium and electronic equipment

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21846182

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21846182

Country of ref document: EP

Kind code of ref document: A1