WO2021189880A1 - 头发的渲染方法、装置、电子设备及存储介质 - Google Patents

头发的渲染方法、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2021189880A1
WO2021189880A1 PCT/CN2020/129859 CN2020129859W WO2021189880A1 WO 2021189880 A1 WO2021189880 A1 WO 2021189880A1 CN 2020129859 W CN2020129859 W CN 2020129859W WO 2021189880 A1 WO2021189880 A1 WO 2021189880A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
hair
motion state
particle
area
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2020/129859
Other languages
English (en)
French (fr)
Inventor
侯沛宏
马重阳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to JP2022549140A priority Critical patent/JP7390495B2/ja
Publication of WO2021189880A1 publication Critical patent/WO2021189880A1/zh
Priority to US17/897,309 priority patent/US20220414963A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/00Two-dimensional [2D] image generation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/00Three-dimensional [3D] image rendering
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T13/00Animation
    • G06T13/20Three-dimensional [3D] animation
    • G06T13/40Three-dimensional [3D] animation of characters, e.g. humans, animals or virtual beings
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/00Two-dimensional [2D] image generation
    • G06T11/10Texturing; Colouring; Generation of textures or colours
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/00Three-dimensional [3D] image rendering
    • G06T15/04Texture mapping
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/20Analysis of motion
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10016Video; Image sequence
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person
    • G06T2207/30201Face
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2210/00Indexing scheme for image generation or computer graphics
    • G06T2210/56Particle system, point based geometry or rendering

Definitions

  • the present disclosure relates to the field of image processing technology, and in particular to hair rendering methods, devices, electronic equipment, and storage media.
  • the pixels in the hair area are subjected to rendering processing such as color replacement and blurring through the CPU (central processing unit) on the PC (personal computer) side or the server side.
  • CPU central processing unit
  • the current rendering method has a large amount of calculations, and the processing of the hair particle information by the CPU is often complicated, and real-time rendering cannot be realized on the mobile terminal.
  • the processing of the hair particle information by the CPU is often complicated, and real-time rendering cannot be realized on the mobile terminal.
  • there is an increasing demand for live broadcasting through the mobile terminal so it is necessary to provide a method capable of real-time rendering of the hair on the mobile terminal.
  • the present disclosure provides a hair rendering method, method, device, electronic device, and storage medium, so as to at least solve the problem that the hair cannot be rendered in real time on the mobile terminal in the related art.
  • the technical solutions of the present disclosure are as follows:
  • a hair rendering method including: obtaining a target video containing hair information, selecting a target image frame from image frames of the target video; and obtaining a texture of the target image frame An image, wherein the texture image is an image in a texture format that records the motion state and state change information of pixels in the target image frame, and the hair area in the texture image is divided into at least one particle area by a grid line; Acquire the first target motion state and target state change information of the first target particle region from the texture image, wherein the first target particle region is any region of the at least one particle region; according to the first target particle region The target motion state and the target state change information determine the second target motion state of the first target particle area in the next image frame, wherein the next image frame is the target image frame of the target video The next frame of image; the motion state in the texture image is updated according to the second target motion state to render the hair region.
  • the step of updating the motion state in the texture image according to the second target motion state includes: performing the motion state of the first target particle region according to the second target motion state Update and retain the movement state of the remaining particle area; the remaining particle area is other particle areas in the at least one particle area except for the first target particle area.
  • the first target motion state includes first screen coordinates
  • the target state change information includes a first speed
  • the first target motion state and the target state change information are used to determine the first
  • the step of the second target motion state of the target particle area in the next image frame includes: determining the time difference between the target image frame and the next image frame; according to the first screen coordinates, the first The difference between the speed and the time determines the second screen coordinates of the first target particle area in the next image frame as the second target motion state.
  • the step of updating the motion state in the texture image according to the second target motion state includes: if the second screen coordinates are outside the hair area, re-determining the texture The hair region of the image, and determine the second target particle region from the particle region corresponding to the newly determined hair region; obtain the reference target motion state and reference target state change information of the second target particle region from the texture image; According to the reference target motion state and the reference target state change information, determine the motion state of the second target particle region in the next image frame to obtain a third target motion state; according to the third target motion The state updates the motion state in the texture image.
  • the first target motion state includes a second speed
  • the target state change information includes a hair direction angle
  • the first target is determined according to the first target motion state and the target state change information
  • the step of the second target motion state of the particle area in the next image frame includes: obtaining a preset speed; and determining the first target particle area according to the second speed, the hair direction angle, and the speed At the third speed in the next image frame, the second target motion state is obtained.
  • the method further includes: determining the candidate state of each pixel in the target image frame according to the time-varying pixel state information in the target video Change information; obtain the hair direction map and the hair region mask map corresponding to the target image frame; the hair direction map contains the hair direction angle of each pixel, and the hair region mask map contains some The mask information of the hair region in the target image frame; determine the candidate motion state of each pixel according to the hair direction angle in the hair direction map and the mask information in the hair region mask map; The candidate state change information and the candidate motion state are stored in the vertex position of the at least one particle region; wherein the vertex position of the at least one particle region corresponds to the respective pixel point.
  • the method further includes: storing the texture image in a first frame buffer
  • the method further includes: storing the texture image in the first frame buffer in the second frame buffer; updating The subsequent texture image is stored in the first frame buffer.
  • the method further includes: determining a hair region in the texture image; and performing grid division on the hair region according to a predetermined number of particle beams, A corresponding at least one particle beam is obtained; and the at least one particle beam is respectively grid-divided according to the predetermined number of particles to obtain the corresponding at least one particle area.
  • the method before the step of acquiring the first target motion state and target state change information of the first target particle region from the texture image, the method further includes: setting the at least one particle beam in a set position The particle area is determined as the first target particle area.
  • a hair rendering device including: an image frame determining unit configured to perform acquisition of a target video containing hair information, and select a target image frame from the image frames of the target video
  • the texture image acquisition unit is configured to perform acquisition of the texture image of the target image frame, wherein the texture image is an image in a texture format that records the motion state and state change information of pixels in the target image frame, so The hair area in the texture image is divided into at least one particle area by a grid line;
  • the state information obtaining unit is configured to obtain the first target motion state and target state change information of the first target particle area from the texture image, Wherein, the first target particle area is any area of the at least one particle area;
  • the motion state determining unit is configured to perform determining the The second target motion state of the first target particle area in the next image frame, wherein the next image frame is the next image of the target image frame in the target video;
  • the motion state update unit is configured to Performing updating the motion state in the texture image according to the second
  • the motion state update unit is further configured to perform update of the motion state of the first target particle region according to the second target motion state, and retain the motion state of the remaining particle regions, wherein The remaining particle area is another particle area except for the first target particle area in the at least one particle area.
  • the first target motion state includes first screen coordinates
  • the target state change information includes a first speed
  • the motion state determination unit includes: a time difference determination subunit configured to perform the determination The time difference between the target image frame and the next image frame; a first motion state determination subunit configured to perform determining according to the first screen coordinates, the first speed, and the time difference
  • the second screen coordinates of the first target particle area in the next image frame are used as the second target motion state.
  • the motion state update unit includes: a particle area determination subunit configured to perform redefining the hair area of the texture image if the second screen coordinates are outside the hair area, and resetting Determine the second target particle region in the particle region corresponding to the determined hair region; the state information acquiring subunit is configured to perform acquiring the reference target motion state and the reference target state of the second target particle region from the texture image Change information; a second motion state determination subunit configured to perform determination of the motion state of the second target particle area in the next image frame according to the reference target motion state and the reference target state change information To obtain the third target motion state; the motion state update subunit is configured to perform update of the motion state in the texture image according to the third target motion state.
  • the first target motion state includes a second speed
  • the target state change information includes a hair direction angle
  • the motion state determination unit includes: a rate acquisition subunit configured to perform acquisition of a preset Speed; a third motion state determination subunit, configured to perform determining the third of the first target particle area in the next image frame according to the second speed, the hair direction angle, and the speed Speed to obtain the second target motion state.
  • the hair rendering device further includes: a state change information determining unit configured to determine the candidate of each pixel in the target image frame according to the pixel state information that changes over time in the target video State change information; an image acquisition unit configured to perform acquisition of a hair direction map and a hair region mask map corresponding to the target image frame; the hair direction map includes the hair direction angles of the respective pixels, the The hair region mask map contains the mask information of the hair region in the target image frame; the candidate motion state determination unit is configured to execute the hair region mask map based on the hair direction angle in the hair direction map The mask information in, determines the candidate motion state of each pixel; the candidate motion state storage unit is configured to perform storing the candidate state change information and the candidate motion state to the vertex of the at least one particle area Position; wherein the vertex position of the at least one particle area corresponds to the respective pixel point.
  • a state change information determining unit configured to determine the candidate of each pixel in the target image frame according to the pixel state information that changes over time in the target video State change information
  • the hair rendering device further includes: a first image storage unit configured to execute storing the texture image in a first frame buffer; an image dumping unit configured to execute storing the first frame The texture image in the buffer is stored in the second frame buffer; the second image storage unit is configured to execute the storage of the updated texture image in the first frame buffer.
  • the hair rendering apparatus further includes: a region determining unit configured to perform determining the hair region in the texture image; The region is grid-divided to obtain at least one corresponding particle beam; the particle beam dividing unit is configured to perform grid division of the at least one particle beam according to a predetermined number of particles to obtain at least one corresponding particle region.
  • the hair rendering device further includes: a particle region determining unit configured to determine a particle region at a set position in the at least one particle beam as the first target particle region.
  • an electronic device including a processor; a memory for storing executable instructions of the processor; wherein the processor is configured to execute the instructions to achieve the above The described hair rendering method.
  • a storage medium is provided.
  • the electronic device can execute the hair rendering method described above.
  • a computer program product includes a computer program, the computer program is stored in a readable storage medium, and at least one processor of the device obtains data from the readable storage medium.
  • the computer program is read and executed, so that the device executes the hair rendering method described in the above embodiment.
  • the texture image of the target image frame is acquired according to the target video containing the hair information, the texture image can be processed by the GPU; the hair region in the texture image is divided into at least A particle area can realize the GPU processing of the particle area, while greatly simplifying the graphics processing efficiency of the GPU, and realizes the calculation on the mobile terminal; in addition, obtain the first target motion state and target state change information of the target particle area from the texture image According to this, the second target motion state of the first target particle region in the next image frame is determined, and the motion state in the texture image is updated according to the second target motion state to realize the rendering of the hair region.
  • real-time rendering of the hair area can be realized on the mobile terminal, and the motion state of the specific particle area can be modified at the same time, so that the special rendering effect of particles flowing along the hairline direction can be realized.
  • Fig. 1 is a diagram showing an application environment of a hair rendering method according to an exemplary embodiment.
  • Fig. 2 is a flow chart showing a method for rendering hair according to an exemplary embodiment.
  • Fig. 3 is a schematic diagram showing the structure of a particle beam according to an exemplary embodiment.
  • Fig. 4 is a schematic diagram showing a display of hair rendering according to an exemplary embodiment.
  • Fig. 5 is a flowchart showing a method for rendering hair according to another exemplary embodiment.
  • Fig. 6 is a block diagram showing a device for rendering hair according to an exemplary embodiment.
  • the hair rendering method provided in the present disclosure can be applied to the device 100 as shown in FIG. 1.
  • the device 100 may be a mobile terminal, such as a mobile phone, a computer, a digital broadcasting terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, and so on.
  • the device 100 may include one or more of the following components: a processing component 101, a memory 102, a power supply component 103, a multimedia component 104, an audio component 105, an input/output (I/O) interface 106, a sensor component 107, and Communication component 108.
  • a processing component 101 a memory 102
  • a power supply component 103 a multimedia component 104
  • an audio component 105 an input/output (I/O) interface 106
  • sensor component 107 a sensor component 107
  • Communication component 108 Communication component
  • the processing component 101 generally controls the overall operations of the device 100, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations.
  • the processing component 101 may include one or more processors 109 to execute instructions to complete all or part of the steps of the foregoing method.
  • the processing component 101 may include one or more modules to facilitate the interaction between the processing component 101 and other components.
  • the processing component 101 may include a multimedia module to facilitate the interaction between the multimedia component 104 and the processing component 101.
  • the memory 102 is configured to store various types of data to support operations in the device 100. Examples of such data include instructions for any application or method operating on the device 100, contact data, phone book data, messages, pictures, videos, and the like.
  • the memory 102 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable Programmable read only memory (EPROM), programmable read only memory (PROM), read only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
  • SRAM static random access memory
  • EEPROM electrically erasable programmable read-only memory
  • EPROM erasable Programmable read only memory
  • PROM programmable read only memory
  • ROM read only memory
  • magnetic memory flash memory
  • flash memory magnetic or optical disk.
  • the power supply component 103 provides power to various components of the device 100.
  • the power supply component 103 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 100.
  • the multimedia component 104 includes a screen that provides an output interface between the device 100 and the user.
  • the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user.
  • the touch panel includes one or more touch sensors to sense touch, sliding, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure related to the touch or slide operation.
  • the multimedia component 104 includes a front camera and/or a rear camera. When the device 100 is in an operation mode, such as a shooting mode or a video mode, the front camera and/or the rear camera can receive external multimedia data. Each front camera and rear camera can be a fixed optical lens system or have focal length and optical zoom capabilities.
  • the audio component 105 is configured to output and/or input audio signals.
  • the audio component 105 includes a microphone (MIC).
  • the microphone When the device 100 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive external audio signals.
  • the received audio signal can be further stored in the memory 102 or sent via the communication component 108.
  • the audio component 105 further includes a speaker for outputting audio signals.
  • the I/O interface 106 provides an interface between the processing component 101 and a peripheral interface module.
  • the above-mentioned peripheral interface module may be a keyboard, a click wheel, a button, and the like. These buttons may include, but are not limited to: home button, volume button, start button, and lock button.
  • the sensor component 107 includes one or more sensors for providing the device 100 with various aspects of state evaluation.
  • the sensor component 107 can detect the on/off status of the device 100 and the relative positioning of components.
  • the component is the display and keypad of the device 100.
  • the sensor component 107 can also detect the position change of the device 100 or a component of the device 100. , The presence or absence of contact between the user and the device 100, the orientation or acceleration/deceleration of the device 100, and the temperature change of the device 100.
  • the sensor assembly 107 may include a proximity sensor configured to detect the presence of nearby objects when there is no physical contact.
  • the sensor component 107 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications.
  • the sensor component 107 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
  • the communication component 108 is configured to facilitate wired or wireless communication between the device 100 and other devices.
  • the device 100 can access a wireless network based on a communication standard, such as WiFi, an operator network (such as 2G, 3G, 4G, or 5G), or a combination thereof.
  • the communication component 108 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel.
  • the communication component 108 further includes a near field communication (NFC) module to facilitate short-range communication.
  • the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
  • RFID radio frequency identification
  • IrDA infrared data association
  • UWB ultra-wideband
  • Bluetooth Bluetooth
  • the device 100 may be implemented by one or more application-specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field-available A programmable gate array (FPGA), controller, microcontroller, microprocessor, or other electronic components are implemented to implement the above methods.
  • ASIC application-specific integrated circuits
  • DSP digital signal processors
  • DSPD digital signal processing devices
  • PLD programmable logic devices
  • FPGA field-available A programmable gate array
  • controller microcontroller, microprocessor, or other electronic components are implemented to implement the above methods.
  • Fig. 2 is a flow chart showing a method for rendering hair according to an exemplary embodiment.
  • the method for rendering hair can be used in the device 100 shown in Fig. 1 (and can also be specifically used in the processor 109 in Fig. 1 More specifically, it can also be applied to the GPU of the device 100), as shown in FIG. 2, including the following steps S201/S202/S203/S204/S205, which are described in detail as follows:
  • step S201 a target video containing hair information is acquired, and a target image frame is selected from the image frames of the target video.
  • the target video may be a video obtained by collecting the head of a human body (or an animal body) through a shooting device.
  • the photographing device may be the sensor component 107 on the device 100, or may be a camera that has a network connection relationship with the device 100.
  • the hair information contained in the target video may refer to information such as the location of the hair area, the size of the hair area, the real-time position of the hair area, the hair color, the length of the hair, the direction of the hair, and so on.
  • the camera can shoot a target video containing hair information for a set time period, and send the captured target video to the device 100 (or directly to the processor of the device 100), and the processor performs hair rendering. Furthermore, the camera may shoot the target video in advance, and send the captured target video to the device 100 together; it may also send the target video to the processor in real time during the shooting process.
  • each time sequence of the target video corresponds to an image frame
  • the device 100 can perform hair rendering processing on one or some of the image frames in a one-time hair rendering program, and the one or some image frames can be understood Is the target image frame.
  • the target image frame may be an image frame randomly selected from the target video, or may be several consecutive image frames selected in a time sequence.
  • step S202 a texture image of the target image frame is acquired, where the texture image is an image in a texture format that records the motion state and state change information of pixels in the target image frame, and the texture image in the texture image
  • the hair area is divided into at least one particle area by the grid line.
  • the texture format is a pixel format that can be recognized by the GPU.
  • the texture image in the embodiment of the present disclosure is the image in the texture format.
  • the texture image can also be directly referred to as "texture", which can be half float (half float). Point) or float (floating point) type texture map.
  • the texture image of the target image frame is acquired, and the GPU in the device 100 processes the texture image.
  • the hair area in the texture image can be determined according to the color of each pixel in the target image frame. For example, the black area with an area larger than the set value is determined as the hair area, and then the corresponding information is filled in the grid corresponding to the texture image , To characterize the hair area in the texture image.
  • the process of determining the hair region can also be implemented by machine learning, for example: input multiple videos containing hair information into a pre-built neural network model, and input each video frame into the neural network model.
  • the neural network model performs self-learning through the input information and completes the training process. After training, the target video shot by the camera is input to the neural network model, and the neural network model can automatically output each of the target videos The hair area of the image frame.
  • the hair area in the texture image is divided into at least one particle area (in some cases, other areas outside the hair area can also be grid-divided to obtain the corresponding particle area), and the particle area can be used by the device 100 is divided after acquiring the texture image, and may also be divided by an external device of the device 100 or by other components other than the processor in the device 100 (for example, it may be divided by a sensor component on the device 100).
  • the hair area corresponding to the texture image can be divided according to a set number of grid lines, and the particle area can be determined according to the divided grid; the texture image can also be divided according to the distribution of hair strands, for example, each The hair strand (the distance between the hair strands is small enough) is determined as the particle area.
  • the number of particle areas in the texture image can be determined according to the actual situation.
  • the number of particle areas can be a larger value.
  • the number of particle regions can be a smaller value.
  • the target image frame may be the image frame displayed on the display screen of the device 100, that is, the texture image records the particle information of the image frame currently displayed on the display screen.
  • the particle information is each pixel in the target image frame (each pixel is There may be corresponding particle area) motion state and state change information.
  • the movement state is the state of the particle in the corresponding image frame, which can be position information, speed information (including speed and direction), hair direction angle, size, etc.; and state change information can refer to the state change of the particle.
  • the information described can characterize the movement state of the particle in the next adjacent image frame, and can be speed, hair direction angle, rotation direction, life cycle, and so on. It should be noted that some particle information can be either motion state or state change information.
  • speed can not only characterize the rate and direction information of a certain image frame (in this case, it can be used as the motion state), or it can characterize the image.
  • the movement state of the frame (this can be used as state change information, it can determine the movement distance of the particle in combination with the time information, and then determine the position coordinate of the particle).
  • the velocity can be used to evaluate the position of the particle at the next moment.
  • the position information can be used as the movement state and the velocity can be used as the state change information
  • the speed can be used to evaluate the speed of the particle at the next moment.
  • the speed can be used as the motion state and the speed can be used as the state change information.
  • the speed is both the motion state and the state change information.
  • one texture image is not enough to store the motion state or state change information, it can be stored by using two texture images.
  • two texture images can be used to store position information, speed information (including speed and direction), hair direction angle, rotation direction, life cycle, size, and other dimensions.
  • step S203 obtain the first target motion state and target state change information of the first target particle area from the texture image, wherein the first target particle area is any area of the at least one particle area .
  • each particle in the texture image may have its own number, and the particle information of each particle is stored in each particle area of the texture image.
  • the target particle area can be randomly selected from each particle area of the texture image, or can be selected according to a specific rule (for example, a particle area at a specific position is selected). Further, the corresponding target motion state and state change information can be obtained through the particle information recorded in the target particle area, that is, the first target motion state and target state change information can be obtained.
  • the specific implementation process of S203 may be: obtaining at least one of the screen coordinates, speed, direction angle, rotation attitude, current life state, life cycle, and size of the target particle from the texture image, and according to the obtained information Obtain the first target motion state and the target state change information (the corresponding target state change information can be determined according to the current motion state to be updated).
  • the method further includes: determining a hair area in the texture image; performing processing on the hair area according to a predetermined number of particle beams.
  • the grid is divided to obtain at least one corresponding particle beam; the at least one particle beam is respectively grid divided according to the predetermined number of particles to obtain the corresponding at least one particle area.
  • the number of particle beams is used to characterize the number of particle beams contained in the hair region, and the number can be determined according to the screen resolution, rendering fineness, etc.; the number of particles is used to characterize the number of particle regions contained in the particle beam, and the number is also It can be determined according to the screen resolution, rendering fineness, etc.
  • the hair area or particle beam can be divided according to grid lines at equal intervals (of course, the intervals can also be unequal). At the same time, it can be divided horizontally, vertically, or horizontally and horizontally. Vertical combination (both horizontal and vertical division, in this case, the horizontal and vertical division intervals may be the same or different), or may be divided according to a line at a certain angle (for example, 30°) to the horizontal line of the screen.
  • the schematic diagram of the texture image can be as shown in Figure 3.
  • the left side of Figure 3 shows a girl’s head profile.
  • the head profile includes the hair profile (thick solid line) and the face profile (thin solid line).
  • the hair area 301 and the face area 302 are respectively constituted.
  • the hair area is divided into a plurality of particle beams, and a grid area 303 surrounded by a thick dashed line in FIG. 3 can be understood as a particle beam.
  • these particle beams are also divided into multiple small areas, and these small areas may be referred to as the first target particle area 304 (also may be referred to as hair particles or particles.
  • the first target particle area 304 also may be referred to as hair particles or particles.
  • For the specific division please refer to the enlarged view on the right side of FIG. 3). ).
  • FIG. 3 is a grid division for the entire texture image.
  • only the hair area (or only the hair area and the face area) can be divided.
  • a video contains multiple frames, and because the head position may change, the hair area in each frame will also change. Therefore, after obtaining a texture image, the hair area can be determined again.
  • the hair area is divided into grids.
  • the method before the step of acquiring the first target motion state and target state change information of the first target particle region in the at least one particle region from the texture image, the method further includes: The particle area at the set position in the at least one particle beam is determined as the first target particle area.
  • the set position can be a particle area in a center position, a head position (the position where the first number is located), and a tail position (the position where the last number is located) in a certain particle beam.
  • the embodiment of the present disclosure selects the target particle region from multiple particle regions of the particle beam (as shown in 304 in FIG. 3).
  • the selection method can be random selection, or the center or edge particles can be selected as the target.
  • the particle area in some exemplary embodiments, the target particle area may also be referred to as a head particle (the particle plays a role in driving other particles to move during the rendering process).
  • the method of selecting target particles in different particle beams in the same texture image can be the same or inconsistent. Taking the inconsistency as an example, the implementation method can be specifically as follows: Select a particle at the edge of a certain particle beam The region is used as the target particle region, and in another particle beam, the particle region located in the center can be selected as the target particle region.
  • the number of target particle regions corresponding to a particle beam can be one, two or more.
  • the target particle region can be the selected target particle region of all particle beams in the hair region, or it can be part of the target particle region. Or the selected target particle area in a certain particle beam. Dividing the hair area in the texture image can update the motion state of the specific particle area, so that these particle areas will gradually change in the final displayed video, and achieve the rendering effect of particles flowing along the hair direction.
  • step S204 determine the second target motion state of the first target particle area in the next image frame according to the first target motion state and the target state change information, where the next image frame is The next image of the target image frame in the target video.
  • the next image frame is the image frame of the target image frame at the next moment.
  • the moment in the "next moment" can be determined according to the frame sampling rate, and 1 min contains 60 image frames [one image per second (s) Frame] as an example, if the frame sampling rate is 5s/frame, the next image frame and the target image frame are separated by 4 image frames, and if the frame sampling rate is 1s/frame, the next image frame is between the target image frame 0 image frames apart (that is, the two are adjacent). Therefore, the selection of image frames can be adjusted according to the actual situation. For example, if the rendering fineness is high, the frame sampling rate can be a high value (more image frames need to be processed at this time), and if the rendering fineness is required If the requirement is low, the frame sampling rate can be a low value.
  • the first target motion state characterizes the motion state of the first target particle area in the target image frame
  • the target state change information characterizes the influence of the first target particle area on the state change in the target image frame. Therefore, By combining the two, the movement state of the first target particle area in the next image frame can be obtained, that is, the second target movement state can be obtained.
  • the texture image contains the following particle information: the position coordinates of the first target particle area is (2,2), its velocity direction is the horizontal line of the screen (which can be recorded as the x-axis) positive direction 36.87°, and the velocity value is 5mm/s,
  • the position coordinate is the first target motion state, and the speed direction and speed are the target state change information.
  • the first target particle area is from the target image frame to the next image frame (using the target image frame and the next image frame).
  • the interval time is 1s as an example) It moves 3mm in the positive direction of the x-axis and 4mm in the direction of the y-axis. Therefore, it can be determined that the position coordinates of the first target particle area in the next image frame are (5, 6), and we get The second target state of motion.
  • step S205 the motion state in the texture image is updated according to the second target motion state to render the hair region.
  • Updating the motion state in the texture image can be understood as directly replacing the first target motion state in the texture image with the second target motion state.
  • the display screen of the device 100 displays the target image frame according to the texture image at the beginning. After the texture image is updated, the corresponding next image frame can be displayed on the display screen. At this time, the motion state of the first target particle area on the screen It will change from the first target motion state to the second target motion state, that is, the rendering effect of the flow of specific particles in the hair area is realized.
  • the completion of the switching between the target image frame and the next image frame can be regarded as the completion of the rendering of the hair region. Next, you can continue with a new rendering.
  • the texture image of the target image frame is obtained according to the target video containing the hair information, and the texture image can be processed by the GPU; the hair area in the texture image is divided into at least one particle area, which can realize the GPU to the particle Area processing, while greatly simplifying the graphics processing efficiency of the GPU to realize the calculation on the mobile terminal; in addition, the first target motion state and target state change information of the target particle area are obtained from the texture image, and the first target particle area is determined accordingly In the second target motion state in the next image frame, the motion state in the texture image is updated according to the second target motion state, so as to realize the rendering of the hair region.
  • real-time rendering of the hair area can be realized on the mobile terminal, and the motion state of the specific particle area can be modified at the same time, so that the special rendering effect of particles flowing along the hairline direction can be realized.
  • the step of updating the motion state in the texture image according to the second target motion state includes: updating the first target particle area according to the second target motion state
  • the movement state of is updated, and the movement state of the remaining particle area (also referred to as the tail particle area or the tail particle) is retained; the remaining particle area is the particle in the at least one particle area except the first target particle area area.
  • the movement state of the remaining particle area in the next image frame directly adopts the movement state of the target image frame, while the movement state of the first target particle area is updated in real time.
  • the display state in the display screen is It is: the state of the first target particle area changes while the state of the remaining particle area does not change.
  • the display schematic diagram of the hair area of the target image frame can be as shown in Figure 4(a) (the grid line may not be displayed during display), and the state of the hair can be seen clearly; after the rendering process, there is tailing
  • the hair area of the rendering effect can be as shown in Figure 4(b).
  • the gray area 401 in Figure 4(b) can be the first target particle area.
  • the first target particle area is blurred due to motion during frame switching. While the state of particles in other areas remains unchanged, the hair can still be seen clearly, so that the particle beam flows along the direction of the hair and the rendering effect of "tailing" is realized.
  • the motion state of the remaining particle area in the next image frame may not adopt the corresponding reference remaining motion state in the target image frame, but obtain the candidate remaining motion state according to the method for determining the second target motion state.
  • Determine the difference between the candidate residual motion state and the reference residual motion state multiply the difference by a certain ratio (for example: 30%) and sum it with the reference residual motion state to obtain the motion of the remaining particle area in the next image frame State
  • this processing method can make the remaining particles change in the rendering process, but the change range is not as large as the target particle, which can produce a "tailing" effect and the fluidity of the hair is more natural.
  • operations such as color rendering (for example: replacing black particles with golden particles) on the target particle area or the remaining particle area may be performed according to the needs of the scene.
  • the first target motion state includes first screen coordinates
  • the target state change information includes a first speed
  • the determination is based on the first target motion state and the target state change information
  • the step of the second target motion state of the first target particle area in the next image frame includes: determining the time difference between the target image frame and the next image frame; The first speed and the time difference determine the second screen coordinates of the first target particle area in the next image frame as the second target motion state.
  • the screen coordinates may be understood as the position coordinates of the vertices of the first target particle area in the display screen of the device 100.
  • updating the screen coordinates of the first target particle area may be that the vertex position of the first target particle area is updated, while other positions are not updated.
  • the second screen coordinates of the first target particle area in the next image frame are determined according to the first screen coordinates, the first speed, and the time difference, and the second screen coordinates are used as the second target motion state.
  • the process of determining the motion state is simple, which can effectively improve the efficiency of hair area rendering and realize real-time rendering on the mobile terminal.
  • the step of updating the motion state in the texture image according to the second target motion state includes: if the second screen coordinates are within the hair area In addition, re-determine the hair area of the texture image, and determine the second target particle area from the particle area corresponding to the newly determined hair area; obtain the reference target motion state of the second target particle area from the texture image And reference target state change information; determine the motion state of the second target particle region in the next image frame according to the reference target motion state and the reference target state change information to obtain a third target motion state; The third target motion state updates the motion state in the texture image.
  • the second screen coordinates can be compared with the coordinates of each particle area in the hair area, and if none of them match, then the first screen coordinates can be considered to be outside the hair area.
  • the motion state of the target particle (that is, the third target motion state) is re-determined, and the texture image is updated according to the third target motion state, which can ensure The continuity of the hair area displayed on the display screen will not cause sudden deformation of the hair area, ensuring a good hair display effect.
  • the new motion state can be determined according to the third target motion state and the third target state change information, and so on. Until the determined screen coordinates are in the hair area.
  • the determined screen coordinates including the aforementioned second screen coordinates
  • the distance from the edge of the hair area is less than a preset threshold (the threshold can be determined according to the actual situation. The disclosure does not limit this)
  • the motion state may not be re-determined, but the texture image is directly updated according to the second target motion state.
  • the first target motion state includes a second speed
  • the target state change information includes a hair direction angle
  • the determination of the target state change information is based on the first target motion state and the target state change information.
  • the step of the second target motion state of the first target particle area in the next image frame includes: obtaining a preset speed; determining the first target particle area according to the second speed, the hair direction angle, and the speed.
  • the third velocity of the target particle area in the next image frame obtains the second target motion state.
  • both the first speed and the second speed are speed information obtained from a certain channel in the same texture image, and their sizes can be the same.
  • the speed is used as the state change information; when updating the speed, the speed is used as the motion state.
  • the velocity can also be referred to as a velocity scalar, which is used to control the flow velocity of the particles, which can be preset by the user or determined by a certain algorithm (for example, the velocity scalar gradually decreases as time changes).
  • the hair direction angle can refer to the angle of the speed of the first target particle area relative to the positive direction of the x-axis of the screen horizontal line, which can be understood as the direction of movement of the first target particle area, which can be represented by D (cost, sint), where t represents The angle of the target particle relative to the positive direction of the x-axis, and cost and sint respectively represent the distance components of the movement distance of the first target particle area in the x-axis and y-axis directions.
  • the third speed can be calculated by the following formula:
  • the third speed the second speed + hair direction angle * speed
  • the second speed includes a speed value and a direction angle. Therefore, the sum of "second speed” and “hair direction angle * rate” not only includes the sum of speed values, so it can also include the fusion of direction angles.
  • the third speed may not be determined in combination with the second speed. Instead, the product of the hair direction angle and the speed may be directly used as the third speed.
  • the specific calculation formula may be as follows:
  • the third speed v(u,v) D(cost,sint)*V, where D(cost,sint) is the direction angle of the hair, and V is the user-defined speed.
  • the foregoing embodiment determines the speed information of the next image frame according to the direction angle and the speed, and the determination process is simple, which can effectively improve the computing efficiency and realize real-time rendering on the mobile terminal.
  • the method before the step of obtaining the texture image of the target image frame, the method further includes: determining each pixel in the target image frame according to the pixel state information that changes with time in the target video Point candidate state change information; obtain the hair direction map and hair region mask map corresponding to the target image frame; the hair direction map contains the hair direction angle of each pixel, the hair region mask map Contains the mask information of the hair region in the target image frame; the candidate motion state of each pixel is determined according to the hair direction angle in the hair direction map and the mask information in the hair region mask map Storing the candidate state change information and the candidate motion state in the vertex position of the at least one particle area; wherein the vertex position of the at least one particle area corresponds to the respective pixel point.
  • the pixel state information can refer to the state information of each pixel in the video, such as the color and position of each pixel, and the relationship between the state of the pixels over time (for example, in a certain frame, a certain pixel P1 is pure black, and In the next frame, its adjacent pixel point P2 becomes pure black, and the pixel point P1 becomes another color).
  • a particle may correspond to one or more pixels (there is a mapping relationship between the particle and the pixel).
  • the state change information of each particle (such as moving speed, etc.) can be determined, and the candidate can be obtained Status change information.
  • the hair direction angle is the direction of the hair.
  • the hair direction angle t of each particle is arranged together to form a hair direction map; in other embodiments, the hair direction map can also store the values of cos2t and sin2t (store 2t angle The sine and cosine values of is to prevent the ambiguity of the hair direction on the same straight line).
  • the cost and sint can be determined by the following formulas:
  • sign represents a sign function.
  • t can be determined in the following ways: Sa. Calculate the grayscale image of the target image frame; Sb. Calculate the gradient image of the grayscale image; Sc. Blur the gradient image; Sd. Take each pixel of the vertical vector of Sc The direction vector of, get t.
  • the mask is a string of binary codes that performs bit-and operation on the target field.
  • the mask information of the hair area can indicate whether each particle is in the hair area.
  • the mask information of each particle is arranged together to form a hair area mask map.
  • the direction angle of each particle can be obtained, and the position information, size, etc. of each particle can be obtained according to the hair area mask map of a certain image frame.
  • the hair direction map of the adjacent image frame can know the rotation direction of each particle, and the hair area mask map of the adjacent image frame can know the life cycle of each particle (for example: determine that a certain particle is generated in the A image frame, and in the B image frame Disappear, the number of frames between A and B can be used as the life cycle of the particle), speed information (for example, a certain particle is at the c position in the C image frame, but at the d position in the D image frame, you can The velocity information of the particle is determined according to the distance between the c position and the d position and the time difference between the C image frame and the D image frame).
  • the hair direction map and the hair region mask map can be obtained from the target video information through the neural network model.
  • the neural network model may be a CNN (Convolutional Neural Network) model or the like.
  • the above embodiment determines the candidate motion state and candidate state change information of the target image frame according to the target video information, and stores this information in the texture image, which belongs to the process of pre-processing the target video, so that the subsequent hair rendering process can be carried out in an orderly manner. .
  • the method further includes: storing the texture image in In the first frame buffer; after the step of updating the motion state in the texture image according to the second target motion state, the method further includes: storing the texture image in the first frame buffer in the second frame buffer Middle; store the updated texture image in the first frame buffer.
  • this embodiment After acquiring the candidate state change information and the candidate motion state, this embodiment stores these two information in the corresponding vertex positions in the texture image for later use.
  • the candidate state change information and the candidate motion state corresponding to the target image frame are obtained from the texture image as the target state change information and the first target motion state, respectively.
  • the texture image is stored in two frame buffers, the first frame buffer and the second frame buffer.
  • the texture image stored in the first frame buffer can be used as output (that is, displayed on the display screen), and the second The texture image stored in the frame buffer can be used as input.
  • the texture image in the first frame buffer is input into the second frame buffer, and then the texture image in the first frame buffer Perform output display of image frames.
  • the first frame buffer and the second frame buffer can also switch between input and output.
  • the texture image in the first frame buffer is output at the current moment, and the second frame buffer is used as the backup of the first frame buffer for storage.
  • the texture image corresponding to the next image frame; at the next moment, the texture image corresponding to the next image frame in the second frame buffer is output, and the first frame buffer is used as the backup of the second frame buffer, and the newly determined next image
  • the texture image corresponding to the frame (the next image of the next image frame) is stored in the first frame buffer.
  • the foregoing embodiment uses double buffering to store the texture image, which can ensure the orderliness of information input and output in the texture image, prevent data loss, and ensure the accuracy of hair rendering.
  • a flow chart of a hair rendering method is provided.
  • the hair rendering method is used in the device shown in FIG. 1, as shown in FIG. 5.
  • the implementation process is as follows:
  • S501 Obtain a hair direction map and a hair region mask map.
  • S502. Use the double frame buffer to read and write particle information.
  • the obtained particle information includes: particle speed, position, rotation posture, current life state, size, hair direction, and the obtained particles
  • the information is stored through two textures, and the texture recording the particle information is stored in the first frame buffer, and the other frame buffer is used to back up the first frame buffer.
  • the process of obtaining it can be: initialize two textures, randomly generate particles on the full screen, if a particle is located in the hair area, write the screen coordinates of the particle into the frame buffer; for the hair direction, according to the hair
  • the cos2t and sin2t stored in the direction map determine the cost and sint, and obtain the hair direction D (cost, sint).
  • the foregoing embodiment uses a GPU to calculate particle information and implements a GPU particle system, which greatly improves the calculation efficiency of the particle system, can achieve real-time on the mobile terminal, and realizes real-time rendering of the hair on the mobile terminal.
  • Fig. 6 is a block diagram of a hair rendering apparatus 600 according to an exemplary embodiment. 6, the device includes an image frame determination unit 601, a texture image acquisition unit 602, a state information acquisition unit 603, a motion state determination unit 604, and a motion state update unit 605.
  • the image frame determination unit 601 is configured to perform acquisition of a target video containing hair information, and select a target image frame from the image frames of the target video;
  • the texture image acquisition unit 602 is configured to perform acquisition of the texture image of the target image frame; wherein the texture image is an image in a texture format that records the motion state and state change information of pixels in the target image frame , The hair area in the texture image is divided into at least one particle area by grid lines;
  • the state information acquiring unit 603 is configured to acquire the first target motion state and target state change information of the first target particle region in the at least one particle region from the texture image;
  • the motion state determining unit 604 is configured to perform determining the second target motion state of the first target particle area in the next image frame according to the first target motion state and the target state change information; the next image Frame is the next image of the target image frame in the target video;
  • the motion state update unit 605 is configured to update the motion state in the texture image according to the second target motion state, so as to render the hair region.
  • the hair rendering device obtained in the above embodiment obtains the texture image of the target image frame according to the target video containing the hair information, and the texture image can be processed by the GPU; the hair area in the texture image is divided into at least one particle area, which can achieve The GPU processes the particle area and greatly simplifies the graphics processing efficiency of the GPU to realize the calculation on the mobile terminal.
  • the first target motion state and target state change information of the target particle area are obtained from the texture image, and the first target state change information is determined accordingly.
  • the motion state in the texture image is updated according to the second target motion state, so as to realize the rendering of the hair area.
  • real-time rendering of the hair area can be realized on the mobile terminal, and the motion state of the specific particle area can be modified at the same time, so that the special rendering effect of particles flowing along the hairline direction can be realized.
  • the motion state update unit is further configured to update the motion state of the first target particle area according to the second target motion state, and retain the motion state of the remaining particle area
  • the remaining particle area is the particle area of the at least one particle area where the first target particle area is removed.
  • the first target motion state includes first screen coordinates
  • the target state change information includes a first speed
  • the motion state determination unit includes: a time difference determination subunit, configured To perform the determination of the time difference between the target image frame and the next image frame
  • the first motion state determination subunit is configured to perform the determination based on the first screen coordinates, the first speed, and the time difference The value determines the second screen coordinates of the first target particle area in the next image frame as the second target motion state.
  • the motion state update unit includes: a particle area determining subunit configured to perform redefining the hair of the texture image if the second screen coordinates are outside the hair area Region, and determine the second target particle region from the particle region corresponding to the newly determined hair region; the state information acquiring subunit is configured to perform acquiring the reference target motion state of the second target particle region from the texture image And reference target state change information; a second motion state determination subunit configured to perform determining that the second target particle area is in the next image frame according to the reference target motion state and the reference target state change information The third target motion state is obtained; the motion state update subunit is configured to execute the update of the motion state in the texture image according to the third target motion state.
  • the first target motion state includes a second speed
  • the target state change information includes a hair direction angle
  • the motion state determination unit includes: a rate acquisition subunit configured to perform acquisition A preset rate; a third motion state determination subunit configured to perform determining that the first target particle area is in the next image frame according to the second speed, the hair direction angle, and the rate To obtain the second target motion state.
  • the hair rendering device further includes: a state change information determining unit configured to perform determining each of the target image frames according to the pixel state information that changes over time in the target video Candidate state change information of the pixel; the image acquisition unit is configured to perform the acquisition of the hair direction map and the hair region mask map corresponding to the target image frame; the hair direction map contains the hair direction of each pixel The hair area mask map contains the mask information of the hair area in the target image frame; the candidate motion state determination unit is configured to perform the calculation based on the hair direction angle in the hair direction map and the hair direction angle.
  • the mask information in the area mask map determines the candidate motion state of each pixel; the candidate motion state storage unit is configured to perform storing the candidate state change information and the candidate motion state in the at least one particle The vertex position of the region; wherein the vertex position of the at least one particle region corresponds to the respective pixel point.
  • the hair rendering device further includes: a first image storage unit configured to execute storing the texture image in the first frame buffer; and an image dumping unit configured to execute The texture image in the first frame buffer is stored in the second frame buffer; the second image storage unit is configured to perform storing the updated texture image in the first frame buffer.
  • the hair rendering device further includes: a region determining unit configured to perform determining the hair region in the texture image; and a region dividing unit configured to perform a predetermined number of particle beams Perform grid division on the hair area to obtain at least one corresponding particle beam; the particle beam division unit is configured to perform grid division on the at least one particle beam according to a predetermined number of particles to obtain the corresponding at least one particle beam. A particle area.
  • the hair rendering device further includes: a particle area determining unit configured to perform determining a particle area at a set position in the at least one particle beam as the first target Particle area.
  • an electronic device is also provided.
  • the schematic structural diagram of the electronic device may be as shown in FIG. 1.
  • the electronic device includes: a processor; a memory for storing executable instructions of the processor;
  • the processor is configured to execute the instructions to implement the hair rendering method described in the foregoing embodiment.
  • non-transitory computer-readable storage medium including instructions, such as the memory 102 including instructions, and the foregoing instructions may be executed by the processor 120 of the device 100 to complete the foregoing method.
  • the non-transitory computer-readable storage medium may be ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
  • a computer program product includes a computer program, the computer program is stored in a readable storage medium, and at least one processor of the device reads from the readable storage medium And execute the computer program, so that the device executes the hair rendering method described in the above embodiment.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Graphics (AREA)
  • Multimedia (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Processing Or Creating Images (AREA)
  • Image Generation (AREA)
  • Studio Devices (AREA)
  • Image Analysis (AREA)

Abstract

一种头发的渲染方法、装置、电子设备及存储介质。该方法包括:获取包含头发信息的目标视频,从目标视频的图像帧中选择目标图像帧;获取目标图像帧的纹理图像;纹理图像为记录目标图像帧中像素点的运动状态和状态变化信息的纹理格式的图像;从纹理图像中获取第一目标粒子区域的第一目标运动状态和目标状态变化信息;根据第一目标运动状态和目标状态变化信息确定第一目标粒子区域在下一图像帧中的第二目标运动状态;根据第二目标运动状态对纹理图像中的运动状态进行更新,以对头发区域进行渲染。该方法能够在移动端实现对头发区域的实时渲染,同时对特定粒子区域的运动状态进行修改,能实现粒子沿发丝方向流动的渲染特效。

Description

头发的渲染方法、装置、电子设备及存储介质
相关申请的交叉引用
本申请基于申请号请202010230272.6,申请日请2020年03月27日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作请参考。
技术领域
本公开涉及图像处理技术领域,尤其涉及头发的渲染方法、装置、电子设备及存储介质。
背景技术
随着网络直播等技术的发展,实时渲染技术在移动端的应用越来越广,例如:在直播过程中对图像、视频中的用户头发进行染发、柔发等渲染处理。
目前是通过PC(个人电脑)端或者服务器端的CPU(中央处理器),对头发区域中的像素点进行颜色替换、模糊等渲染处理。
然而,目前的渲染方法运算量大,CPU对头发粒子信息的处理过程往往较为复杂,无法在移动端中实现实时渲染。而目前通过移动端进行直播的需求不断增加,因此有必要提供一种能够在移动端中对头发进行实时渲染的方法。
发明内容
本公开提供一种头发的渲染方法、方法、装置、电子设备及存储介质,以至少解决相关技术中无法在移动端中对头发进行实时渲染的问题。本公开的技术方案如下:
根据本公开实施例的第一方面,提供一种头发的渲染方法,包括:获取包含头发信息的目标视频,从所述目标视频的图像帧中选择目标图像帧;获取所述目标图像帧的纹理图像,其中,所述纹理图像为记录所述目标图像帧中像素点的运动状态和状态变化信息的纹理格式的图像,所述纹理图像中的头发区域被格网线划分为至少一个粒子区域;从所述纹理图像中获取第一目标粒子区域的第一目标运动状态和目标状态变化信息,其中,所述第一目标粒子区域为所述至少一个粒子区域中的任一区域;根据所述第一目标运动状态和所述目标状态变化信息确定所述第一目标粒子区域在下一图像帧中的第二目标运动状态,其中,所述下一图像帧为所述目标视频中所述目标图像帧的下一帧图像;根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新,以对所述头发区域进行渲染。
可选地,所述根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新的步骤,包括:根据所述第二目标运动状态对所述第一目标粒子区域的运动状态进行更新,并保留剩余粒子区域的运动状态;所述剩余粒子区域为所述至少一个粒子区域中除去所述第一目标粒子区域外的其他粒子区域。
可选地,所述第一目标运动状态包括第一屏幕坐标,所述目标状态变化信息包括第一速度;所述根据所述第一目标运动状态和所述目标状态变化信息确定所述第一目标粒子区域在下一图像帧中的第二目标运动状态的步骤,包括:确定所述目标图像帧和所述下一图像帧间的时间差值;根据所述第一屏幕坐标、所述第一速度和所述时间差值,确定所述第一目标粒子区域在所述下一图像帧中的第二屏幕坐标,作为所述第二目标运动 状态。
可选地,所述根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新的步骤,包括:若所述第二屏幕坐标处于所述头发区域之外,重新确定所述纹理图像的头发区域,并从新确定的头发区域所对应的粒子区域中确定第二目标粒子区域;从所述纹理图像中获取所述第二目标粒子区域的参考目标运动状态和参考目标状态变化信息;根据所述参考目标运动状态和所述参考目标状态变化信息,确定所述第二目标粒子区域在所述下一图像帧中的运动状态,得到第三目标运动状态;根据所述第三目标运动状态对所述纹理图像中的运动状态进行更新。
可选地,所述第一目标运动状态包括第二速度,所述目标状态变化信息包括头发方向角;所述根据所述第一目标运动状态和所述目标状态变化信息确定所述第一目标粒子区域在下一图像帧中的第二目标运动状态的步骤,包括:获取预先设定的速率;根据所述第二速度、所述头发方向角和所述速率,确定所述第一目标粒子区域在所述下一图像帧中的第三速度,得到所述第二目标运动状态。
可选地,在所述获取所述目标图像帧的纹理图像的步骤之前,还包括:根据所述目标视频中随时间变化的像素状态信息,确定所述目标图像帧中各个像素点的候选状态变化信息;获取所述目标图像帧对应的头发方向图和头发区域掩码图;所述头发方向图中包含有所述各个像素点的头发方向角,所述头发区域掩码图中包含有所述目标图像帧中头发区域的掩码信息;根据所述头发方向图中的头发方向角和所述头发区域掩码图中的掩码信息,确定所述各个像素点的候选运动状态;将所述候选状态变化信息和所述候选运动状态存储到所述至少一个粒子区域的顶点位置上;其中,所述至少一个粒子区域的顶点位置与所述各个像素点对应。
可选地,在所述将所述候选状态变化信息和所述候选运动状态存储到所述至少一个粒子区域的顶点位置上的步骤之后,还包括:将所述纹理图像存储到第一帧缓冲中;在所述根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新的步骤之后,还包括:将第一帧缓冲中的纹理图像存储到第二帧缓冲中;将更新后的所述纹理图像存储到所述第一帧缓冲中。
可选地,在所述获取所述目标图像帧的纹理图像的步骤之后,还包括:确定所述纹理图像中的头发区域;根据预先确定的粒子束数量对所述头发区域进行格网划分,得到对应的至少一个粒子束;根据预先确定的粒子数量对所述至少一个粒子束分别进行格网划分,得到对应的至少一个粒子区域。
可选地,在所述从所述纹理图像中获取第一目标粒子区域的第一目标运动状态和目标状态变化信息的步骤之前,还包括:将所述至少一个粒子束中处于设定位置的粒子区域,确定为所述第一目标粒子区域。
根据本公开实施例的第二方面,提供一种头发的渲染装置,包括:图像帧确定单元,被配置为执行获取包含头发信息的目标视频,从所述目标视频的图像帧中选择目标图像帧;纹理图像获取单元,被配置为执行获取所述目标图像帧的纹理图像,其中,所述纹理图像为记录所述目标图像帧中像素点的运动状态和状态变化信息的纹理格式的图像,所述纹理图像中的头发区域被格网线划分为至少一个粒子区域;状态信息获取单元,被配置为执行从所述纹理图像中获取第一目标粒子区域的第一目标运动状态和目标状态变化信息,其中,所述第一目标粒子区域为所述至少一个粒子区域中的任一区域;运动状态确定单元,被配置为执行根据所述第一目标运动状态和所述目标状态变化信息,确定所述第一目标粒子区域在下一图像帧中的第二目标运动状态,其中,所述下一图像帧为所述目标视频中所述目标图像帧的下一帧图像;运动状态更新单元,被配置为执行根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新,以对所述头发 区域进行渲染。
可选地,所述运动状态更新单元,还被配置为执行根据所述第二目标运动状态对所述第一目标粒子区域的运动状态进行更新,并保留剩余粒子区域的运动状态,其中,所述剩余粒子区域为所述至少一个粒子区域中除去所述第一目标粒子区域外的其他粒子区域。
可选地,所述第一目标运动状态包括第一屏幕坐标,所述目标状态变化信息包括第一速度;所述运动状态确定单元,包括:时间差值确定子单元,被配置为执行确定所述目标图像帧和所述下一图像帧间的时间差值;第一运动状态确定子单元,被配置为执行根据所述第一屏幕坐标、所述第一速度和所述时间差值,确定所述第一目标粒子区域在所述下一图像帧中的第二屏幕坐标,作为所述第二目标运动状态。
可选地,所述运动状态更新单元,包括:粒子区域确定子单元,被配置为执行若所述第二屏幕坐标处于所述头发区域之外,重新确定所述纹理图像的头发区域,并从新确定的头发区域所对应的粒子区域中确定第二目标粒子区域;状态信息获取子单元,被配置为执行从所述纹理图像中获取所述第二目标粒子区域的参考目标运动状态和参考目标状态变化信息;第二运动状态确定子单元,被配置为执行根据所述参考目标运动状态和所述参考目标状态变化信息,确定所述第二目标粒子区域在所述下一图像帧中的运动状态,得到第三目标运动状态;运动状态更新子单元,被配置为执行根据所述第三目标运动状态对所述纹理图像中的运动状态进行更新。
可选地,所述第一目标运动状态包括第二速度,所述目标状态变化信息包括头发方向角;所述运动状态确定单元,包括:速率获取子单元,被配置为执行获取预先设定的速率;第三运动状态确定子单元,被配置为执行根据所述第二速度、所述头发方向角和所述速率,确定所述第一目标粒子区域在所述下一图像帧中的第三速度,得到所述第二目标运动状态。
可选地,所述头发的渲染装置,还包括:状态变化信息确定单元,被配置为执行根据所述目标视频中随时间变化的像素状态信息,确定所述目标图像帧中各个像素点的候选状态变化信息;图像获取单元,被配置为执行获取所述目标图像帧对应的头发方向图和头发区域掩码图;所述头发方向图中包含有所述各个像素点的头发方向角,所述头发区域掩码图中包含有所述目标图像帧中头发区域的掩码信息;候选运动状态确定单元,被配置为执行根据所述头发方向图中的头发方向角和所述头发区域掩码图中的掩码信息,确定所述各个像素点的候选运动状态;候选运动状态存储单元,被配置为执行将所述候选状态变化信息和所述候选运动状态存储到所述至少一个粒子区域的顶点位置上;其中,所述至少一个粒子区域的顶点位置与所述各个像素点对应。
可选地,所述头发的渲染装置,还包括:第一图像存储单元,被配置为执行将所述纹理图像存储到第一帧缓冲中;图像转存单元,被配置为执行将第一帧缓冲中的纹理图像存储到第二帧缓冲中;第二图像存储单元,被配置为执行将更新后的所述纹理图像存储到所述第一帧缓冲中。
可选地,所述头发的渲染装置还包括:区域确定单元,被配置为执行确定所述纹理图像中的头发区域;区域划分单元,被配置为执行根据预先确定的粒子束数量对所述头发区域进行格网划分,得到对应的至少一个粒子束;粒子束划分单元,被配置为执行根据预先确定的粒子数量对所述至少一个粒子束分别进行格网划分,得到对应的至少一个粒子区域。
可选地,所述头发的渲染装置,还包括:粒子区域确定单元,被配置为执行将所述至少一个粒子束中处于设定位置的粒子区域,确定为所述第一目标粒子区域。
根据本公开实施例的第三方面,提供一种电子设备,包括处理器;用于存储所述处 理器可执行指令的存储器;其中,所述处理器被配置为执行所述指令,以实现如上所述的头发的渲染方法。
根据本公开实施例的第四方面,提供一种存储介质,当所述存储介质中的指令由电子设备的处理器执行时,使得所述电子设备能够执行如上所述的头发的渲染方法。
根据本公开实施例的第五方面,提供一种计算机程序产品,所述程序产品包括计算机程序,所述计算机程序存储在可读存储介质中,设备的至少一个处理器从所述可读存储介质读取并执行所述计算机程序,使得设备执行如上实施例中所述的头发的渲染方法。
本公开的实施例提供的技术方案至少带来以下有益效果:根据包含头发信息的目标视频获取目标图像帧的纹理图像,该纹理图像能够被GPU处理;该纹理图像中的头发区域被划分为至少一个粒子区域,能实现GPU对粒子区域的处理,同时极大简化GPU的图形处理效率,实现在移动端的运算;另外,从纹理图像中获取目标粒子区域的第一目标运动状态和目标状态变化信息,据此确定第一目标粒子区域在下一图像帧中的第二目标运动状态,根据第二目标运动状态对纹理图像中的运动状态进行更新,以实现对头发区域的渲染。根据本公开的上述技术方案能够在移动端实现对头发区域的实时渲染,同时对特定粒子区域的运动状态进行修改,能实现粒子沿发丝方向流动的渲染特效。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本公开。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理,并不构成对本公开的不当限定。
图1是根据一示例性实施例示出的一种头发的渲染方法的应用环境图。
图2是根据一示例性实施例示出的一种头发的渲染方法的流程图。
图3是根据一示例性实施例示出的粒子束的结构示意图。
图4是根据一示例性实施例示出的头发渲染的显示示意图。
图5是根据另一示例性实施例示出的一种头发的渲染方法的流程图。
图6是根据一示例性实施例示出的一种头发的渲染装置的框图。
具体实施方式
为了使本领域普通人员更好地理解本公开的技术方案,下面将结合附图,对本公开实施例中的技术方案进行清楚、完整地描述。
需要说明的是,本公开的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本公开的实施例能够以除了在这里图示或描述的那些以外的顺序实施。以下示例性实施例中所描述的实施方式并不代表与本公开相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本公开的一些方面相一致的装置和方法的例子。
本公开所提供的头发的渲染方法,可以应用于如图1所示的设备100中。设备100可以是移动端,如:移动电话、计算机、数字广播终端、消息收发设备、游戏控制台、平板设备、医疗设备、健身设备、个人数字助理等。
参照图1,设备100可以包括以下一个或多个组件:处理组件101、存储器102、电源组件103、多媒体组件104、音频组件105、输入/输出(I/O)的接口106、传感器组件107以及通信组件108。对这些组件详细说明如下:
处理组件101通常控制设备100的整体操作,诸如与显示、电话呼叫、数据通信、相机操作和记录操作相关联的操作。处理组件101可以包括一个或多个处理器109来执行指令,以完成上述的方法的全部或部分步骤。此外,处理组件101可以包括一个或多个模块,便于处理组件101和其他组件之间的交互。例如,处理组件101可以包括多媒体模块,以方便多媒体组件104和处理组件101之间的交互。
存储器102被配置为存储各种类型的数据以支持在设备100的操作。这些数据的示例包括用于在设备100上操作的任何应用程序或方法的指令、联系人数据、电话簿数据、消息、图片、视频等。存储器102可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM)、电可擦除可编程只读存储器(EEPROM)、可擦除可编程只读存储器(EPROM)、可编程只读存储器(PROM)、只读存储器(ROM)、磁存储器、快闪存储器、磁盘或光盘。
电源组件103为设备100的各种组件提供电力。电源组件103可以包括电源管理系统,一个或多个电源,及其他与为设备100生成、管理和分配电力相关联的组件。
多媒体组件104包括在所述设备100和用户之间的提供一个输出接口的屏幕。在一些实施例中,屏幕可以包括液晶显示器(LCD)和触摸面板(TP)。如果屏幕包括触摸面板,屏幕可以被实现为触摸屏,以接收来自用户的输入信号。触摸面板包括一个或多个触摸传感器以感测触摸、滑动和触摸面板上的手势。所述触摸传感器可以不仅感测触摸或滑动动作的边界,而且还检测与所述触摸或滑动操作相关的持续时间和压力。在一些实施例中,多媒体组件104包括一个前置摄像头和/或后置摄像头。当设备100处于操作模式,如拍摄模式或视频模式时,前置摄像头和/或后置摄像头可以接收外部的多媒体数据。每个前置摄像头和后置摄像头可以是一个固定的光学透镜系统或具有焦距和光学变焦能力。
音频组件105被配置为输出和/或输入音频信号。例如,音频组件105包括一个麦克风(MIC),当设备100处于操作模式,如呼叫模式、记录模式和语音识别模式时,麦克风被配置为接收外部音频信号。所接收的音频信号可以被进一步存储在存储器102或经由通信组件108发送。在一些实施例中,音频组件105还包括一个扬声器,用于输出音频信号。
I/O接口106为处理组件101和外围接口模块之间提供接口,上述外围接口模块可以是键盘,点击轮,按钮等。这些按钮可包括但不限于:主页按钮、音量按钮、启动按钮和锁定按钮。
传感器组件107包括一个或多个传感器,用于为设备100提供各个方面的状态评估。例如,传感器组件107可以检测到设备100的打开/关闭状态,组件的相对定位,例如所述组件为设备100的显示器和小键盘,传感器组件107还可以检测设备100或设备100一个组件的位置改变,用户与设备100接触的存在或不存在,设备100方位或加速/减速和设备100的温度变化。传感器组件107可以包括接近传感器,被配置用来在没有任何的物理接触时检测附近物体的存在。传感器组件107还可以包括光传感器,如CMOS或CCD图像传感器,用于在成像应用中使用。在一些实施例中,该传感器组件107还可以包括加速度传感器、陀螺仪传感器、磁传感器、压力传感器或温度传感器。
通信组件108被配置为便于设备100和其他设备之间有线或无线方式的通信。设备100可以接入基于通信标准的无线网络,如WiFi,运营商网络(如2G、3G、4G或5G),或它们的组合。在一个示例性实施例中,通信组件108经由广播信道接收来自外部广播管理系统的广播信号或广播相关信息。在一个示例性实施例中,所述通信组件108还包括近场通信(NFC)模块,以促进短程通信。例如,在NFC模块可基于射频识别(RFID)技术,红外数据协会(IrDA)技术,超宽带(UWB)技术,蓝牙(BT)技术和 其他技术来实现。
在一示例性实施例中,设备100可以被一个或多个应用专用集成电路(ASIC)、数字信号处理器(DSP)、数字信号处理设备(DSPD)、可编程逻辑器件(PLD)、现场可编程门阵列(FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述方法。
图2是根据一示例性实施例示出的一种头发的渲染方法的流程图,头发的渲染方法可以用于如图1所示的设备100中(也可以具体用于图1中的处理器109中,更具体的,还可以应用于设备100的GPU中),如图2所示,包括以下步骤S201/S202/S203/S204/S205,详细说明如下:
在步骤S201中,获取包含头发信息的目标视频,从所述目标视频的图像帧中选择目标图像帧。
其中,目标视频可以是通过拍摄设备对人体(也可以是动物体)头部进行采集得到的视频。拍摄设备可以为设备100上的传感器组件107,也可以是与设备100存在网络连接关系的摄像头。目标视频中所包含的头发信息可以指头发区域所在位置、头发区域大小、头发区域实时位置、头发颜色、发丝长度、发丝方向等等信息。
摄像头可以拍摄设定时间段的包含有头发信息的目标视频,并将拍摄得到的目标视频发送给设备100(或者直接发给设备100的处理器),由处理器进行头发渲染。更进一步的,摄像头可以预先拍摄目标视频,将拍摄好的目标视频一起发送给设备100;也可以是在拍摄过程中实时向处理器发送目标视频。
进一步的,目标视频的各个时序上对应有图像帧,设备100在一次的头发渲染程序中可以对其中的某个或某些图像帧进行头发渲染处理,所述某个或某些图像帧可以理解为目标图像帧。其中,目标图像帧可以是从目标视频中随机选择的图像帧,也可以是按时间顺序选择的相互连续的若干个图像帧。
在步骤S202中,获取所述目标图像帧的纹理图像,其中,所述纹理图像为记录所述目标图像帧中像素点的运动状态和状态变化信息的纹理格式的图像,所述纹理图像中的头发区域被格网线划分为至少一个粒子区域。
其中,纹理格式是能被GPU所识别的像素格式,本公开实施例中的纹理图像即为纹理格式的图像,进一步的,纹理图像也可以直接简称为“纹理”,可以是half float(半浮点)或者float(浮点)型纹理图。
本步骤获取目标图像帧的纹理图像,由设备100中的GPU来对该纹理图像进行处理。可以根据目标图像帧中的各个像素点的颜色来确定纹理图像中的头发区域,例如:将面积大于设定值的黑色区域确定为头发区域,进而在纹理图像对应的网格中填充相应的信息,以在纹理图像中表征头发区域。当然,确定头发区域的过程也可以通过机器学习的方式来实现,例如:将多个包含头发信息的视频输入到预先构建的神经网络模型中,同时向该神经网络模型中输入各个视频各个图像帧对应的头发区域信息,该神经网络模型通过输入的信息进行自学习并完成训练过程,训练结束后将摄像头拍摄的目标视频输入到神经网络模型中,神经网络模型就能自动输出该目标视频中各个图像帧的头发区域。
进一步的,纹理图像中的头发区域被划分为至少一个粒子区域(在某些情况下还可以对头发区域外的其他区域也进行格网划分,得到对应的粒子区域),该粒子区域可以由设备100在获取到纹理图像后划分得到,也可以由设备100的外接设备或者设备100中处理器以外的其他组件划分得到(例如可以由设备100上的传感器组件划分得到)。更进一步地,可以按照设定数量的格网线对纹理图像对应的头发区域进行划分,根据划分得到的格网确定粒子区域;也可以根据发丝的分布来对纹理图像进行划分,例如,将 各个发束(发丝之间的距离足够小)确定为粒子区域。另外,纹理图像中的粒子区域数量可以根据实际情况确定,在需要对头发区域进行更为准确的渲染时则粒子区域数量可以为一个较大的值,在需要对头发区域进行更为粗略的渲染时则粒子区域数量可以为一个较小的值。
进一步的,目标图像帧可以为设备100显示屏中显示的图像帧,即纹理图像记录显示屏当前显示的图像帧的粒子信息,该粒子信息为目标图像帧中各个像素点(每个像素点都可以有对应的粒子区域)的运动状态和状态变化信息。其中,运动状态为粒子在对应图像帧中所处的状态,可以是位置信息、速度信息(包括速率和方向)、头发方向角、尺寸等;而状态变化信息可以指对该粒子的状态变化进行描述的信息,能够表征该粒子在接下来的相邻图像帧中的运动状态,可以为速度、头发方向角、旋转方向、生命周期等。需要说明的是,某些粒子信息既可以为运动状态也可以为状态变化信息,例如,速度既可以表征某一图像帧的速率和方向信息(此时可以作为运动状态),也可以表征该图像帧的移动状态(此时可以作为状态变化信息,它可以结合时间信息确定粒子的移动距离,进而确定粒子的位置坐标)。具体的,在需要计算粒子在下一图像帧中的位置时,速度是可以评价粒子的在下一时刻的位置的,此时位置信息可以作为运动状态而速度可以作为状态变化信息;在需要计算粒子在下一图像帧中的速度时,速率是可以评价粒子的在下一时刻的速度,此时速度可以作为运动状态而速率可以作为状态变化信息,上述情况中速度既作为运动状态又作为状态变化信息。
在一示例性实施例中,由于纹理图像中的存储通道有限,如果一张纹理图像不足以存储运动状态或状态变化信息,则可以通过两张纹理图像来存储。例如,对于仅有4个通道的纹理图像,可以通过两张纹理图像来存储位置信息、速度信息(包括速率和方向)、头发方向角、旋转方向、生命周期、尺寸这些维度的信息。
在步骤S203中,从所述纹理图像中获取第一目标粒子区域的第一目标运动状态和目标状态变化信息,其中,所述第一目标粒子区域为所述至少一个粒子区域中的任一区域。
其中,纹理图像中各个粒子可以有各自的编号,而各个粒子的粒子信息存储在纹理图像的各个粒子区域中。目标粒子区域可以从纹理图像的各个粒子区域中随机选择,也可以按照特定的规则选择(例如:选择特定位置的粒子区域)。进一步地,通过目标粒子区域中记录的粒子信息就可以得到对应的目标运动状态和状态变化信息,即得到第一目标运动状态和目标状态变化信息。
S203的具体实现过程可以为:从所述纹理图像中获取所述目标粒子的屏幕坐标、速度、方向角、旋转姿态、当前生命状态、生命周期、尺寸中的至少一项,根据所获取的信息得到第一目标运动状态和所目标状态变化信息(可以根据当前所要更新的运动状态确定对应的目标状态变化信息)。
在一示例性实施例中,在所述获取所述目标图像帧的纹理图像的步骤之后,还包括:确定所述纹理图像中的头发区域;根据预先确定的粒子束数量对所述头发区域进行格网划分,得到对应的至少一个粒子束;根据预先确定的粒子数量对所述至少一个粒子束分别进行格网划分,得到对应的至少一个粒子区域。
其中,粒子束数量用于表征头发区域中所包含粒子束的数量,该数量可以根据屏幕分辨率、渲染精细度等确定;粒子数量用于表征粒子束中所包含粒子区域的数量,该数量也可以根据屏幕分辨率、渲染精细度等确定。进一步地,在获知数量之后,可以按照等间隔(当然,间隔也可以不等)的格网线对头发区域或者粒子束进行划分,同时,可以进行横向划分,也可以纵向划分,还可以是横向和纵向结合(既进行横向划分又进行纵向划分,此时横向和纵向的划分间隔可以相同也可以不同),还可以是按照与屏幕水 平线呈一定的角度(例如30°)的线进行划分。
纹理图像的示意图可以如图3所示,图3左侧示出了一个女孩的头部轮廓,该头部轮廓包括头发轮廓(粗实线)和脸庞轮廓(细实线),这两种轮廓分别构成头发区域301和脸庞区域302。进一步的,头发区域被划分为多个粒子束,如图3中由粗虚线围成的一个方格区域303可以理解为一个粒子束。进一步的,这些粒子束还被划分为多个小区域,这些小区域可以称为第一目标粒子区域304(也可以称为头发粒子或者粒子,其具体划分情况可以参见图3右侧的放大图)。
需要说明的是,图3是对整个纹理图像都进行了格网划分,在实际的应用场景中,可以仅对头发区域(或者仅对头发区域和脸庞区域)进行划分。进一步的,一个视频中包含多个帧,而由于头部位置可能发生变化,每个帧中的头发区域也会发生变化,因此,在获取到一个纹理图像后,都可以重新确定头发区域并对头发区域进行格网划分。
在一示例性实施例中,在所述从所述纹理图像中获取所述至少一个粒子区域中第一目标粒子区域的第一目标运动状态和目标状态变化信息的步骤之前,还包括:将所述至少一个粒子束中处于设定位置的粒子区域,确定为所述第一目标粒子区域。
其中,设定位置可以是某一粒子束中处于居中位置、头部位置(第一个编号所在的位置)、尾部位置(最后一个编号所在的位置)等的粒子区域。
进一步的,本公开实施例从粒子束的多个粒子区域中选择出目标粒子区域(如图3中的304),其选择方式可以为随机选取,也可以是选择居中或者边缘位置的粒子作为目标粒子区域,在一些示例性实施例中,目标粒子区域也可以称为头部粒子(该粒子在渲染过程中起到了带动其他粒子移动的作用)。另一方面,同一纹理图像中不同粒子束中选择目标粒子的方法可以一致,也可以不一致,以不一致的情况为例,其实现方式可以具体如下:某一粒子束中选择一个处于边缘位置的粒子区域作为目标粒子区域,而在另一粒子束中可以选择位于居中位置的粒子区域作为目标粒子区域。另外,一个粒子束对应的目标粒子区域的数量可以为一个、两个也可以为多个,进一步的,目标粒子区域可以为头发区域中所有粒子束中所选择的目标粒子区域,也可以是部分或者某个粒子束中所选择的目标粒子区域。对纹理图像中的头发区域进行划分,能对其中的特定粒子区域进行运动状态更新,使得这些粒子区域在最终显示的视频中呈现逐步变化的状态,达到粒子沿发丝方向流动的渲染特效。
在步骤S204中,根据所述第一目标运动状态和所述目标状态变化信息,确定所述第一目标粒子区域在下一图像帧中的第二目标运动状态,其中,所述下一图像帧为所述目标视频中所述目标图像帧的下一帧图像。
其中,下一图像帧为目标图像帧在下一时刻的图像帧,该“下一时刻”中的时刻可以根据帧取样率来确定,以1min包含有60个图像帧[每秒(s)一个图像帧]为例,如果帧取样率为5s/帧,则下一图像帧与目标图像帧中间相隔4个图像帧,而如果帧取样率为1s/帧,则下一图像帧与目标图像帧中间相隔0个图像帧(即两者相邻)。因此,可以根据实际情况调整图像帧的选择,例如,对渲染精细度要求高,则帧取样率可以取一个高的值(此时需要对更多图像帧进行处理),而如果对渲染精细度要求低,则帧取样率可以取一个低的值。
第一目标运动状态表征的是第一目标粒子区域在目标图像帧中的运动状态,而目标状态变化信息表征的是第一目标粒子区域在目标图像帧中对状态变化产生的影响,因此,将两者相互结合,就能获知第一目标粒子区域在下一图像帧的运动状态,即得到第二目标运动状态。例如,纹理图像中包含以下粒子信息:第一目标粒子区域的位置坐标为(2,2),其速度方向为屏幕水平线(可以记为x轴)正方向36.87°,速度值为5mm/s,其中位置坐标为第一目标运动状态,速度方向和速度值为目标状态变化信息, 根据上述信息可以确定第一目标粒子区域从目标图像帧到下一图像帧(以目标图像帧和下一图像帧相隔时间为1s为例)在x轴正方向运动了3mm,在y轴方向运动了4mm,因此,可以确定第一目标粒子区域在下一图像帧的位置坐标为(5,6),即得到了第二目标运动状态。
在步骤S205中,根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新,以对所述头发区域进行渲染。
对纹理图像中的运动状态进行更新可以理解为直接将纹理图像中的第一目标运动状态替换为第二目标运动状态。
设备100的显示屏中刚开始时根据纹理图像显示目标图像帧,在对纹理图像进行更新后,可以在显示屏中显示对应的下一图像帧,此时屏幕中第一目标粒子区域的运动状态就会从第一目标运动状态变化为第二目标运动状态,即实现了对头发区域中特定粒子在流动的渲染效果。
进一步的,完成了目标图像帧和下一图像帧的切换即可以认为完成了一次头发区域的渲染。接下来,可以继续进行新的渲染。
上述头发的渲染方法中,根据包含头发信息的目标视频获取目标图像帧的纹理图像,该纹理图像能够被GPU处理;该纹理图像中的头发区域被划分为至少一个粒子区域,能实现GPU对粒子区域的处理,同时极大简化GPU的图形处理效率,实现在移动端的运算;另外,从纹理图像中获取目标粒子区域的第一目标运动状态和目标状态变化信息,据此确定第一目标粒子区域在下一图像帧中的第二目标运动状态,根据第二目标运动状态对纹理图像中的运动状态进行更新,以实现对头发区域的渲染。根据本公开的上述技术方案能够在移动端实现对头发区域的实时渲染,同时对特定粒子区域的运动状态进行修改,能实现粒子沿发丝方向流动的渲染特效。
在一示例性实施例中,所述根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新的步骤,包括:根据所述第二目标运动状态对所述第一目标粒子区域的运动状态进行更新,并保留剩余粒子区域(也可以称为尾部粒子区域或者尾部粒子)的运动状态;所述剩余粒子区域为所述至少一个粒子区域中除去所述第一目标粒子区域的粒子区域。
如图3中303的放大图所示,粒子束中除去第一目标粒子区域304的全部或部分粒子可以认为是剩余粒子区域,如图3中的305所示。在一示例性实施例中,确定第一目标粒子区域和剩余粒子区域的过程可以如下:设存储粒子信息的纹理图像的分辨率为W*H,粒子在W、H方向分布分别为m、n个,则总粒子数量为m*n,其中m<=W,n<=H;设每一粒子束由K个粒子构成,把H方向划分为n/K个格子,则每个格子存储一束粒子的信息。将每个格子划分为K个子区间k(i),其中i取值范围是0~K-1,其中,k(0)为粒子束的目标粒子(即头部粒子),而k(1)~k(K-1)为粒子束的剩余粒子(即尾部粒子)。其中,W/H/m/n/K/k的数值大小可以根据实际情况确定。
在本实施例中,剩余粒子区域在下一图像帧中的运动状态直接采用目标图像帧的运动状态,而第一目标粒子区域的运动状态则被实时更新,基于此,显示屏中的显示状态即为:第一目标粒子区域的状态发生变化而剩余粒子区域的状态不发生变化。通过这样的方式,在显示目标图像帧后显示下一图像帧,就能够形成“拖尾”效果,这在游戏等需要形成“拖尾”效果的场景中具有较高的适用性。如图4所示,目标图像帧的头发区域的显示示意图可以如图4(a)所示(显示时可以不显示格网线),可以看清楚发丝的状态;经过渲染处理后,有拖尾渲染效果的头发区域可以如图4(b)所示,图4(b)中灰色区域401可以为第一目标粒子区域,第一目标粒子区域在帧切换的过程中由于运动而发丝模糊,而其他区域的粒子状态不变则仍能看清楚发丝,这样就实现了粒子束沿 着发丝方向流动以及“拖尾”的渲染特效。
在一示例性实施例中,剩余粒子区域在下一图像帧中的运动状态也可以不采用目标图像帧中对应的参考剩余运动状态,而是按照第二目标运动状态的确定方法得到候选剩余运动状态,确定候选剩余运动状态和参考剩余运动状态之间的差值,将该差值乘以一定比例(例如:30%)后与参考剩余运动状态求和得到剩余粒子区域在下一图像帧中的运动状态,这样的处理方式能使得在渲染过程中剩余粒子也会发生状态变化但其变化幅度没有目标粒子大,能够产生“拖尾”效果同时头发的流动性更为自然。
进一步的,在一示例性实施例中,还可以根据场景需要对目标粒子区域或者剩余粒子区域进行颜色渲染(例如:将黑色的粒子换成金色的粒子)等操作。
在一示例性实施例中,所述第一目标运动状态包括第一屏幕坐标,所述目标状态变化信息包括第一速度;所述根据所述第一目标运动状态和所述目标状态变化信息确定所述第一目标粒子区域在下一图像帧中的第二目标运动状态的步骤,包括:确定所述目标图像帧和所述下一图像帧的时间差值;根据所述第一屏幕坐标、所述第一速度和所述时间差值确定所述第一目标粒子区域在所述下一图像帧中的第二屏幕坐标,作为所述第二目标运动状态。
其中,目标图像帧和下一图像帧的时间差值可以根据前述实施例的帧取样率确定,进一步的,可以按视频特效的整体帧率来确定,比如某app产品设定的特效帧率为30fps,则相邻图像帧之间的时间差值(delta_t)约等于1000/30=33ms,如果目标图像帧和下一图像帧为相邻图像帧,则两者的时间差值为33ms。
屏幕坐标可以理解为第一目标粒子区域的顶点在设备100显示屏中的位置坐标。
进一步的,对第一目标粒子区域的屏幕坐标进行更新可以是第一目标粒子区域的顶点位置进行更新,而其他位置不更新。
本实施例根据第一屏幕坐标、第一速度和时间差值确定第一目标粒子区域在下一图像帧中的第二屏幕坐标,将第二屏幕坐标作为第二目标运动状态。运动状态的确定过程简单,能有效提高头发区域渲染的效率,实现在移动端的实时渲染。
进一步的,在一示例性实施例中,所述根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新的步骤,包括:若所述第二屏幕坐标处于所述头发区域之外,重新确定所述纹理图像的头发区域,并从新确定的头发区域所对应的粒子区域中确定第二目标粒子区域;从所述纹理图像中获取所述第二目标粒子区域的参考目标运动状态和参考目标状态变化信息;根据所述参考目标运动状态和所述参考目标状态变化信息确定所述第二目标粒子区域在所述下一图像帧中的运动状态,得到第三目标运动状态;根据所述第三目标运动状态对所述纹理图像中的运动状态进行更新。
其中,可以将第二屏幕坐标与头发区域中各个粒子区域的坐标进行比对,如果均不匹配,则可以认为第一屏幕坐标处于头发区域之外。
“根据所述参考目标运动状态和所述参考目标状态变化信息确定所述第二目标粒子区域在所述下一图像帧中的运动状态,得到第三目标运动状态”可以参照前述实施例中“根据所述第一目标运动状态和所述目标状态变化信息确定所述第一目标粒子区域在下一图像帧中的第二目标运动状态”的过程,“根据所述第三目标运动状态对所述纹理图像中的运动状态进行更新”可以参照前述实施例中“根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新,以对所述头发区域进行渲染”的过程,本实施例对此不再赘述。
本实施例在确定目标粒子位于目标图像帧对应的头发区域之外时,重新确定目标粒子的运动状态(即第三目标运动状态),并根据第三目标运动状态对纹理图像进行更新,能保证显示屏中显示的头发区域的连贯性,不会出现头发区域突然变形的问题,保 证良好的头发显示效果。
在一示例性实施例中,如果第三目标运动状态对应的屏幕坐标依旧位于头发区域之外,则可以继续根据第三目标运动状态和第三目标状态变化信息确定新的运动状态,以此类推,直到所确定的屏幕坐标位于头发区域内。当然,在某些情况下,所确定的屏幕坐标(包括前述第二屏幕坐标)位于头发区域之外但与头发区域边缘之间的距离小于预设的阈值(阈值大小可以根据实际情况确定,本公开对此不做限制),也可以不重新确定运动状态,而是直接根据第二目标运动状态对纹理图像进行更新,这样的处理方式能在保证良好的头发显示效果的同时有效减少运算量。
在一示例性实施例中,所述第一目标运动状态包括第二速度,所述目标状态变化信息包括头发方向角;所述根据所述第一目标运动状态和所述目标状态变化信息确定所述第一目标粒子区域在下一图像帧中的第二目标运动状态的步骤,包括:获取预先设定的速率;根据所述第二速度、所述头发方向角和所述速率确定所述第一目标粒子区域在所述下一图像帧中的第三速度,得到所述第二目标运动状态。
需要说明的是,第一速度和第二速度都是从同一纹理图像中某一通道获取的速度信息,它们的大小可以一致。在对屏幕坐标进行更新时,要根据速度来对粒子的屏幕坐标进行更新时,速度是作为状态变化信息的;在对速度进行更新时,速度是作为运动状态的。
其中,速率可以也可以称为速度标量,用来控制粒子的流速,可以由用户预先设定,也可以是通过一定的算法(例如:随着时间变化速度标量逐步变小)确定。
头发方向角可以指第一目标粒子区域的速度相对于屏幕水平线x轴正方向的角度,可以理解为第一目标粒子区域的运动方向,可以通过D(cost,sint)来表示,其中,t表示目标粒子相对于x轴正方向的角度,而cost和sint分别表示第一目标粒子区域的移动距离在x轴和y轴方向上的距离分量。
进一步的,第三速度可以通过以下公式来进行计算:
第三速度=第二速度+头发方向角*速率
其中,第二速度中包含有速度值和方向角。因此,“第二速度”和“头发方向角*速率”求和,不仅包含速度值的求和,因此还可以包括方向角的融合。
在另一示例性实施例中,也可以不结合第二速度来确定第三速度,而是直接将头发方向角和速率的乘积作为第三速度,具体的计算公式可以如下:
第三速度v(u,v)=D(cost,sint)*V,其中,D(cost,sint)为头发方向角,V为用户定义的速率。这样的处理方式使得第一目标粒子区域的速度可以由设备100来控制,能根据用户的需要来控制发丝的流速,起到更个性化的头发特效显示效果。
上述实施例根据方向角和速率来确定下一图像帧的速度信息,确定过程简单,能有效提高运算效率,实现在移动端的实时渲染。
在一示例性实施例中,在所述获取所述目标图像帧的纹理图像的步骤之前,还包括:根据所述目标视频中随时间变化的像素状态信息,确定所述目标图像帧中各个像素点的候选状态变化信息;获取所述目标图像帧对应的头发方向图和头发区域掩码图;所述头发方向图中包含有所述各个像素点的头发方向角,所述头发区域掩码图中包含有所述目标图像帧中头发区域的掩码信息;根据所述头发方向图中的头发方向角和所述头发区域掩码图中的掩码信息确定所述各个像素点的候选运动状态;将所述候选状态变化信息和所述候选运动状态存储到所述至少一个粒子区域的顶点位置上;其中,所述至少一个粒子区域的顶点位置与所述各个像素点对应。
其中,像素状态信息可以指视频中各个像素点的颜色、位置等状态信息以及像素点之间的状态随时间的变化关系(例如,在某一帧中,某一像素点P1为纯黑色,而在下 一帧中,其相邻像素点P2变为纯黑色,像素点P1则变为其他颜色)。粒子可能对应有一个或多个像素点(粒子与像素点之间存在映射关系),根据对应像素点的像素状态信息,可以确定出各个粒子的状态变化信息(如:移动速度等),得到候选状态变化信息。
头发方向角为发丝的方向,各个粒子的头发方向角t对应的排列在一起即形成头发方向图;在其他实施例中,头发方向图中还可以存储可以cos2t和sin2t的值(存储2t角的正弦和余弦值是为了防止头发方向在同一条直线上的歧义性),在需要对头发方向角进行处理时可以通过以下公式分别确定cost和sint:
cost=sqrt((1+cos2t)/2)*sign(sin2t);
sint=sqrt(1-cost^2)
其中,sign表示符号函数。
进一步的,t可以通过以下方式确定:Sa.计算目标图像帧的灰度图;Sb.计算灰度图的梯度图;Sc.对梯度图进行模糊处理;Sd.取Sc的垂直矢量每个像素的方向矢量,得到t。
掩码是一串二进制代码,对目标字段进行位与运算,头发区域的掩码信息可以表征各个粒子是否处于头发区域中,各个粒子的掩码信息排列在一起即形成头发区域掩码图。
根据某一图像帧的头发方向图中的头发方向角可以得到各个粒子的方向角,而根据某一图像帧的头发区域掩码图可以得到各个粒子的位置信息、尺寸等,进一步的,结合相邻图像帧的头发方向图可以获知各个粒子的旋转方向,结合相邻图像帧的头发区域掩码图可以获知各个粒子的生命周期(例如:确定某一粒子在A图像帧产生,在B图像帧消失,则可以将A和B之间相差的帧数作为该粒子的生命周期)、速度信息(例如,某个粒子在C图像帧中处于c位置,而在D图像帧中处于d位置,可以根据c位置和d位置之间的距离以及C图像帧和D图像帧之间相差的时间确定该粒子的速度信息)。
另外,可以通过神经网络模型从目标视频信息中获取头发方向图和头发区域掩码图。该神经网络模型可以是CNN(卷积神经网络)模型等。
上述实施例根据目标视频信息确定目标图像帧的候选运动状态和候选状态变化信息,并将这些信息存储到纹理图像中,属于对目标视频进行预先处理的过程,以便后续头发渲染过程的有序进行。
在一示例性实施例中,在所述将所述候选状态变化信息和所述候选运动状态存储到所述至少一个粒子区域的顶点位置上的步骤之后,还包括:将所述纹理图像存储到第一帧缓冲中;在所述根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新的步骤之后,还包括:将第一帧缓冲中的纹理图像存储到第二帧缓冲中;将更新后的所述纹理图像存储到所述第一帧缓冲中。
在获取到候选状态变化信息和候选运动状态后,本实施例将这两个信息存储到纹理图像中对应的顶点位置上备用。在需要对头发进行渲染时,从纹理图像中获取目标图像帧对应的候选状态变化信息和候选运动状态,分别作为目标状态变化信息和第一目标运动状态。
本实施例通过第一帧缓冲和第二帧缓冲这两个帧缓冲来存储纹理图像,其中,第一帧缓冲中存储的纹理图像可以是作为输出(即在显示屏中进行显示),第二帧缓冲中存储的纹理图像可以是作为输入,例如,在需要进行图像帧的显示时,将第一帧缓冲中的纹理图像输入到第二帧缓冲中,进而根据第一帧缓冲中的纹理图像进行图像帧的输出显示。
另外,第一帧缓冲和第二帧缓冲也可以进行输入和输出的切换,例如,在当前时刻 输出第一帧缓冲中的纹理图像,将第二帧缓冲作为第一帧缓冲的备份用于存储下一图像帧对应的纹理图像;在下一时刻,输出第二帧缓冲中下一图像帧对应的纹理图像,并将第一帧缓冲作为第二帧缓冲的备份,将新确定的下下一图像帧(下一图像帧的下一帧图像)对应的纹理图像存储到第一帧缓冲中。
上述实施例通过双缓冲来对纹理图像进行存储,能保证纹理图像中的信息输入和输出的有序性,防止出现数据的丢失,保证头发渲染的准确性。
在一示例性实施例中,提供一种头发的渲染方法的流程图,头发的渲染方法用于如图1所示的设备中,如图5所示,其实现过程如下:
S501、获取头发方向图&头发区域掩码图。
S502、利用双重帧缓冲来读写粒子信息。从头发方向图&头发区域掩码图中获取目标图像帧的粒子信息,所获取的粒子信息包括:粒子的速度、位置、旋转姿态、当前生命状态、尺寸、发丝方向,将所获取的粒子信息通过两张纹理进行存储,并将记录有粒子信息的纹理存储到第一帧缓冲中,另一帧缓冲用于对第一帧缓冲进行备份。例如,对于位置,其获取过程可以为:初始化两张纹理,在全屏幕随机生成粒子,如果某粒子位于头发区域内,则把该粒子的屏幕坐标写入帧缓冲;对于发丝方向,根据头发方向图存储的cos2t和sin2t确定cost和sint,得到发丝方向D(cost,sint)。
S503、更新目标粒子的速度。根据发丝方向D(cost,sint)和速度标量V确定目标粒子的在下一图像帧的速度v2(u,v):v2(u,v)=D(cost,sint)*V,根据v2(u,v)对目标图像帧的速度进行更新。
S504、更新目标粒子的位置。根据目标图像帧的粒子速度v1(u,v)确定目标粒子在下一图像帧的位置P(u,v)=P_prev(u,v)+v1(u,t)*delta_t,其中,P_prev(u,v)表示目标粒子在目标图像帧的位置,delta_t表示时间增量,根据P(u,v)对P_prev(u,v)进行更新。如果更新后的粒子位置超出了头发区域范围,则在屏幕上重新生成随机的粒子位置,重新确定位置并进行位置更新。
S505、剩余粒子的状态保持不变。剩余粒子在下一图像帧的速度和位置采用目标图像帧的速度和位置。
上述实施例实现了以下有益效果:
1、将头发粒子整合为粒子束,避免了头发的杂乱无序,实现了“流光”的流畅渲染效果。
2、传统技术中,视频特效大多数实现比较简单,且GPU粒子技术实现复杂,比较难推广成一种固定的模式,所以一般需求还是使用传统的cpu计算来实现粒子系统。而上述实施例使用GPU实现粒子信息的计算,实现了GPU粒子系统,大大提高了粒子系统的计算效率,能在移动端做到实时,实现了移动端对头发的实时渲染。
应该理解的是,虽然图2和图5的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图2和图5中的至少一部分步骤可以包括多个步骤或者多个阶段,这些步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤中的步骤或者节点的至少一部分轮流或者交替地执行。
图6是根据一示例性实施例示出的一种头发的渲染装置600的框图。参照图6,该装置包括图像帧确定单元601,纹理图像获取单元602,状态信息获取单元603,运动状态确定单元604和运动状态更新单元605。
图像帧确定单元601,被配置为执行获取包含头发信息的目标视频,从所述目标视 频的图像帧中选择目标图像帧;
纹理图像获取单元602,被配置为执行获取所述目标图像帧的纹理图像;其中,所述纹理图像为对所述目标图像帧中像素点的运动状态和状态变化信息进行记录的纹理格式的图像,所述纹理图像中的头发区域被格网线划分为至少一个粒子区域;
状态信息获取单元603,被配置为执行从所述纹理图像中获取所述至少一个粒子区域中第一目标粒子区域的第一目标运动状态和目标状态变化信息;
运动状态确定单元604,被配置为执行根据所述第一目标运动状态和所述目标状态变化信息确定所述第一目标粒子区域在下一图像帧中的第二目标运动状态;所述下一图像帧为所述目标视频中所述目标图像帧的下一帧图像;
运动状态更新单元605,被配置为执行根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新,以对所述头发区域进行渲染。
上述实施例提供的头发的渲染装置,根据包含头发信息的目标视频获取目标图像帧的纹理图像,该纹理图像能够被GPU处理;该纹理图像中的头发区域被划分为至少一个粒子区域,能实现GPU对粒子区域的处理,同时极大简化GPU的图形处理效率,实现在移动端的运算;另外,从纹理图像中获取目标粒子区域的第一目标运动状态和目标状态变化信息,据此确定第一目标粒子区域在下一图像帧中的第二目标运动状态,根据第二目标运动状态对纹理图像中的运动状态进行更新,以实现对头发区域的渲染。根据本公开的上述技术方案能够在移动端实现对头发区域的实时渲染,同时对特定粒子区域的运动状态进行修改,能实现粒子沿发丝方向流动的渲染特效。
在一示例性实施例中,所述运动状态更新单元,还被配置为执行根据所述第二目标运动状态对所述第一目标粒子区域的运动状态进行更新,并保留剩余粒子区域的运动状态;所述剩余粒子区域为所述至少一个粒子区域中除去所述第一目标粒子区域的粒子区域。
在一示例性实施例中,所述第一目标运动状态包括第一屏幕坐标,所述目标状态变化信息包括第一速度;所述运动状态确定单元,包括:时间差值确定子单元,被配置为执行确定所述目标图像帧和所述下一图像帧的时间差值;第一运动状态确定子单元,被配置为执行根据所述第一屏幕坐标、所述第一速度和所述时间差值确定所述第一目标粒子区域在所述下一图像帧中的第二屏幕坐标,作为所述第二目标运动状态。
在一示例性实施例中,所述运动状态更新单元,包括:粒子区域确定子单元,被配置为执行若所述第二屏幕坐标处于所述头发区域之外,重新确定所述纹理图像的头发区域,并从新确定的头发区域所对应的粒子区域中确定第二目标粒子区域;状态信息获取子单元,被配置为执行从所述纹理图像中获取所述第二目标粒子区域的参考目标运动状态和参考目标状态变化信息;第二运动状态确定子单元,被配置为执行根据所述参考目标运动状态和所述参考目标状态变化信息确定所述第二目标粒子区域在所述下一图像帧中的运动状态,得到第三目标运动状态;运动状态更新子单元,被配置为执行根据所述第三目标运动状态对所述纹理图像中的运动状态进行更新。
在一示例性实施例中,所述第一目标运动状态包括第二速度,所述目标状态变化信息包括头发方向角;所述运动状态确定单元,包括:速率获取子单元,被配置为执行获取预先设定的速率;第三运动状态确定子单元,被配置为执行根据所述第二速度、所述头发方向角和所述速率确定所述第一目标粒子区域在所述下一图像帧中的第三速度,得到所述第二目标运动状态。
在一示例性实施例中,所述头发的渲染装置,还包括:状态变化信息确定单元,被配置为执行根据所述目标视频中随时间变化的像素状态信息,确定所述目标图像帧中各个像素点的候选状态变化信息;图像获取单元,被配置为执行获取所述目标图像帧对应 的头发方向图和头发区域掩码图;所述头发方向图中包含有所述各个像素点的头发方向角,所述头发区域掩码图中包含有所述目标图像帧中头发区域的掩码信息;候选运动状态确定单元,被配置为执行根据所述头发方向图中的头发方向角和所述头发区域掩码图中的掩码信息确定所述各个像素点的候选运动状态;候选运动状态存储单元,被配置为执行将所述候选状态变化信息和所述候选运动状态存储到所述至少一个粒子区域的顶点位置上;其中,所述至少一个粒子区域的顶点位置与所述各个像素点对应。
在一示例性实施例中,所述头发的渲染装置,还包括:第一图像存储单元,被配置为执行将所述纹理图像存储到第一帧缓冲中;图像转存单元,被配置为执行将第一帧缓冲中的纹理图像存储到第二帧缓冲中;第二图像存储单元,被配置为执行将更新后的所述纹理图像存储到所述第一帧缓冲中。
在一示例性实施例中,所述头发的渲染装置还包括:区域确定单元,被配置为执行确定所述纹理图像中的头发区域;区域划分单元,被配置为执行根据预先确定的粒子束数量对所述头发区域进行格网划分,得到对应的至少一个粒子束;粒子束划分单元,被配置为执行根据预先确定的粒子数量对所述至少一个粒子束分别进行格网划分,得到对应的至少一个粒子区域。
在一示例性实施例中,所述头发的渲染装置,还包括:粒子区域确定单元,被配置为执行将所述至少一个粒子束中处于设定位置的粒子区域,确定为所述第一目标粒子区域。
关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。
在一示例性实施例中,还提供了一种电子设备,其结构示意图可以如图1所示,该电子设备包括:处理器;用于存储所述处理器可执行指令的存储器;其中,所述处理器被配置为执行所述指令,以实现如前述实施例所述的头发的渲染方法。
在一示例性实施例中,还提供了一种包括指令的非临时性计算机可读存储介质,例如包括指令的存储器102,上述指令可由设备100的处理器120执行以完成上述方法。例如,所述非临时性计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。
在一示例性实施例中,提供一种计算机程序产品,所述程序产品包括计算机程序,所述计算机程序存储在可读存储介质中,设备的至少一个处理器从所述可读存储介质读取并执行所述计算机程序,使得设备执行如上实施例中所述的头发的渲染方法。
本领域技术人员在考虑说明书及实践这里公开的发明后,将容易想到本公开的其它实施方案。本公开旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由下面的权利要求指出。
应当理解的是,本公开并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本公开的范围仅由所附的权利要求来限制。

Claims (20)

  1. 一种头发的渲染方法,其特征在于,包括:
    获取包含头发信息的目标视频,从所述目标视频的图像帧中选择目标图像帧;
    获取所述目标图像帧的纹理图像,其中,所述纹理图像为记录所述目标图像帧中像素点的运动状态和状态变化信息的纹理格式的图像,所述纹理图像中的头发区域被格网线划分为至少一个粒子区域;
    从所述纹理图像中获取第一目标粒子区域的第一目标运动状态和目标状态变化信息,其中,所述第一目标粒子区域为所述至少一个粒子区域中的任一区域;
    根据所述第一目标运动状态和所述目标状态变化信息,确定所述第一目标粒子区域在下一图像帧中的第二目标运动状态,其中,所述下一图像帧为所述目标视频中所述目标图像帧的下一帧图像;
    根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新,以对所述头发区域进行渲染。
  2. 根据权利要求1所述的头发的渲染方法,其特征在于,所述根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新的步骤,包括:
    根据所述第二目标运动状态对所述第一目标粒子区域的运动状态进行更新,并保留剩余粒子区域的运动状态,其中,所述剩余粒子区域为所述至少一个粒子区域中除去所述第一目标粒子区域外的其他粒子区域。
  3. 根据权利要求1或2所述的头发的渲染方法,其特征在于,所述第一目标运动状态包括第一屏幕坐标,所述目标状态变化信息包括第一速度;
    所述根据所述第一目标运动状态和所述目标状态变化信息,确定所述第一目标粒子区域在下一图像帧中的第二目标运动状态的步骤,包括:
    确定所述目标图像帧和所述下一图像帧间的时间差值;
    根据所述第一屏幕坐标、所述第一速度和所述时间差值,确定所述第一目标粒子区域在所述下一图像帧中的第二屏幕坐标,作为所述第二目标运动状态。
  4. 根据权利要求3所述的头发的渲染方法,其特征在于,所述根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新的步骤,包括:
    若所述第二屏幕坐标处于所述头发区域之外,重新确定所述纹理图像的头发区域,并从新确定的头发区域所对应的粒子区域中确定第二目标粒子区域;
    从所述纹理图像中获取所述第二目标粒子区域的参考目标运动状态和参考目标状态变化信息;
    根据所述参考目标运动状态和所述参考目标状态变化信息,确定所述第二目标粒子区域在所述下一图像帧中的运动状态,得到第三目标运动状态;
    根据所述第三目标运动状态对所述纹理图像中的运动状态进行更新。
  5. 根据权利要求1或2所述的头发的渲染方法,其特征在于,所述第一目标运动状态包括第二速度,所述目标状态变化信息包括头发方向角;
    所述根据所述第一目标运动状态和所述目标状态变化信息,确定所述第一目标粒子区域在下一图像帧中的第二目标运动状态的步骤,包括:
    获取预先设定的速率;
    根据所述第二速度、所述头发方向角和所述速率,确定所述第一目标粒子区域在所述下一图像帧中的第三速度,得到所述第二目标运动状态。
  6. 根据权利要求1-5任一所述的头发的渲染方法,其特征在于,在所述获取所述目标图像帧的纹理图像的步骤之前,还包括:
    根据所述目标视频中随时间变化的像素状态信息,确定所述目标图像帧中各个像素点的候选状态变化信息;
    获取所述目标图像帧对应的头发方向图和头发区域掩码图,其中,所述头发方向图中包含有所述各个像素点的头发方向角,所述头发区域掩码图中包含有所述目标图像帧中头发区域的掩码信息;
    根据所述头发方向图中的头发方向角和所述头发区域掩码图中的掩码信息,确定所述各个像素点的候选运动状态;
    将所述候选状态变化信息和所述候选运动状态存储到所述至少一个粒子区域的顶点位置上;其中,所述至少一个粒子区域的顶点位置与所述各个像素点对应。
  7. 根据权利要求6所述的头发的渲染方法,其特征在于,在所述将所述候选状态变化信息和所述候选运动状态存储到所述至少一个粒子区域的顶点位置上的步骤之后,还包括:
    将所述纹理图像存储到第一帧缓冲中;
    在所述根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新的步骤之后,还包括:
    将第一帧缓冲中的纹理图像存储到第二帧缓冲中;
    将更新后的所述纹理图像存储到所述第一帧缓冲中。
  8. 根据权利要求1-7任一所述的头发的渲染方法,其特征在于,在所述获取所述目标图像帧的纹理图像的步骤之后,还包括:
    确定所述纹理图像中的头发区域;
    根据预先确定的粒子束数量对所述头发区域进行格网划分,得到对应的至少一个粒子束;
    根据预先确定的粒子数量对所述至少一个粒子束分别进行格网划分,得到对应的至少一个粒子区域。
  9. 根据权利要求8所述的头发的渲染方法,其特征在于,在所述从所述纹理图像中获取第一目标粒子区域的第一目标运动状态和目标状态变化信息的步骤之前,还包括:
    将所述至少一个粒子束中处于设定位置的粒子区域,确定为所述第一目标粒子区域。
  10. 一种头发的渲染装置,其特征在于,包括:
    图像帧确定单元,被配置为执行获取包含头发信息的目标视频,从所述目标视频的图像帧中选择目标图像帧;
    纹理图像获取单元,被配置为执行获取所述目标图像帧的纹理图像,其中,所述纹理图像为记录所述目标图像帧中像素点的运动状态和状态变化信息的纹理格式的图像,所述纹理图像中的头发区域被格网线划分为至少一个粒子区域;
    状态信息获取单元,被配置为执行从所述纹理图像中获取第一目标粒子区域的第一目标运动状态和目标状态变化信息,其中,所述第一目标粒子区域为所述至少一个粒子区域中的任一区域;
    运动状态确定单元,被配置为执行根据所述第一目标运动状态和所述目标状态变化信息,确定所述第一目标粒子区域在下一图像帧中的第二目标运动状态,其中,所述下一图像帧为所述目标视频中所述目标图像帧的下一帧图像;
    运动状态更新单元,被配置为执行根据所述第二目标运动状态对所述纹理图像中的运动状态进行更新,以对所述头发区域进行渲染。
  11. 根据权利要求10所述的头发的渲染装置,其特征在于,所述运动状态更新单元,还被配置为执行根据所述第二目标运动状态对所述第一目标粒子区域的运动状态进 行更新,并保留剩余粒子区域的运动状态,其中,所述剩余粒子区域为所述至少一个粒子区域中除去所述第一目标粒子区域外的其他粒子区域。
  12. 根据权利要求10或11所述的头发的渲染装置,其特征在于,所述第一目标运动状态包括第一屏幕坐标,所述目标状态变化信息包括第一速度;
    所述运动状态确定单元,包括:
    时间差值确定子单元,被配置为执行确定所述目标图像帧和所述下一图像帧间的时间差值;
    第一运动状态确定子单元,被配置为执行根据所述第一屏幕坐标、所述第一速度和所述时间差值,确定所述第一目标粒子区域在所述下一图像帧中的第二屏幕坐标,作为所述第二目标运动状态。
  13. 根据权利要求12所述的头发的渲染装置,其特征在于,所述运动状态更新单元,包括:
    粒子区域确定子单元,被配置为执行若所述第二屏幕坐标处于所述头发区域之外,重新确定所述纹理图像的头发区域,并从新确定的头发区域所对应的粒子区域中确定第二目标粒子区域;
    状态信息获取子单元,被配置为执行从所述纹理图像中获取所述第二目标粒子区域的参考目标运动状态和参考目标状态变化信息;
    第二运动状态确定子单元,被配置为执行根据所述参考目标运动状态和所述参考目标状态变化信息,确定所述第二目标粒子区域在所述下一图像帧中的运动状态,得到第三目标运动状态;
    运动状态更新子单元,被配置为执行根据所述第三目标运动状态对所述纹理图像中的运动状态进行更新。
  14. 根据权利要求10或11所述的头发的渲染装置,其特征在于,所述第一目标运动状态包括第二速度,所述目标状态变化信息包括头发方向角;
    所述运动状态确定单元,包括:
    速率获取子单元,被配置为执行获取预先设定的速率;
    第三运动状态确定子单元,被配置为执行根据所述第二速度、所述头发方向角和所述速率,确定所述第一目标粒子区域在所述下一图像帧中的第三速度,得到所述第二目标运动状态。
  15. 根据权利要求10-14任一所述的头发的渲染装置,其特征在于,所述头发的渲染装置,还包括:
    状态变化信息确定单元,被配置为执行根据所述目标视频中随时间变化的像素状态信息,确定所述目标图像帧中各个像素点的候选状态变化信息;
    图像获取单元,被配置为执行获取所述目标图像帧对应的头发方向图和头发区域掩码图,其中,所述头发方向图中包含有所述各个像素点的头发方向角,所述头发区域掩码图中包含有所述目标图像帧中头发区域的掩码信息;
    候选运动状态确定单元,被配置为执行根据所述头发方向图中的头发方向角和所述头发区域掩码图中的掩码信息,确定所述各个像素点的候选运动状态;
    候选运动状态存储单元,被配置为执行将所述候选状态变化信息和所述候选运动状态存储到所述至少一个粒子区域的顶点位置上;其中,所述至少一个粒子区域的顶点位置与所述各个像素点对应。
  16. 根据权利要求15所述的头发的渲染装置,其特征在于,所述头发的渲染装置,还包括:
    第一图像存储单元,被配置为执行将所述纹理图像存储到第一帧缓冲中;
    图像转存单元,被配置为执行将第一帧缓冲中的纹理图像存储到第二帧缓冲中;
    第二图像存储单元,被配置为执行将更新后的所述纹理图像存储到所述第一帧缓冲中。
  17. 根据权利要求10-16任一所述的头发的渲染装置,其特征在于,所述头发的渲染装置还包括:
    区域确定单元,被配置为执行确定所述纹理图像中的头发区域;
    区域划分单元,被配置为执行根据预先确定的粒子束数量对所述头发区域进行格网划分,得到对应的至少一个粒子束;
    粒子束划分单元,被配置为执行根据预先确定的粒子数量对所述至少一个粒子束分别进行格网划分,得到对应的至少一个粒子区域。
  18. 根据权利要求17所述的头发的渲染装置,其特征在于,所述头发的渲染装置,还包括:
    粒子区域确定单元,被配置为执行将所述至少一个粒子束中处于设定位置的粒子区域,确定为所述第一目标粒子区域。
  19. 一种电子设备,其特征在于,包括:
    处理器;
    用于存储所述处理器可执行指令的存储器;
    其中,所述处理器被配置为执行所述指令,以实现如权利要求1至9中任一项所述的头发的渲染方法。
  20. 一种存储介质,当所述存储介质中的指令由电子设备的处理器执行时,使得所述电子设备能够执行如权利要求1至9中任一项所述的头发的渲染方法。
PCT/CN2020/129859 2020-03-27 2020-11-18 头发的渲染方法、装置、电子设备及存储介质 Ceased WO2021189880A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP2022549140A JP7390495B2 (ja) 2020-03-27 2020-11-18 髪のレンダリング方法、装置、電子機器及び記憶媒体
US17/897,309 US20220414963A1 (en) 2020-03-27 2022-08-29 Hair rendering method and apparatus, electronic device and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010230272.6A CN113516743A (zh) 2020-03-27 2020-03-27 头发的渲染方法、装置、电子设备及存储介质
CN202010230272.6 2020-03-27

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/897,309 Continuation US20220414963A1 (en) 2020-03-27 2022-08-29 Hair rendering method and apparatus, electronic device and storage medium

Publications (1)

Publication Number Publication Date
WO2021189880A1 true WO2021189880A1 (zh) 2021-09-30

Family

ID=77890877

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/129859 Ceased WO2021189880A1 (zh) 2020-03-27 2020-11-18 头发的渲染方法、装置、电子设备及存储介质

Country Status (4)

Country Link
US (1) US20220414963A1 (zh)
JP (1) JP7390495B2 (zh)
CN (1) CN113516743A (zh)
WO (1) WO2021189880A1 (zh)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220164852A1 (en) * 2020-11-20 2022-05-26 The Procter & Gamble Company Digital Imaging and Learning Systems and Methods for Analyzing Pixel Data of an Image of a Hair Region of a User's Head to Generate One or More User-Specific Recommendations
KR102575743B1 (ko) * 2021-10-14 2023-09-06 네이버 주식회사 이미지 번역 방법 및 시스템
CN114037740B (zh) * 2021-11-09 2024-07-19 北京字节跳动网络技术有限公司 图像数据流的处理方法、装置及电子设备
CN114219877B (zh) * 2021-12-06 2024-06-25 北京字节跳动网络技术有限公司 人像头发流动特效处理方法、装置、介质和电子设备
CN114898006B (zh) * 2022-05-20 2025-09-30 北京字跳网络技术有限公司 交互方法、装置、设备及存储介质
CN115359151A (zh) * 2022-08-26 2022-11-18 北京字跳网络技术有限公司 特效处理方法、装置、电子设备和存储介质
CN116778059A (zh) * 2023-03-28 2023-09-19 网易(杭州)网络有限公司 虚拟水面波纹生成方法、装置、存储介质与电子设备

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107958480A (zh) * 2017-11-23 2018-04-24 腾讯科技(上海)有限公司 图像渲染方法、装置及存储介质
US20180181803A1 (en) * 2016-12-27 2018-06-28 Shenzhen University Pedestrian head identification method and system

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4695275B2 (ja) * 2001-03-07 2011-06-08 独立行政法人科学技術振興機構 動画像生成システム
JP2007286669A (ja) * 2006-04-12 2007-11-01 Sony Corp 画像処理装置および方法、並びにプログラム
JP2009020874A (ja) * 2007-06-11 2009-01-29 Kyushu Institute Of Technology 髪シミュレーション方法およびその装置
CN103606186B (zh) * 2013-02-02 2016-03-30 浙江大学 一种图像与视频的虚拟发型建模方法
JP2017054337A (ja) * 2015-09-10 2017-03-16 ソニー株式会社 画像処理装置および方法
US9870638B2 (en) * 2016-02-24 2018-01-16 Ondrej Jamri{hacek over (s)}ka Appearance transfer techniques

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180181803A1 (en) * 2016-12-27 2018-06-28 Shenzhen University Pedestrian head identification method and system
CN107958480A (zh) * 2017-11-23 2018-04-24 腾讯科技(上海)有限公司 图像渲染方法、装置及存储介质

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
LYU MENGYA, DU HUAPENG, TANG YONG: "A Novel Algorithm of Collision Handling for Fluid based Hair Model", JOURNAL OF YANSHAN UNIVERSITY, vol. 34, no. 5, 30 September 2010 (2010-09-30), pages 417 - 420, XP055853229, ISSN: 1007-791X, DOI: 10.3969/j.issn.1007-791X.2010.05.008 *
WU CHEN: "Research and Implementation on Video-based Fast Hair Capture Method", INFORMATION & TECHNOLOGY, CHINA MASTER'S THESES FULL-TEXT DATABASE, 15 January 2015 (2015-01-15), XP055853232 *

Also Published As

Publication number Publication date
CN113516743A (zh) 2021-10-19
JP2023515410A (ja) 2023-04-13
JP7390495B2 (ja) 2023-12-01
US20220414963A1 (en) 2022-12-29

Similar Documents

Publication Publication Date Title
WO2021189880A1 (zh) 头发的渲染方法、装置、电子设备及存储介质
US10032076B2 (en) Method and device for displaying image
JP7038853B2 (ja) 画像処理方法及び装置、電子機器並びにコンピュータ可読記憶媒体
KR102301447B1 (ko) 비디오 처리 방법, 비디오 처리 장치 및 저장 매체
CN111985268B (zh) 一种人脸驱动动画的方法和装置
US10154228B1 (en) Smoothing video panning
US9824723B1 (en) Direction indicators for panoramic images
CN107977934B (zh) 图像处理方法及装置
US12417597B2 (en) Systems and methods for augmented reality video generation
CN114071223A (zh) 基于光流的视频插帧的生成方法、存储介质及终端设备
CN114422692B (zh) 视频录制方法、装置及电子设备
CN110211211B (zh) 图像处理方法、装置、电子设备及存储介质
CN112614228A (zh) 三维网格的简化方法、装置、电子设备和存储介质
WO2022142388A1 (zh) 特效显示方法及电子设备
WO2023093792A1 (zh) 一种图像帧的渲染方法及相关装置
CN116582637A (zh) 视频会议画面的分屏方法及相关设备
CN114898039A (zh) 三维模型构建方法、装置、电子设备及存储介质
EP3799415A2 (en) Method and device for processing videos, and medium
CN107239758A (zh) 人脸关键点定位的方法及装置
JP7427786B2 (ja) 拡張現実に基づく表示方法、機器、記憶媒体及びプログラム製品
CN114095646B (zh) 图像处理方法、装置、电子设备及存储介质
CN110312117B (zh) 数据刷新方法及装置
CN116092147A (zh) 视频处理方法、装置、电子设备及存储介质
WO2019061118A1 (zh) 全景拍摄方法及终端
CN115396740B (zh) 全景视频的播放方法、装置、电子设备及可读存储介质

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: 20927952

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2022549140

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20927952

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 31.03.2023)

122 Ep: pct application non-entry in european phase

Ref document number: 20927952

Country of ref document: EP

Kind code of ref document: A1