Disclosure of Invention
The embodiment of the disclosure provides an image display method and device, electronic equipment and a storage medium.
In a first aspect, an embodiment of the present disclosure provides an image display method, including:
acquiring an original image frame from an acquired image stream when acquiring an image;
drawing an auxiliary foreground image on the original image frame to obtain an intermediate image frame with the auxiliary foreground image;
if the original image frame contains target information, calculating the proportion of the target information occupying a display screen, wherein the target information is an image to be subjected to three-dimensional effect display;
when the calculation result of the ratio is greater than or equal to a first preset threshold value, dividing an area occupied by the target information from the intermediate image frame, and taking the area occupied by the target information as a target area;
filling the target area with the target information in the original image frame to obtain a stereoscopic image to be displayed;
and displaying the stereoscopic effect image.
In the above scheme, after calculating the ratio of the target information occupying the display screen, the method further includes:
when the calculation result of the proportion is greater than or equal to a second preset threshold and smaller than the first preset threshold, performing normalization processing on the target area to obtain a frame body corresponding to the target area;
and according to the position relation between the frame body corresponding to the target area and the auxiliary foreground image, distorting the auxiliary foreground image to obtain the distorted auxiliary foreground image.
In the foregoing solution, the distorting the auxiliary foreground image according to the position relationship between the frame corresponding to the target region and the auxiliary foreground image to obtain the distorted auxiliary foreground image includes:
for each pixel point in the auxiliary foreground image, calculating the product of the length-to-width ratio of the frame body corresponding to the target area and the ordinate of each pixel point, and taking the sum of the square of the product and the square of the abscissa of each pixel point as a first calculation result;
calculating a double value of the square of the length for each pixel point in the auxiliary foreground image as a second calculation result;
and when the first calculation result is smaller than the second calculation result, transforming the coordinates of each pixel point in a texture coordinate space to obtain the distorted auxiliary foreground image.
In the foregoing solution, the transforming the coordinate of each pixel point in a texture coordinate space to obtain the distorted auxiliary foreground image includes:
acquiring a central coordinate of a frame corresponding to the target area, wherein the central coordinate is a coordinate of a central point;
calculating a distortion coefficient of the auxiliary foreground image according to the proportion of the target information occupying a display screen, wherein the distortion coefficient represents the distortion degree of the auxiliary foreground image;
calculating a new coordinate of each pixel point after distortion according to the central coordinate, the first calculation result, the second calculation result and the distortion coefficient;
and obtaining the distorted auxiliary foreground image according to the distorted new coordinates of each pixel point.
In the above solution, the dividing the area occupied by the target information from the intermediate image frame, and taking the area occupied by the target information as a target area, includes:
dividing the intermediate image frame by using an image segmentation detection algorithm to obtain a target information occupied area, wherein an image in the target information occupied area comprises the target information and the auxiliary foreground image in the target information occupied area;
and shielding the target information occupied area, reserving images of other areas in the intermediate image frame, and taking the shielded target information occupied area as the target area.
In the foregoing solution, when the auxiliary foreground image is an annular auxiliary foreground image, the filling the target area with the target information in the original image frame to obtain a to-be-displayed stereoscopic image includes:
and after the target area is filled into the image of the corresponding area in the original image frame, drawing the lower half part of the auxiliary foreground image in the ring shape again to obtain the image with the stereoscopic effect to be displayed.
In the above solution, after calculating a ratio of the target information occupying a display screen when the target information appears in the intermediate image frame, the method further includes:
and when the calculation result of the proportion is smaller than a first preset threshold value, the stereoscopic effect image is not displayed.
In the above solution, the acquiring an original image frame from an acquired image stream includes:
and when the preset time length is reached, capturing the acquired image stream to obtain the original image frame.
In the above solution, before the obtaining the original image frame from the acquired image stream, the method further includes:
detecting whether a stereoscopic effect switch is turned on, wherein the stereoscopic effect switch is used for controlling whether the stereoscopic effect of the image is turned on;
when the stereoscopic effect switch is turned on, the image display method is performed.
In a second aspect, embodiments of the present disclosure provide an image display apparatus, including an acquisition unit, a drawing unit, a calculation unit, a division unit, and a filling unit, wherein,
the acquisition unit is used for acquiring an original image frame from an acquired image stream when an image is acquired;
the drawing unit is used for drawing an auxiliary foreground image on the original image frame to obtain an intermediate image frame with the auxiliary foreground image;
the calculating unit is used for calculating the proportion of the target information occupying a display screen if the original image frame contains the target information, wherein the target information is an image to be subjected to three-dimensional effect display;
the dividing unit is used for dividing an area occupied by the target information from the intermediate image frame when the calculation result of the proportion is larger than or equal to a first preset threshold value, and taking the area occupied by the target information as a target area;
the filling unit is used for filling the target area with the target information in the original image frame to obtain a stereoscopic image to be displayed;
the drawing unit is further used for displaying the stereoscopic effect image.
In the foregoing solution, the calculating unit is specifically configured to, after the calculating the ratio of the target information occupying the display screen, perform normalization processing on the target area when a calculation result of the ratio is greater than or equal to a second preset threshold and smaller than the first preset threshold, so as to obtain a frame corresponding to the target area; and according to the position relation between the frame body corresponding to the target area and the auxiliary foreground image, distorting the auxiliary foreground image to obtain the distorted auxiliary foreground image.
In the above aspect, the image display apparatus further includes a warping unit, wherein,
the distortion unit is used for calculating the product of the length-to-width ratio of the frame body corresponding to the target area and the ordinate of each pixel point for each pixel point in the auxiliary foreground image, and taking the sum of the square of the product and the square of the abscissa of each pixel point as a first calculation result; calculating a double value of the square of the length as a second calculation result; and when the first calculation result is smaller than the second calculation result, transforming the coordinates of each pixel point in a texture coordinate space to obtain the distorted auxiliary foreground image.
In the above scheme, the warping unit is specifically configured to obtain a central coordinate of a frame corresponding to the target area, where the central coordinate is a coordinate of a central point; calculating a distortion coefficient of the auxiliary foreground image according to the proportion of the target information occupying a display screen, wherein the distortion coefficient represents the distortion degree of the auxiliary foreground image; calculating a new coordinate of each pixel point after distortion according to the central coordinate, the first calculation result, the second calculation result and the distortion coefficient; and obtaining the distorted auxiliary foreground image according to the distorted new coordinates of each pixel point.
In the above solution, the dividing unit is specifically configured to divide the intermediate image frame by using an image segmentation detection algorithm to obtain the target information occupied area, where an image in the target information occupied area includes the target information and the auxiliary foreground image in the target information occupied area; and shielding the target information occupied area, reserving images of other areas in the intermediate image frame, and taking the shielded target information occupied area as the target area.
In the foregoing solution, when the auxiliary foreground image is an annular auxiliary foreground image, the filling unit is specifically configured to, after filling the target region with an image of a corresponding region in the original image frame, draw the lower half portion of the annular auxiliary foreground image again to obtain a to-be-displayed stereoscopic image.
In the foregoing solution, the calculating unit is further configured to, after calculating a ratio that the target information occupies a display screen if the original image frame includes the target information, not display the stereoscopic image when a calculation result of the ratio is smaller than a first preset threshold.
In the above scheme, the acquiring unit is specifically configured to capture a frame of the acquired image stream when a predetermined duration is reached, so as to obtain the original image frame.
In the above-mentioned aspect, the image display apparatus further includes a detection unit and an execution unit, wherein,
the detection unit is used for detecting whether a stereoscopic effect switch is turned on before an original image frame is acquired from the acquired image stream, wherein the stereoscopic effect switch is used for controlling whether the stereoscopic effect of the image is turned on;
the execution unit is used for executing the image display method when the stereoscopic effect switch is turned on.
In a third aspect, an embodiment of the present disclosure provides an image display electronic device, including:
a memory for storing executable instructions;
and the processor is used for realizing the image display method provided by the embodiment of the disclosure when the executable instruction is executed.
In a fourth aspect, the present disclosure provides a storage medium storing executable instructions, where the executable instructions are executed to implement an image display method provided by the embodiments of the present disclosure.
The embodiment of the disclosure has the following beneficial effects:
the spatial position is expressed by changing the shielding relation between the auxiliary foreground image and the target information, 3D spatial sense is simulated, the visual effect that the target information stretches out from the auxiliary foreground image is embodied, and therefore the special effect of naked eye stereoscopic effect is established when the monocular camera shoots.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
Referring now to fig. 1, fig. 1 is a schematic diagram of an electronic device 100 implementing an embodiment of the present disclosure. The electronic device may be various terminals including a mobile terminal such as a mobile phone, a notebook computer, a Digital broadcast receiver, a Personal Digital Assistant (PDA), a tablet computer (PAD), a Portable Multimedia Player (PMP), a vehicle mounted terminal (e.g., a car navigation terminal), etc., and a fixed terminal such as a Digital Television (TV), a desktop computer, etc. The electronic device shown in fig. 1 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 1, the electronic device 100 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 110, which may perform various appropriate actions and processes according to a program stored in a Read-Only Memory (ROM) 120 or a program loaded from a storage means 180 into a Random Access Memory (RAM) 130. In the RAM 130, various programs and data necessary for the operation of the electronic apparatus 100 are also stored. The processing device 110, the ROM 120, and the RAM 130 are connected to each other through a bus 140. An Input/Output (I/O) interface 150 is also connected to bus 140.
Generally, the following devices may be connected to the I/O interface 150: input devices 160 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 170 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; a storage device 180 including, for example, a magnetic tape, a hard disk, or the like; and a communication device 190. The communication device 190 may allow the electronic device 100 to communicate wirelessly or by wire with other devices to exchange data. While fig. 1 illustrates an electronic device 100 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, the processes described by the provided flowcharts may be implemented as computer software programs according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer-readable storage medium (i.e., storage medium), the computer program containing program code for performing the method illustrated by the flowchart. In such embodiments, the computer program may be downloaded and installed from a network through the communication device 190, or installed from the storage device 180, or installed from the ROM 120. The computer program, when executed by the processing device 110, performs the functions in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable storage medium in the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may include, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a RAM, a ROM, an Erasable Programmable Read-Only Memory (EPROM), a flash Memory, an optical fiber, a portable compact disc Read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In the disclosed embodiments, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the disclosed embodiments, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any computer readable storage medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable storage medium may be transmitted using any appropriate medium, including over electrical wiring, fiber optics, Radio Frequency (RF), etc., or any suitable combination of the foregoing.
The computer-readable storage medium may be included in the electronic device 100; or may be separate and not incorporated into the electronic device 100.
The computer-readable storage medium carries one or more programs which, when executed by the electronic device 100, cause the electronic device to perform the image display method provided by the embodiments of the present disclosure.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of Network, including a Local Area Network (LAN) and a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams provided by the embodiments of the present disclosure illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a unit does not in some cases constitute a limitation of the unit itself, for example, the first obtaining unit may also be described as a "unit obtaining at least two internet protocol addresses".
The functions described in the embodiments of the present disclosure may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: Field-Programmable Gate arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Parts (ASSPs)), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of embodiments of the present disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The following provides a unit and/or a module in an image display device in connection with an embodiment of the present disclosure. It is understood that the units or modules in the image display apparatus can be implemented in the electronic device shown in fig. 1 by software (for example, the computer program stored in the computer software program) or the hardware logic components (for example, FPGA, ASIC, ASSP, SOC, and CPLD) described above.
Referring to fig. 2, fig. 2 is an alternative structural schematic diagram of an image display device 200 implementing an embodiment of the present disclosure, showing the following modules: an acquisition unit 210, a rendering unit 220, a calculation unit 230, a dividing unit 240 and a filling unit 250, wherein,
the acquiring unit 210 is configured to, when acquiring an image, acquire an original image frame from an acquired image stream;
the drawing unit 220 is configured to draw an auxiliary foreground image on the original image frame to obtain an intermediate image frame with the auxiliary foreground image;
the calculating unit 230 is configured to calculate, if the original image frame includes target information, a ratio of the target information occupying a display screen, where the target information is an image to be displayed with a stereoscopic effect;
the dividing unit 240 is configured to divide an area occupied by the target information from the intermediate image frame, and take the area occupied by the target information as a target area, when the calculation result of the ratio is greater than or equal to a first preset threshold;
the filling unit 250 is configured to fill the target area with the target information in the original image frame to obtain a stereoscopic image to be displayed;
the rendering unit 220 is further configured to display the stereoscopic image.
In the foregoing solution, the calculating unit 230 is specifically configured to, after the calculating the ratio of the target information occupying the display screen, perform normalization processing on the target area when a calculation result of the ratio is greater than or equal to a second preset threshold and smaller than the first preset threshold, so as to obtain a frame corresponding to the target area; and according to the position relation between the frame body corresponding to the target area and the auxiliary foreground image, distorting the auxiliary foreground image to obtain the distorted auxiliary foreground image.
In the above-described aspect, the image display apparatus further includes a warping unit 260, wherein,
the warping unit 260 is configured to calculate, for each pixel point in the auxiliary foreground image, a product of a length-to-width ratio of a frame corresponding to the target area and a vertical coordinate of each pixel point, and use a sum of a square of the product and a square of a horizontal coordinate of each pixel point as a first calculation result; calculating a double value of the square of the length as a second calculation result; and when the first calculation result is smaller than the second calculation result, transforming the coordinates of each pixel point in a texture coordinate space to obtain the distorted auxiliary foreground image.
In the above solution, the warping unit 260 is specifically configured to obtain a central coordinate of a frame corresponding to the target area, where the central coordinate is a coordinate of a central point; calculating a distortion coefficient of the auxiliary foreground image according to the proportion of the target information occupying a display screen, wherein the distortion coefficient represents the distortion degree of the auxiliary foreground image; calculating a new coordinate of each pixel point after distortion according to the central coordinate, the first calculation result, the second calculation result and the distortion coefficient; and obtaining the distorted auxiliary foreground image according to the distorted new coordinates of each pixel point.
In the foregoing solution, the dividing unit 240 is specifically configured to divide the intermediate image frame by using an image segmentation detection algorithm to obtain the target information occupied area, where an image in the target information occupied area includes the target information and the auxiliary foreground image in the target information occupied area; and shielding the target information occupied area, reserving images of other areas in the intermediate image frame, and taking the shielded target information occupied area as the target area.
In the foregoing solution, when the auxiliary foreground image is an annular auxiliary foreground image, the filling unit 250 is specifically configured to draw the lower half portion of the annular auxiliary foreground image again after the target area is filled with the image of the corresponding area in the original image frame, so as to obtain the to-be-displayed stereoscopic image.
In the foregoing solution, the calculating unit 230 is further configured to, after calculating a ratio that the target information occupies a display screen if the original image frame includes the target information, not display the stereoscopic image when a calculation result of the ratio is smaller than a first preset threshold.
In the above scheme, the acquisition unit 210 is specifically configured to capture a frame of the acquired image stream when a predetermined time length is reached, so as to obtain the original image frame.
In the above solution, the image display apparatus further comprises a detection unit 270 and an execution unit 280, wherein,
the detecting unit 270 is configured to detect whether a stereoscopic effect switch is turned on before the original image frame is acquired from the acquired image stream, where the stereoscopic effect switch is a switch that controls whether a stereoscopic effect of an image is turned on;
the execution unit 280 is configured to execute the image display method when the stereoscopic effect switch is turned on.
It should be noted that the above-mentioned classification of units does not constitute a limitation of the electronic device itself, for example, some units may be split into two or more sub-units, or some units may be combined into a new unit.
It is further noted that the names of the above units do not in some cases constitute a limitation on the units themselves, for example, the above acquisition unit 210 may also be described as a unit for "acquiring an original image frame from an acquired image stream".
For the same reason, units and/or modules in the electronic device, which are not described in detail, do not represent defaults of the corresponding units and/or modules, and all operations performed by the electronic device may be implemented by the corresponding units and/or modules in the electronic device.
With continuing reference to fig. 3, fig. 3 is an alternative flowchart illustrating an image display method according to an embodiment of the disclosure, for example, when the processing device 110 loads a program in the Read Only Memory (ROM) 120 or a program in the storage device 180 into the Random Access Memory (RAM), the image display method shown in fig. 3 may be implemented when the program is executed, and the steps shown in fig. 3 are described below.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict.
S101, when an image is collected, obtaining an original image frame from a collected image stream.
The image display mode provided by the embodiment of the disclosure is suitable for recognizing target objects such as human faces and human hands in video or image shooting and simulating a special effect production scene with a three-dimensional effect.
In the embodiment of the present disclosure, the process of acquiring the image may be that when the electronic device takes a picture or a video, the image display device captures a frame of the acquired image stream to obtain an original image frame.
In the embodiment of the present disclosure, the original image frames obtained by the image display device are original image frames in the acquired image stream without any image processing.
In some embodiments, the raw image frames obtained by the image display device may be as shown in fig. 4.
In the embodiment of the disclosure, the image display device may capture a frame of the acquired image stream each time a predetermined time period is reached, so as to obtain an original image frame.
In some embodiments, the image display device may set a cycle timer of a predetermined duration to acquire the original image frames from the acquired image stream each time the predetermined duration is reached.
And S102, drawing the auxiliary foreground image on the original image frame to obtain an intermediate image frame with the auxiliary foreground image.
In the embodiment of the present disclosure, after the original image frame is acquired, the image display device draws an auxiliary foreground image on the original image frame, so as to obtain an intermediate image frame with the auxiliary foreground image.
In the embodiment of the disclosure, the auxiliary foreground image may be a foreground sticker for embodying a naked eye stereoscopic effect. The foreground sticker can be a static or dynamic image and is displayed on the upper layer of the original image frame in a sticker form to accompany target information serving as a main body; the foreground sticker is used as an additional image and is combined with the collected image to show different decoration and depth of field effects.
In some embodiments, the image display device may display the auxiliary foreground sticker in a shape of a straight line, as shown in fig. 5, two parallel vertical lines 500-1 and 500-2 displayed on the original image frame are the auxiliary foreground sticker in a shape of a straight line, and the image display device takes 500-1 and 500-2 as the auxiliary foreground image.
It should be noted that, in the embodiment of the present disclosure, the finally displayed image on the display screen of the electronic device is displayed after synthesizing the contents of the multiple layers, where each layer may include different contents, and the contents included in the multiple layers are synthesized according to a predetermined display area and a predetermined hierarchical order to form the finally displayed image on the screen.
In the embodiment of the disclosure, the image display device draws the auxiliary foreground image on the upper layer of the original image frame, the image display device can obtain the auxiliary foreground image on the upper layer, the original image frame is on two image layers of the lower layer, and the image display device synthesizes the two image layers to obtain the intermediate image frame with the auxiliary foreground image.
S103, if the original image frame contains target information, calculating the proportion of the target information occupying a display screen, wherein the target information is an image to be subjected to three-dimensional effect display.
In the embodiment of the disclosure, after the image display device obtains the original image frame and the intermediate image frame, the image display device first performs target information detection on the original image frame, and if it is detected that the original image frame includes the target information, calculates a ratio of the target information occupying a display screen.
In the embodiment of the present disclosure, the target information is an image to be subjected to a stereoscopic effect display, the original image frame includes a lot of image information, the image display device performs a stereoscopic effect display on the target image, and other image information is not subjected to a display process of the stereoscopic effect.
In some embodiments, the original image frame acquired by the image display device includes images of a human face and a scenery, when the image display needs to perform stereoscopic effect display on the human face, the target information is the human face, the image display device performs stereoscopic effect display on the human face, and the images in the original image frame are reserved for the human face and the scenery part without performing stereoscopic effect display. Similarly, the target information may also be an image of a human hand or other objects, which is specifically selected according to the actual situation, and the embodiment of the present disclosure is not limited.
In some embodiments, when the target information is a human face, the image display device may determine whether the original image frame includes the human face through a human face detection algorithm; when the target information is a human hand, the image display device can respectively judge whether the original image frame comprises a left hand or a right hand through a human hand detection algorithm.
In the embodiment of the disclosure, after the image display device detects that the original image frame contains the target information, the image display device calculates the proportion of the target information occupying the display screen of the electronic device.
In some embodiments, the image display device may obtain a rectangular region corresponding to an image boundary of the target information after normalization processing by using a target information detection algorithm used in target information detection.
In some embodiments, when the target information is a human face, the image display device identifies whether the original image frame includes the human face through a human face detection algorithm, and the human face detection algorithm may also calculate a face frame after normalization processing of a boundary of a human face image corresponding to the identified human face image, as shown in fig. 6, a dotted-line rectangular frame 600 in fig. 6 is a rectangular region corresponding to the image boundary of the target information human face after normalization processing.
In some embodiments, after the image display device obtains the rectangular area corresponding to the target information, the image display device calculates a ratio of the rectangular area corresponding to the target information occupying the display screen. In some embodiments, the image display apparatus may perform a ratio calculation according to a maximum value of the length or the width of the rectangular region corresponding to the target information and the length or the width corresponding to the display screen, so as to obtain a calculation result of a proportion of the target rectangular region occupying the display screen.
In the embodiment of the present disclosure, the image display device may also calculate the ratio of the target information occupying the display screen by using other methods, and specifically select the target information according to the actual situation, which is not limited in the embodiment of the present disclosure.
And S104, when the calculation result of the proportion is larger than or equal to a first preset threshold value, dividing an area occupied by the target information from the middle image frame, and taking the area occupied by the target information as the target area.
In the embodiment of the present disclosure, when the ratio calculated by the image display device is greater than or equal to the first preset threshold, the image display device divides an area occupied by the target information from the intermediate image frame, and takes the area occupied by the target information as the target area.
In the embodiment of the disclosure, the image display device may infer whether the target information is blocked by the auxiliary foreground image through the first preset threshold, and when the calculation result of the proportion of the target information occupying the display screen is greater than or equal to the first preset threshold, it indicates that the size of the target information in the screen is already large and is likely to be blocked by the auxiliary foreground image, so that the image display device may perform subsequent image processing to present the stereoscopic effect.
In some embodiments, the first preset threshold may be 0.5, or may be other values, which are specifically selected according to actual situations, and the embodiments of the present disclosure are not limited.
In the embodiment of the present disclosure, the image display apparatus divides the area occupied by the target information from the intermediate image frame, and taking the area occupied by the target information as the target area may include S1041 to S1042 as follows:
s1041, dividing the intermediate image frame by using an image segmentation detection algorithm to obtain a target information occupying area, wherein an image in the target information occupying area comprises target information and an auxiliary foreground image in the target information occupying area.
In the embodiment of the disclosure, the image display device divides the intermediate image frame by using an image segmentation detection algorithm to obtain the target information occupying area.
In the embodiment of the present disclosure, the target information occupying region is an image portion within a range included in a boundary of the target information in the intermediate image frame.
In the embodiment of the disclosure, when the target information is a human face, the image display apparatus may use a head segmentation headseg algorithm in the neural network model to segment a region occupied by the head from the intermediate image frame, so as to obtain a region occupied by the target information. When the target information is a human hand, the image display device may also use an image segmentation detection algorithm of the human hand to respectively divide the areas occupied by the left hand and the right hand.
In some embodiments, the original image frame is shown in fig. 4, the intermediate image frame is shown in fig. 5, the target information is face information in the original image frame, the image display device divides an area occupied by the face information from the intermediate image frame, and the obtained face information occupied area can be shown in fig. 7, where a dotted line portion 700 in fig. 7 is the face information occupied area divided from the intermediate image frame by the image display device. As can be seen from fig. 7, the image display device divides the image in fig. 6 into a face occupation region with the face as a boundary, and the face occupation region 700 divided by the image display device includes the face and a linear auxiliary foreground image partially within the face.
S1042, shielding the occupied area of the target information, reserving the images of the rest areas in the middle image frame, and taking the shielded occupied area of the target information as the target area.
In the embodiment of the present disclosure, after the image display device divides the target information occupied area from the intermediate image frame, the image layer mask corresponding to the target information occupied area is obtained, and the image layer mask blocks the target information occupied area, and performs the transparency processing on other areas.
In the embodiment of the present disclosure, the image display device takes the blocked occupied area of the target information as the target area.
In some embodiments, the original image frame is shown in fig. 4, the intermediate image frame is shown in fig. 5, the target information is face information in the original image frame, the target information occupying area is shown in fig. 7, the target area obtained after the image display device blocks the target information occupying area may be shown in fig. 8, and the hatched area 800 in fig. 8 is the blocked target information occupying area, i.e., the target area. As can be seen from fig. 8, the image display apparatus blocks 700 in fig. 7, and retains the image of the rest of fig. 7 except 700.
It can be understood that, after the image display device blocks the target information occupying area, the image display device blocks the target information together with the auxiliary foreground image in the target information occupying area, and the images of other areas except the target area in the intermediate image frame can be normally displayed.
And S105, filling a target area by adopting target information in the original image frame to obtain a stereoscopic effect image to be displayed.
In the embodiment of the disclosure, after the image display device obtains the target area, the target area is filled with the target information in the original image frame, so as to obtain the stereoscopic image to be displayed.
In the embodiment of the disclosure, the original image frame is displayed on the lower layer, the intermediate image frame is displayed on the upper layer of the original image frame, and the coordinates of the same pixel point in the original image frame and the intermediate image frame are all aligned, so that after the image display device obtains the target area from the intermediate image frame, the image display device can correspondingly obtain the area where the original image frame is the same as the target area, and the image in the area is the target information in the original image frame.
In the embodiment of the present disclosure, the image display device may invoke a layer rendering function of the electronic device display system through a general OpenGL ES (OpenGL for Embedded Systems) interface, and extract target information corresponding to a target area in an original image frame to a top layer of a rendering chain, that is, extract a target information image originally displayed in a lower layer to an uppermost layer for drawing, so that the shielded target area is filled with an image of the target information, and the image display device synthesizes images of all layers to obtain a stereoscopic image to be displayed.
In the embodiment of the present disclosure, an OpenGL ES (OpenGL for Embedded Systems) interface is a cross-language and cross-platform application programming interface for rendering 2D and 3D vector graphics on an Embedded platform.
In some embodiments, the process of the image display apparatus obtaining the portion 900 of the face image in the original image frame through the target area 800 in the intermediate image frame may be as shown in fig. 9, since the intermediate image frame is obtained by drawing the auxiliary foreground image on the basis of the original image frame, and the two image layers of the intermediate image frame and the original image frame are the same in size and are displayed in a stacked manner, the image display apparatus may obtain the portion 900 of the face image in the original image frame by aligning coordinates of each pixel point in the target area 800 of the intermediate image frame with coordinates of a pixel point in the original image frame. After the image display apparatus fills the target area 800 in fig. 8 with the face image 900 area in the original image frame, the obtained stereoscopic image to be displayed may be as shown in fig. 10. As can be seen from fig. 10, the face image 900 in the original image frame forms an occlusion on the auxiliary foreground images 500-1 and 500-2, and other parts of the body of the face are still occluded by the auxiliary foreground images 500-1 and 500-2, thereby representing the stereoscopic effect of the face 900 protruding from the auxiliary foreground images 500-1 and 500-2.
The image display device can simulate the stereoscopic sense of space through the shielding relation formed by the target information and the auxiliary foreground image in the finally obtained stereoscopic image to be displayed, and realizes the special effect of shooting the image with the naked eye stereoscopic effect by using the monocular camera.
In some embodiments, as shown in fig. 11, when the target information is the human hand 110, the image display apparatus may also obtain a stereoscopic effect image in which the human hand 110 stretches out the auxiliary foreground images 111_1 and 111_2 by the above-described image display method.
In some embodiments of the present disclosure, the image display device may further display an auxiliary foreground image of the circular line.
In this embodiment of the disclosure, when the image display device displays the auxiliary foreground image in the shape of a circular strip, in order to reflect the effect that the target information passes through the ring, that is, the target information only passes through the upper half ring and does not pass through the lower half ring, S105 may also be:
and S105, after the target area is filled into the image of the corresponding area in the original image frame, drawing the lower half part of the auxiliary foreground image in the shape of a circular ring again to obtain the image with the stereoscopic effect to be displayed.
In the embodiment of the disclosure, when the image display device displays the auxiliary foreground image of the circular line, after the image display device fills the target area into the image of the corresponding area in the original image frame, the auxiliary foreground image of the circular ring with only the lower half portion is overlaid to draw the uppermost layer of all the image layers, so as to obtain the stereoscopic image to be displayed, and the stereoscopic image to be displayed can achieve the stereoscopic effect that the head portion passes through the upper half portion circular ring.
In some embodiments, as shown in fig. 12, when the target information in fig. 12 is a human face 1121 and a human hand 1122, the auxiliary foreground image is a circular ring 1120, and the stereoscopic image to be displayed corresponding to the auxiliary foreground image of the circular ring line obtained by the image display device may be as shown in fig. 12. In fig. 12, after the image display apparatus fills the target area corresponding to the human face and the human hand, the lower half portion 1120_1 of the circular ring-shaped auxiliary foreground image is drawn again, and in the obtained stereoscopic image to be displayed, the human face 1121 blocks the upper half portion circular ring, and the human hand 1122 is blocked by the lower half portion circular ring 1120_1 drawn again, so that the stereoscopic effect that the human face 1121 protrudes from the auxiliary foreground image circular ring 1120 is embodied.
It can be understood that, when the image display device displays the auxiliary foreground image of the circular line, because the lower half of the circular ring is drawn more than once, the stereoscopic effect that the target information in the upper half of the picture passes through the circular ring can be embodied in the finally obtained stereoscopic effect image to be displayed.
And S106, displaying the stereoscopic effect image.
In the embodiment of the disclosure, after the image display device obtains the stereoscopic image to be displayed, the stereoscopic image to be displayed is sent to the display screen of the electronic device for displaying, and the stereoscopic effect of the image is finally presented.
It should be noted that, in the embodiment of the present disclosure, S101 to S106 are methods for processing one frame of original image, and when the image display device processes an input video stream, the image display device may perform the processing of the methods of S101 to S106 on each obtained original image frame in the video stream, so as to finally obtain a dynamic effect of a change in a shielding relationship between target information and an auxiliary foreground image in the entire video stream, thereby implementing a naked eye stereoscopic effect of a video.
In the embodiment of the present disclosure, after S103, S107 may be further included, as follows:
and S107, when the calculation result of the proportion is smaller than a first preset threshold value, not displaying the stereoscopic effect image.
In the embodiment of the present disclosure, when the calculation result of the ratio of the target information occupying the screen is smaller than the first preset threshold, it indicates that the image size of the target information in the screen is smaller and the distance from the auxiliary foreground image is further, so that the display of the stereoscopic effect is not required, and the method in S104 and the following steps are not performed.
In the embodiment of the present disclosure, before S101, S108-S109 may be further included, as follows:
and S108, detecting whether the stereoscopic effect switch is turned on or not, wherein the stereoscopic effect switch is a switch for controlling whether the stereoscopic effect of the image is turned on or not.
And S109, when the stereoscopic effect switch is turned on, executing the image display method.
In the embodiment of the present disclosure, the image display method may be controlled by a general stereoscopic effect switch, and the image display method in the embodiment of the present disclosure is performed when the stereoscopic effect switch is turned on, and is not performed when the stereoscopic effect switch is turned off.
With continuing reference to fig. 13, fig. 13 is an alternative flowchart illustrating an image display method according to an embodiment of the present disclosure, and after S103, a method is further provided, which includes S201 to S202, as follows:
s201, when the calculation result of the proportion is larger than or equal to a second preset threshold and smaller than a first preset threshold, carrying out normalization processing on the target area to obtain a frame body corresponding to the target area.
In the embodiment of the disclosure, when the calculation result of the ratio is greater than or equal to the second preset threshold and smaller than the first preset threshold, the image display device performs normalization processing on the target area, and normalizes the irregular curve boundary of the target area to obtain a regular frame corresponding to the target area.
In the embodiment of the present disclosure, the second preset threshold is a value greater than 0 and smaller than the first preset threshold, and in some embodiments, when the first preset threshold is set to 0.5, the second preset threshold may be set to 0.3, which is specifically selected according to an actual situation, which is not limited in the embodiment of the present disclosure.
In some embodiments, the image display apparatus may use a rectangular area corresponding to the target information obtained by the target information detection algorithm in S103 as a frame corresponding to the target area.
In the embodiment of the present disclosure, the frame body corresponding to the target area may also be a frame body with other shapes, which is specifically selected according to the actual situation, and the embodiment of the present disclosure is not limited.
S202, according to the position relation between the frame body corresponding to the target area and the auxiliary foreground image, the auxiliary foreground image is distorted, and the distorted auxiliary foreground image is obtained.
In the embodiment of the disclosure, after the image display device obtains the frame corresponding to the target area, the image display device may distort lines of the auxiliary foreground image in different directions and in different degrees according to the position relationship between the frame corresponding to the target area and the auxiliary foreground image to obtain the distorted auxiliary foreground image, so as to reflect the interaction effect of the target information and the auxiliary foreground image.
In the embodiment of the disclosure, in order to embody the interactive special effect between the target information and the auxiliary foreground image, the image display device may distort the auxiliary foreground image in the direction opposite to the position of the target information when the target information is close to the auxiliary foreground image and coincides with the auxiliary foreground image, so as to embody the special effect that the auxiliary foreground image is deformed and distorted under the extrusion of the target information.
In the embodiment of the present disclosure, in order to obtain the distorted auxiliary foreground image, the image display device needs to calculate, according to the position relationship between the frame corresponding to the target region and the auxiliary foreground image, a new coordinate value of each pixel point in the auxiliary foreground image under the influence of the frame corresponding to the target region in the texture coordinate system, and obtain the distorted auxiliary foreground image according to the new coordinate value.
In the embodiment of the present disclosure, the image display device distorts the auxiliary foreground image according to the position relationship between the frame corresponding to the target area and the auxiliary foreground image, and obtaining the distorted auxiliary foreground image may include S2021 to S2023, as follows:
s2021, for each pixel point in the auxiliary foreground image, calculating a product of a length-to-width ratio of a frame body corresponding to the target area and a longitudinal coordinate of each pixel point, and taking the sum of the square of the product and the square of the abscissa of each pixel point as a first calculation result.
In the embodiment of the disclosure, the image display device first obtains the length and the width of the frame body according to the frame body corresponding to the target area, and then, for each pixel point in the auxiliary foreground image, the image display device can obtain the abscissa and the ordinate of each pixel point in the texture space coordinate system.
In the embodiments of the present disclosure, the image display apparatus calculates a length-to-width ratio. Multiplying the ratio by the ordinate of each pixel, and taking the sum of the square of the multiplied product and the square of the abscissa of each pixel as a first calculation result.
In some embodiments, the image display apparatus may take the calculation result of equation 1 as the first calculation result:
wherein,
for the abscissa value of each pixel in the auxiliary foreground image,
for the ordinate value of each pixel point in the auxiliary foreground image,
the length of the frame corresponding to the target area,
the width of the frame corresponding to the target area.
S2022, calculate a double value of the square of the length as a second calculation result.
In the embodiment of the present disclosure, the image display device calculates a square value of the length of the frame corresponding to the target area, and then multiplies the square value by two to obtain a second calculation result.
In some embodiments, the image display apparatus may obtain the second calculation result according to equation 2:
and S2023, when the first calculation result is smaller than the second calculation result, transforming the coordinates of each pixel point in a texture coordinate space to obtain a distorted auxiliary foreground image.
In the embodiment of the present disclosure, when the first calculation result is smaller than the second calculation result, it indicates that the position of the frame corresponding to the target area partially coincides with the position of the auxiliary foreground image, and at this time, the auxiliary foreground image may be distorted to show an effect that the target information and the auxiliary foreground image interact with each other.
In some embodiments, when equation 3 is satisfied, that is, when the statement in if is determined to be true, the image display device transforms the coordinates of each pixel point in the texture coordinate space to obtain the distorted auxiliary foreground image.
It can be understood that the image display device calculates which parts of the auxiliary foreground image coincide with the target information distance through the length and the width of each pixel point in the auxiliary foreground image and the frame body corresponding to the target area, that is, the target information extrudes the auxiliary foreground image, the image display device distorts the part of the auxiliary foreground image extruded by the target information, and the rest of the auxiliary foreground image is not distorted, so that the special effect that the corresponding part of the auxiliary foreground image deforms under the extrusion effect of the target information can be embodied.
In this embodiment of the present disclosure, the transforming, by the image display device in S2023, the coordinate of each pixel point in the texture coordinate space to obtain the distorted auxiliary foreground image may further include S301 to S304, as follows:
s301, obtaining the center coordinate of the frame body corresponding to the target area, wherein the center coordinate is the coordinate of the center point.
In the embodiment of the present disclosure, after obtaining the frame corresponding to the target area, the image display device may correspondingly obtain the coordinate of the central point of the frame corresponding to the target area as the central coordinate.
In the embodiment of the present disclosure, since the frame corresponding to the target area obtained by the image display device is in a regular shape after the normalization processing, for a frame corresponding to a target area in a regular shape, the image display device may obtain a center point of the frame corresponding to the target area, and the image display device uses coordinates of the center point in the texture space coordinate system as the center coordinates.
In some embodiments, when the frame corresponding to the target area is a rectangle, the image display device may obtain a center point of the rectangle, and use a coordinate corresponding to the center point of the rectangle as the center coordinate.
S302, calculating a distortion coefficient of the auxiliary foreground image according to the proportion of the target information occupying the display screen, wherein the distortion coefficient represents the distortion degree of the auxiliary foreground image.
In the embodiment of the present disclosure, the image display device may further calculate a distortion coefficient of the auxiliary foreground image according to a ratio of the target information occupying the display screen.
In the embodiment of the present disclosure, the image display apparatus may calculate the distortion coefficient of the auxiliary foreground image by obtaining the proportion of the target information occupying the display screen in step S103.
In some embodiments, the warping factor of the auxiliary foreground image may be used
To indicate when
When the ratio of the frame body corresponding to the target area to the screen is between a first preset threshold and a second preset threshold, the foreground auxiliary image is not distorted, and when the ratio of the frame body corresponding to the target area to the screen is between the first preset threshold and the second preset threshold, the foreground auxiliary image is not distorted
The value of (d) is mapped between 0 and 1.
In the embodiment of the present disclosure, for the auxiliary foreground images with different shapes, algorithms with different distortion coefficients exist in the OPEN GL graphics algorithm, which is specifically selected according to actual situations, and the embodiment of the present disclosure is not limited.
By calculating the distortion coefficient, the effect that the closer the frame corresponding to the target region is to the foreground auxiliary image, the greater the distortion degree of the foreground auxiliary image can be achieved.
And S303, calculating a new distorted coordinate of each pixel point according to the central coordinate, the first calculation result, the second calculation result and the distortion coefficient.
In the embodiment of the present disclosure, the image display apparatus may calculate, according to the central coordinate obtained in S301, the first calculation result obtained in S2021, the second calculation result obtained in S2022, and the distortion coefficient obtained in S302, a new coordinate after each pixel point is distorted according to formula (4), as follows:
wherein,
and
for pixels in the foreground auxiliary image
And
warping the new coordinates corresponding to the transformed object,
the center coordinates of the rectangular frame are the target information.
In the embodiment of the present disclosure, for each pixel point in the auxiliary foreground image that is determined to need to be distorted in S2023, the image display device may calculate, according to formula (4), a new coordinate corresponding to each distorted pixel point in the texture coordinate system, where the new coordinate is a coordinate after the pixel point in the auxiliary foreground image is close to and coincides with the target information, and is transformed in different directions and different programs according to the relative position and the close degree of the target information.
It can be understood that, by calculating the new coordinates of each distorted pixel point, the image display device obtains the position of the auxiliary foreground image after deformation generated by approaching and extruding the target information, and the interaction effect of the auxiliary foreground image and the target information is embodied.
And S304, obtaining a distorted auxiliary foreground image according to the distorted new coordinates of each pixel point.
In the embodiment of the present disclosure, after the image display device obtains the new distorted coordinates of each pixel point, the line position of the corresponding portion of the auxiliary foreground image is correspondingly changed according to the new distorted coordinates of each pixel point, so as to obtain the distorted auxiliary foreground image.
In some embodiments, as shown in fig. 14, when the target information is a human face 140 and the auxiliary foreground images are the auxiliary foreground images 141_1 and 141_2 in the shape of horizontal straight lines, the image display apparatus distorts the auxiliary foreground image at the portion of the extrusion position 141_2_1 of the human face 140 due to the extrusion of the auxiliary foreground image 142 by the position of the human face 140, so as to obtain the distorted special effect shown in fig. 14.
In some embodiments, as shown in fig. 15, when the target information is a human face 150 and the auxiliary foreground images are oblique and straight auxiliary foreground images 151_1 and 151_2, since the position of the human face 150 squeezes the auxiliary foreground image 151_1, the image display device distorts the auxiliary foreground image at the squeezed position 151_1_1 of the human face 150, resulting in a distorted special effect as shown in fig. 15.
In some embodiments, as shown in fig. 16, when the target information is a human face 160 and the auxiliary foreground image is an auxiliary foreground image 161 in a circular ring shape, since the position of the human face 160 forms a squeeze on the auxiliary foreground image 161, the image display device distorts the auxiliary foreground image at the squeeze position 161_1 of the human face 160, so as to obtain a distorted special effect as shown in fig. 16.
It can be understood that, when the ratio of the target information occupying the screen is greater than or equal to the second preset threshold and smaller than the first preset threshold, the image display device distorts the auxiliary foreground image according to the position of the target information, so that the interactive special effect between the target information and the auxiliary foreground image is embodied, and the stereoscopic effect of the image is enhanced.
It should be noted that, the image display method in the embodiment of the present disclosure is a method of performing image display processing on one original image frame, and for a continuously shot video stream, the embodiment of the present disclosure may perform the same image display method on each acquired original image frame, so as to finally obtain a stereoscopic effect of target information in the entire dynamic video or image stream.
The above description is only an example of the present disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.