WO2018176958A1 - Adaptive mapping method and system depending on movement of key points in image - Google Patents

Adaptive mapping method and system depending on movement of key points in image Download PDF

Info

Publication number
WO2018176958A1
WO2018176958A1 PCT/CN2017/120135 CN2017120135W WO2018176958A1 WO 2018176958 A1 WO2018176958 A1 WO 2018176958A1 CN 2017120135 W CN2017120135 W CN 2017120135W WO 2018176958 A1 WO2018176958 A1 WO 2018176958A1
Authority
WO
WIPO (PCT)
Prior art keywords
coordinates
point
key
image
texture
Prior art date
Application number
PCT/CN2017/120135
Other languages
French (fr)
Chinese (zh)
Inventor
李亮
陈少杰
张文明
Original Assignee
武汉斗鱼网络科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 武汉斗鱼网络科技有限公司 filed Critical 武汉斗鱼网络科技有限公司
Publication of WO2018176958A1 publication Critical patent/WO2018176958A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/25Determination of region of interest [ROI] or a volume of interest [VOI]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/20Linear translation of whole images or parts thereof, e.g. panning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/60Rotation of whole images or parts thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2200/00Indexing scheme for image data processing or generation, in general
    • G06T2200/24Indexing scheme for image data processing or generation, in general involving graphical user interfaces [GUIs]

Definitions

  • the present invention relates to the field of image processing and, more particularly, to an adaptive mapping method and system that moves with key points in an image.
  • mapping on video images is becoming more and more common.
  • texture is the effect of adding dynamic texture to specific parts of the image.
  • a human face can be referred to as an eye. , nose or mouth
  • the existing mapping method only places the texture at a specific position in the picture.
  • the specific position changes, although the position of the texture changes, the display scale changes without considering the specific position.
  • the shape of the texture will be distorted to a certain extent, which will greatly reduce the display effect of the texture.
  • the present invention provides a method and system for adaptive mapping of key points moving in an image that overcomes the above problems or at least partially solves the above problems.
  • a method of adaptive mapping that moves with key points in an image comprising:
  • an adaptive mapping system that moves with key points in an image, including:
  • the nearby coordinate generating device obtains a certain range of coordinates near the position after the key point is moved according to the coordinate of the key point movement and the scaling factor of the texture;
  • the texture sampling coordinate obtaining means obtains the texture sampling coordinates according to the coordinates of a certain range, the coordinates of the key points, and the scaling factor of the texture in the vicinity of the position after the key point is moved, and displays the texture on the texture sampling coordinates.
  • an adaptive mapping apparatus comprising:
  • At least one processor at least one memory, and a bus;
  • the processor and the memory complete communication with each other through the bus;
  • the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the following methods:
  • a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions when the program instructions are When the computer executes, it can perform the following methods:
  • a non-transitory computer readable storage medium storing computer instructions that cause the computer to perform the following method:
  • the present application proposes an adaptive mapping method and system for moving key points in an image, by locating the position of a key point on a key object in the image, and rotating any point on the image according to the position change after the key point is moved.
  • Matrix transformation obtain the coordinates of the rotation matrix corresponding to the point, ensure that the points on the image move synchronously with the position of the key point, and then move the key point according to the coordinate of the key point and the scaling factor of the texture.
  • a certain range of coordinates near the position, and finally the coordinate of the key point and the scaling factor of the texture are obtained to obtain the texture sampling coordinates of the display texture.
  • the present invention enables the texture to be adaptively moved in the case where the key point on the image is moved, and The user's experience is improved without changing the original display ratio.
  • FIG. 1 is a flow chart of an adaptive mapping method for moving key points in an image according to an embodiment of the present invention
  • step S1 is a flowchart of step S1 in the embodiment of the present invention.
  • step S2 in the embodiment of the present invention.
  • FIG. 4 is a block diagram of an adaptive mapping system that moves with key points in an image according to an embodiment of the present invention
  • FIG. 5 is a structural block diagram of a conversion module according to an embodiment of the present invention.
  • FIG. 6 is a functional block diagram of an adaptive mapping device in an embodiment of the present invention.
  • the present invention provides a mapping method of adaptive rotation that can be rotated with the human face.
  • FIG. 1 is a flowchart of an adaptive mapping method for face rotation according to an embodiment of the present invention. As shown in FIG. 1, the method includes:
  • the present application proposes an adaptive mapping method and system for moving key points in an image, by locating the position of a key point on a key object in the image, and rotating any point on the image according to the position change after the key point is moved.
  • Matrix transformation get the converted coordinates corresponding to the point, and then according to the coordinate of the key point and the scaling factor of the texture, filter the coordinates of a certain range around the position after the key point is moved, and finally combine the coordinates of the key point and the texture of the map.
  • the scaling factor obtains the texture sampling coordinates of the display texture.
  • the present invention enables the texture to be adaptively moved in the case of moving key points on the image without changing the original display ratio, thereby improving the user experience.
  • FIG. 2 is a flowchart of step S1 in the embodiment of the present invention, including:
  • the embodiment of the present invention refers to the coordinates of the image as the world coordinate system, and the coordinate system in which the movable key object in the image is located is referred to as the object coordinate system.
  • the texture is located in the coordinate system of the image, the texture is mapped. It always follows the motion of the object, which is equivalent to the coordinate system of the object. Therefore, in order to ensure the rotation of the texture to adapt to the transformation between the two coordinate systems, the aspect ratio of the image, the distance moved by the key point, and the rotation angle of the key object are required. , Perform a rotation matrix transformation on any point on the image.
  • step S1.3 further includes:
  • the rotation center point is a key point, so-called The key point, to put it simply, is that the texture needs to be aligned at all times, for example, for mapping on the human eye, the key point can be the center point of the region of the human eye (assuming this is the coordinates of the pupil).
  • the rotation center point in the embodiment refers to a key point after the face is moved in the image, and also in the above example, the coordinates of the pupil after the face is moved.
  • the present invention is not limited to the mapping of the human eye, and the present invention is equally applicable to the mapping of other parts of the face, such as the nose, mouth or eyebrows, and will not be described herein.
  • the rotation angle of the face can be calculated from the position of the key points on the human face. For example, the angle between the bridge of the nose and the X-axis in the horizontal direction is calculated, and the calculation formula is not given in detail here. Therefore, in order to ensure that the rotated coordinates coincide with the rotation angle of the face and the shape does not change, the embodiment rotates the coordinates after the first translation according to the rotation angle of the face and the coordinates of the rotation center point. obtain.
  • step S1.3 further includes:
  • the coordinates (x, y) of the point are converted into homogeneous coordinates (x, y, 1), and the homogeneous coordinates are scaled based on the aspect ratio R of the image. Get the scaled coordinates (R*x, y, 1).
  • the homogeneous coordinate is to represent a vector that is originally n-dimensional with an n+1-dimensional vector.
  • the homogeneous coordinates of the two-dimensional point (x, y) are expressed as (hx, hy, h).
  • the homogeneous representation of a vector is not unique, and the different values of the h of the homogeneous coordinates represent the same point, such as homogeneous coordinates (8, 4, 2), (4, 2 , 1) represents two-dimensional points (4, 2).
  • the scaled coordinates are represented by matrix M 1 as:
  • the coordinates of the original rotation center point are the origin coordinates (0, 0), and the coordinates after the translation are assumed to be (D x , D y ), and the sx units are translated in the x-axis direction.
  • the first coordinates of the shifted matrix M 2 is expressed as:
  • the rotated coordinates are represented by a matrix M 3 as:
  • FIG. 3 is a schematic flowchart of step S2 in the embodiment of the present invention. As shown in FIG. 3, step S2 includes:
  • the coordinates after the transformation of the rotation matrix are defined as (dst x , dst y ), and the coordinates of the key points are (center x , center y ), when the coordinates after the rotation
  • the following conditions are satisfied: (center x -resize x *0.5) ⁇ dst x ⁇ (center x +resize x *0.5) and (center y -resize y *0.5) ⁇ dst y ⁇ (center y +resize y *0.5)
  • the coordinate converted by the rotation matrix is used as a coordinate of a certain range near the position after the key point is moved.
  • l represents the length of the longitudinal length of the key object, such as the length of the face
  • w represents the width of the texture
  • h represents the height of the texture
  • r represents the display coefficient
  • W represents the width of the image
  • H represents the height of the image.
  • the step of obtaining texture sampling coordinates according to the coordinate of a certain range, the coordinates of the key points, and the scaling factor of the map located near the position after the movement of the key point further includes:
  • the key point coordinates are (center x , center y )
  • the scaling factor of the texture on the x-axis is resize x
  • the texture is scaled on the y-axis.
  • the coefficient resize y and the texture sampling coordinates are (coord x , coord y ), then:
  • Coord x (near x -center x +resize x *0.5)/resize x ;
  • Coord y (near y -center y +resize y *0.5)/resize y .
  • FIG. 4 is a block diagram of an adaptive mapping system that moves with key points in an image according to an embodiment of the present invention, including:
  • the nearby coordinate generating device obtains a certain range of coordinates near the position after the key point is moved according to the coordinate of the key point movement and the scaling factor of the texture;
  • the texture sampling coordinate obtaining means obtains the texture sampling coordinates according to the coordinates of a certain range, the coordinates of the key points, and the scaling factor of the texture in the vicinity of the position after the key point is moved, and displays the texture on the texture sampling coordinates.
  • a rotation matrix transformation is performed on any point on the image to obtain a rotation matrix conversion corresponding to the point.
  • the coordinates after the image ensure that the points on the image move synchronously with the position of the key point, and then according to the coordinates of the key point and the scaling factor of the texture, the coordinates of a certain range near the position after the key point is moved are filtered, and finally combined.
  • the coordinate of the key point and the scaling factor of the texture obtain the texture sampling coordinates of the display texture.
  • the present invention enables the texture to be adaptively moved when the key points on the image are moved, and the original display ratio is not changed, thereby improving the user. Experience.
  • the conversion coordinate device comprises:
  • a positioning module for acquiring an aspect ratio of an image and locating a position of a key point on a key object in the image
  • the conversion module is configured to perform rotation matrix conversion on any point on the image according to the aspect ratio of the image, the distance moved by the key point, and the rotation angle of the key object, to obtain the converted coordinates corresponding to any point.
  • the coordinates of the image are called the world coordinate system, and the coordinate system of the movable key object in the image is called the object coordinate system.
  • the texture is located in the coordinate system of the image, the texture always follows the object. Movement, which is equivalent to the coordinate system of the object, so in order to ensure the rotation of the texture to adapt to the conversion between the two coordinate systems, the image should be based on the aspect ratio of the image, the distance moved by the key point, and the rotation angle of the key object. Rotate the matrix transformation at any point.
  • FIG. 5 is a structural block diagram of a conversion module in an embodiment of the present invention, including:
  • the first scaling unit is configured to scale the coordinates of the point according to the aspect ratio of the image to any point on the image to obtain the scaled coordinates.
  • the first translation unit is configured to translate the coordinates of the rotation center point from the origin coordinates to the coordinates of the key point, and translate the scaled coordinates according to the moving distance of the key points to obtain the coordinates after the first translation.
  • the rotation center point is a key point, so-called The key point, to put it simply, is that the texture needs to be aligned at all times, for example, for mapping on the human eye, the key point can be the center point of the region of the human eye (assuming this is the coordinates of the pupil).
  • the rotation center point in the embodiment refers to a key point after the face is moved in the image, and also in the above example, the coordinates of the pupil after the face is moved.
  • the present invention is not limited to the mapping of the human eye, and the present invention is equally applicable to the mapping of other parts of the face, such as the nose, mouth or eyebrows, and will not be described herein.
  • the rotation unit is configured to rotate the coordinates after the first translation according to the rotation angle of the key object and the coordinates of the rotation center point, and obtain the rotated coordinates.
  • the rotation angle of the face can be calculated from the position of the key points on the human face. For example, the angle between the bridge of the nose and the X-axis in the horizontal direction is calculated, and the calculation formula is not given in detail here. Therefore, in order to ensure that the rotated coordinates coincide with the rotation angle of the face and the shape does not change, the embodiment rotates the coordinates after the first translation according to the rotation angle of the face and the coordinates of the rotation center point. obtain.
  • a second translation unit configured to translate coordinates of the rotation center point from coordinates of the key point back to the origin coordinates, and translate the scaled coordinates according to the moving distance of the rotation center point to obtain coordinates after the second translation;
  • a second scaling unit configured to scale the coordinates after the second translation back to the original scale to obtain the converted coordinates.
  • the nearby coordinate generation device comprises:
  • a scaling factor acquisition module for obtaining a scaling factor of the texture on the x-axis based on the longitudinal length of the key object, the width of the texture, and the width of the image, and obtaining the texture on the y-axis based on the longitudinal length of the key object, the height of the texture, and the height of the image.
  • the attachment coordinate acquisition module is configured to define (dstx, dsty) the coordinate after the rotation for any one of the rotated coordinates, and the coordinates of the key point are (centerx, centery), and the coordinates after the rotation satisfy the following conditions: Centerx-resizex*0.5) ⁇ dstx ⁇ (centerx+resizex*0.5) and (centery–resizey*0.5) ⁇ dsty ⁇ (centery+resizey*0.5), the rotated coordinates are taken as the position after the key point is moved A certain range of coordinates nearby.
  • the texture sampling coordinate obtaining device is further configured to:
  • Coord x (near x -center x +resize x *0.5)/resize x ;
  • Coord y (near y -center y +resize y *0.5)/resize y .
  • the present invention discloses an adaptive mapping device, as shown in FIG. 6, comprising:
  • the processor 601 and the memory 602 complete communication with each other through the bus 603; the memory 602 stores program instructions executable by the processor 601, and the processor 602 invokes the program instructions to execute the above
  • the methods provided by the method embodiments include, for example:
  • the present invention discloses a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions when the program instructions are When the computer is executed, the computer can perform the methods provided by the foregoing method embodiments, including, for example:
  • the present invention discloses a non-transitory computer readable storage medium storing computer instructions that cause the computer to perform the various method embodiments described above
  • the methods provided include, for example:
  • the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed.
  • the foregoing steps include the steps of the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Processing Or Creating Images (AREA)
  • Image Generation (AREA)

Abstract

The present invention provides an adaptive mapping method and system depending on movement of key points in an image. The method comprises: positioning the locations of key points on a key object in the image, and performing rotation matrix transformation on any one point on the image according to the location change of the moved key point to obtain the coordinates of the corresponding point after the rotation matrix transformation is performed; obtaining coordinates in a certain range in the vicinity of the location of the moved key point according to the coordinates of the moved key point and the scale coefficient of a map; and obtaining map sampling coordinates according to the coordinates in the certain range in the vicinity of the location of the moved key point, the coordinates of the key point and the scale coefficient of the map, and displaying the map on the map sampling coordinates. By means of the present invention, the map can adaptively rotate in the case that a human face is rotated, and an original display scale will not be changed, and the user experience can be improved.

Description

一种随图像中关键点移动的自适应贴图方法和系统Adaptive mapping method and system for moving with key points in an image
交叉引用cross reference
本申请引用于2017年3月28日提交的专利名称为“一种随图像中关键点移动的自适应贴图方法和系统”的第201710193044.4号中国专利申请,其通过引用被全部并入本申请。The present application is hereby incorporated by reference in its entirety in its entirety in its entirety the entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire entire all all all all all all all all all each
技术领域Technical field
本发明涉及图像处理领域,更具体地,涉及一种随图像中关键点移动的自适应贴图方法和系统。The present invention relates to the field of image processing and, more particularly, to an adaptive mapping method and system that moves with key points in an image.
背景技术Background technique
随着摄影技术和计算机应用的发展,在视频图像上进行贴图变得越来越普遍,所谓贴图就是在图像中的特定部位加上动态贴图的效果,以人脸为例,特定部位可以指眼睛、鼻子或嘴巴,现有的贴图方法仅仅将贴图放置在画面中的特定位置,当特定位置的发生变化时,虽然贴图的位置也随之变化,但由于没有考虑特定位置的显示比例发生了变化,导致贴图的形状会发生一定程度的扭曲,使得贴图的显示效果大打折扣。With the development of photographic technology and computer applications, mapping on video images is becoming more and more common. The so-called texture is the effect of adding dynamic texture to specific parts of the image. For example, a human face can be referred to as an eye. , nose or mouth, the existing mapping method only places the texture at a specific position in the picture. When the specific position changes, although the position of the texture changes, the display scale changes without considering the specific position. The shape of the texture will be distorted to a certain extent, which will greatly reduce the display effect of the texture.
发明内容Summary of the invention
本发明提供一种克服上述问题或者至少部分地解决上述问题的随图像中关键点移动的自适应贴图的方法和系统。The present invention provides a method and system for adaptive mapping of key points moving in an image that overcomes the above problems or at least partially solves the above problems.
根据本发明的一个方面,提供一种随图像中关键点移动的自适应贴图的方法,包括:According to one aspect of the invention, a method of adaptive mapping that moves with key points in an image is provided, comprising:
S1、定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,获得对应该 任意一点的旋转矩阵转换后的坐标;S1. Positioning a key point on a key object in the positioning image, performing rotation matrix conversion on any point on the image according to the position change after the key point is moved, and obtaining a coordinate corresponding to the rotation matrix transformation of any point;
S2、根据关键点移动后的坐标与贴图的缩放系数,获得位于关键点移动后的位置附近一定范围的坐标;S2, according to the coordinate of the key point after moving and the scaling factor of the texture, obtain a certain range of coordinates near the position after the key point is moved;
S3、根据所述位于关键点移动后的位置附近一定范围的坐标、关键点的坐标以及贴图的缩放系数,获得贴图采样坐标,并在所述贴图采样坐标上显示贴图。S3. Obtain a map sampling coordinate according to a certain range of coordinates, a coordinate of a key point, and a scaling factor of the map near the position after the key point is moved, and display the map on the map sampling coordinate.
根据本发明的另一个方面,提供一种随图像中关键点移动的自适应贴图系统,包括:According to another aspect of the present invention, an adaptive mapping system that moves with key points in an image is provided, including:
转换坐标装置,定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的旋转矩阵转换后的坐标;Converting the coordinate device, locating the position of the key point on the key object in the image, performing a rotation matrix transformation on any point on the image according to the position change after the key point is moved, and obtaining the coordinate converted by the rotation matrix corresponding to any point;
附近坐标生成装置,根据关键点移动后的坐标与贴图的缩放系数,获得位于关键点移动后的位置附近一定范围的坐标;The nearby coordinate generating device obtains a certain range of coordinates near the position after the key point is moved according to the coordinate of the key point movement and the scaling factor of the texture;
贴图采样坐标获得装置,根据所述位于关键点移动后的位置附近一定范围的坐标、关键点的坐标以及贴图的缩放系数,获得贴图采样坐标,并在所述贴图采样坐标上显示贴图。The texture sampling coordinate obtaining means obtains the texture sampling coordinates according to the coordinates of a certain range, the coordinates of the key points, and the scaling factor of the texture in the vicinity of the position after the key point is moved, and displays the texture on the texture sampling coordinates.
根据本发明的另一个方面,提供一种自适应贴图设备,包括:According to another aspect of the present invention, an adaptive mapping apparatus is provided, comprising:
至少一个处理器、至少一个存储器和总线;其中,At least one processor, at least one memory, and a bus; wherein
所述处理器和存储器通过所述总线完成相互间的通信;The processor and the memory complete communication with each other through the bus;
所述存储器存储有可被所述处理器执行的程序指令,所述处理器调用所述程序指令能够执行如下方法:The memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the following methods:
S1、定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的旋转矩阵转换后的坐标;S1. Positioning the key points on the key object in the positioning image, performing rotation matrix conversion on any point on the image according to the position change after the key point is moved, and obtaining coordinates converted by the rotation matrix corresponding to any point;
S2、根据关键点移动后的坐标与贴图的缩放系数,获得位于关键点移动后的位置附近一定范围的坐标;S2, according to the coordinate of the key point after moving and the scaling factor of the texture, obtain a certain range of coordinates near the position after the key point is moved;
S3、根据所述位于关键点移动后的位置附近一定范围的坐标、关键点的坐标以及贴图的缩放系数,获得贴图采样坐标,并在所述贴图采样坐标上显示贴图。S3. Obtain a map sampling coordinate according to a certain range of coordinates, a coordinate of a key point, and a scaling factor of the map near the position after the key point is moved, and display the map on the map sampling coordinate.
根据本发明的另一个方面,提供一种计算机程序产品,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,能够执行如下方法:According to another aspect of the present invention, a computer program product is provided, the computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions when the program instructions are When the computer executes, it can perform the following methods:
S1、定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的旋转矩阵转换后的坐标;S1. Positioning the key points on the key object in the positioning image, performing rotation matrix conversion on any point on the image according to the position change after the key point is moved, and obtaining coordinates converted by the rotation matrix corresponding to any point;
S2、根据关键点移动后的坐标与贴图的缩放系数,获得位于关键点移动后的位置附近一定范围的坐标;S2, according to the coordinate of the key point after moving and the scaling factor of the texture, obtain a certain range of coordinates near the position after the key point is moved;
S3、根据所述位于关键点移动后的位置附近一定范围的坐标、关键点的坐标以及贴图的缩放系数,获得贴图采样坐标,并在所述贴图采样坐标上显示贴图。S3. Obtain a map sampling coordinate according to a certain range of coordinates, a coordinate of a key point, and a scaling factor of the map near the position after the key point is moved, and display the map on the map sampling coordinate.
根据本发明的另一个方面,提供一种非暂态计算机可读存储介质,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令使所述计算机执行如下方法:According to another aspect of the present invention, a non-transitory computer readable storage medium is provided, the non-transitory computer readable storage medium storing computer instructions that cause the computer to perform the following method:
S1、定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的旋转矩阵转换后的坐标;S1. Positioning the key points on the key object in the positioning image, performing rotation matrix conversion on any point on the image according to the position change after the key point is moved, and obtaining coordinates converted by the rotation matrix corresponding to any point;
S2、根据关键点移动后的坐标与贴图的缩放系数,获得位于关键点移动后的位置附近一定范围的坐标;S2, according to the coordinate of the key point after moving and the scaling factor of the texture, obtain a certain range of coordinates near the position after the key point is moved;
S3、根据所述位于关键点移动后的位置附近一定范围的坐标、关键点的坐标以及贴图的缩放系数,获得贴图采样坐标,并在所述贴图采样坐标上显示贴图。S3. Obtain a map sampling coordinate according to a certain range of coordinates, a coordinate of a key point, and a scaling factor of the map near the position after the key point is moved, and display the map on the map sampling coordinate.
本申请提出一种随图像中关键点移动的自适应贴图方法和系统,通过定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,得到对应该点的旋转矩阵转换后的坐标,确保图像上的点都随关键点的位置变化而同步移动,再根据关键点移动后的坐标与贴图的缩放系数,筛选位于关键点移动后的位置附近一定范围的坐标,最后结合关键点的坐标以及贴图的缩放系数,获得显示贴图的贴图采样坐标,本发明使得在图像上关键点移动的情况下,贴图自适应地进行移动,并且不改变原有的显示比例,提高了用户的体验。The present application proposes an adaptive mapping method and system for moving key points in an image, by locating the position of a key point on a key object in the image, and rotating any point on the image according to the position change after the key point is moved. Matrix transformation, obtain the coordinates of the rotation matrix corresponding to the point, ensure that the points on the image move synchronously with the position of the key point, and then move the key point according to the coordinate of the key point and the scaling factor of the texture. A certain range of coordinates near the position, and finally the coordinate of the key point and the scaling factor of the texture are obtained to obtain the texture sampling coordinates of the display texture. The present invention enables the texture to be adaptively moved in the case where the key point on the image is moved, and The user's experience is improved without changing the original display ratio.
附图说明DRAWINGS
图1为本发明实施例的一种随图像中关键点移动的自适应贴图方法的流程图;1 is a flow chart of an adaptive mapping method for moving key points in an image according to an embodiment of the present invention;
图2为本发明实施例中步骤S1的流程图;2 is a flowchart of step S1 in the embodiment of the present invention;
图3为本发明实施例中步骤S2的流程示意图;3 is a schematic flowchart of step S2 in the embodiment of the present invention;
图4为本发明实施例的一种随图像中关键点移动的自适应贴图系统的框图;4 is a block diagram of an adaptive mapping system that moves with key points in an image according to an embodiment of the present invention;
图5为本发明实施例中转换模块的结构框图;FIG. 5 is a structural block diagram of a conversion module according to an embodiment of the present invention; FIG.
图6为本发明实施例中的自适应贴图设备的功能框图。FIG. 6 is a functional block diagram of an adaptive mapping device in an embodiment of the present invention.
具体实施方式detailed description
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有 作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
为了克服现有技术中,贴图不能随人脸的旋转而自适应旋转的问题,本发明提供了一种能够随人脸旋转的自适应旋转的贴图方法。In order to overcome the problem of the prior art that the texture cannot be adaptively rotated with the rotation of the human face, the present invention provides a mapping method of adaptive rotation that can be rotated with the human face.
图1示出了本发明实施例的一种随人脸旋转的自适应贴图方法的流程图,如图1可知,本方法包括:FIG. 1 is a flowchart of an adaptive mapping method for face rotation according to an embodiment of the present invention. As shown in FIG. 1, the method includes:
S1、定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的旋转矩阵转换后的坐标;S1. Positioning the key points on the key object in the positioning image, performing rotation matrix conversion on any point on the image according to the position change after the key point is moved, and obtaining coordinates converted by the rotation matrix corresponding to any point;
S2、根据关键点移动后的坐标与贴图的缩放系数,获得位于关键点移动后的位置附近一定范围的坐标;S2, according to the coordinate of the key point after moving and the scaling factor of the texture, obtain a certain range of coordinates near the position after the key point is moved;
S3、根据所述位于关键点移动后的位置附近一定范围的坐标、关键点的坐标以及贴图的缩放系数,获得贴图采样坐标,并在所述贴图采样坐标上显示贴图。S3. Obtain a map sampling coordinate according to a certain range of coordinates, a coordinate of a key point, and a scaling factor of the map near the position after the key point is moved, and display the map on the map sampling coordinate.
本申请提出一种随图像中关键点移动的自适应贴图方法和系统,通过定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,得到对应该点的转换后的坐标,再根据关键点移动后的坐标与贴图的缩放系数,筛选位于关键点移动后的位置附近一定范围的坐标,最后结合关键点的坐标以及贴图的缩放系数,获得显示贴图的贴图采样坐标,本发明使得在图像上关键点移动的情况下,贴图自适应地进行移动,并且不改变原有的显示比例,提高了用户的体验。The present application proposes an adaptive mapping method and system for moving key points in an image, by locating the position of a key point on a key object in the image, and rotating any point on the image according to the position change after the key point is moved. Matrix transformation, get the converted coordinates corresponding to the point, and then according to the coordinate of the key point and the scaling factor of the texture, filter the coordinates of a certain range around the position after the key point is moved, and finally combine the coordinates of the key point and the texture of the map. The scaling factor obtains the texture sampling coordinates of the display texture. The present invention enables the texture to be adaptively moved in the case of moving key points on the image without changing the original display ratio, thereby improving the user experience.
图2示出了本发明实施例中步骤S1的流程图,包括:FIG. 2 is a flowchart of step S1 in the embodiment of the present invention, including:
S1.1、获取图像的宽高比,定位图像中关键物体上关键点的位置。S1.1. Acquire an aspect ratio of the image, and locate the position of the key point on the key object in the image.
需要注意的是,由于常规图像的形状均为长方形,如大部分视频 的宽高比为16:9、4:3、2:1,因此,当图像上的坐标发生旋转时,必然会发生扭曲,最显著的是在有手机观看视频时,手机在横屏模式下或竖屏模型下,字幕上字的宽度不同,因此,为了保证贴图在旋转过程中的形状保持不变,本实施例考虑基于图像的宽高比对任意一点的坐标进行缩放。It should be noted that since the shape of the regular image is rectangular, such as the aspect ratio of most videos is 16:9, 4:3, 2:1, when the coordinates on the image rotate, it will inevitably be distorted. The most significant thing is that when the mobile phone is watching the video, the width of the word on the subtitle is different in the horizontal screen mode or the vertical screen model. Therefore, in order to ensure that the shape of the texture remains unchanged during the rotation process, this embodiment considers The coordinates of any point are scaled based on the aspect ratio of the image.
S1.2、获取关键点移动的距离以及关键物体的转动角度。S1.2. Obtain the distance moved by the key point and the rotation angle of the key object.
S1.3、根据图像的宽高比、关键点移动的距离以及关键物体的转动角度,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的旋转矩阵转换后的坐标。S1.3. Perform a rotation matrix transformation on any point on the image according to the aspect ratio of the image, the distance moved by the key point, and the rotation angle of the key object, and obtain the coordinates after the rotation matrix transformation corresponding to any point.
需要注意的是,本发明实施例将图像的坐标称之为世界坐标系,将图像中可移动的关键物体所在的坐标系称之为物体坐标系,贴图虽然位于图像的坐标系中,但贴图又始终跟随物体运动,相当于与物体的坐标系具有联系,因此为了保证贴图的旋转适应两个坐标系间的转换,需要根据图像的宽高比、关键点移动的距离以及关键物体的转动角度,对图像上的任意一点进行旋转矩阵转换。It should be noted that the embodiment of the present invention refers to the coordinates of the image as the world coordinate system, and the coordinate system in which the movable key object in the image is located is referred to as the object coordinate system. Although the texture is located in the coordinate system of the image, the texture is mapped. It always follows the motion of the object, which is equivalent to the coordinate system of the object. Therefore, in order to ensure the rotation of the texture to adapt to the transformation between the two coordinate systems, the aspect ratio of the image, the distance moved by the key point, and the rotation angle of the key object are required. , Perform a rotation matrix transformation on any point on the image.
出于使描述清晰易懂的考虑,以下实施例中的关键物体均以人脸为例,但不用来限制本发明的范围。For the sake of clarity and ease of description, the key objects in the following embodiments are all exemplified by a human face, but are not intended to limit the scope of the present invention.
在一个实施例中,步骤S1.3进一步包括:In an embodiment, step S1.3 further includes:
S1.3.1、对图像上的任意一点,根据图像的宽高比,对该点的坐标进行缩放,获得缩放后的坐标;S1.3.1, for any point on the image, according to the aspect ratio of the image, the coordinates of the point are scaled to obtain the scaled coordinates;
S1.3.2、将旋转中心点的坐标由原点坐标平移至所述关键点的坐标,并根据关键点的移动距离对缩放后的坐标进行平移,获得第一次平移后的坐标。S1.3.2: The coordinates of the rotation center point are translated from the origin coordinates to the coordinates of the key points, and the scaled coordinates are translated according to the moving distance of the key points to obtain the coordinates after the first translation.
需要注意的是,如果一个图形D绕某点O旋转α°后,得到的新图形与原图形完全重合,称O为图形D的旋转中心点。为了保证贴图 能够以某个特定位置进行旋转,需要将旋转中心平移至特定位置,以保证旋转后的图像与原图像完全重合,在本发明的应用场景下,旋转中心点即为关键点,所谓的关键点,简单的说,就是贴图需要始终对齐的点,以在人的眼睛上进行贴图为例,关键点可以是人的眼睛的区域的中心点(假设这一点是瞳孔的坐标)。显然,本实施例中所述旋转中心点是指图像中人脸移动后的关键点,同样以上述举例来说,就是人脸移动后瞳孔的坐标。当然,本发明并不局限于对人眼进行贴图,本发明同样适用于对人脸其他部位,例如鼻子、嘴巴或者眉毛的贴图,在此不做赘述。It should be noted that if a graphic D is rotated by α° around a certain point O, the obtained new graphic completely coincides with the original graphic, and O is called the rotation center point of the graphic D. In order to ensure that the texture can be rotated at a specific position, the rotation center needs to be translated to a specific position to ensure that the rotated image completely coincides with the original image. In the application scenario of the present invention, the rotation center point is a key point, so-called The key point, to put it simply, is that the texture needs to be aligned at all times, for example, for mapping on the human eye, the key point can be the center point of the region of the human eye (assuming this is the coordinates of the pupil). Obviously, the rotation center point in the embodiment refers to a key point after the face is moved in the image, and also in the above example, the coordinates of the pupil after the face is moved. Of course, the present invention is not limited to the mapping of the human eye, and the present invention is equally applicable to the mapping of other parts of the face, such as the nose, mouth or eyebrows, and will not be described herein.
S1.3.3、根据关键物体的转动角度以及旋转中心点的坐标,对该第一次平移后的坐标进行旋转,获得旋转后的坐标。S1.3.3, according to the rotation angle of the key object and the coordinates of the rotation center point, the coordinates after the first translation are rotated to obtain the rotated coordinates.
需要注意的是,人脸的旋转角度可通过人脸上关键点的位置计算出来,例如,计算鼻梁与水平方向X轴的角度,在此不再详细给出计算公式。因此,为了保证旋转后的坐标与人脸的旋转角度一致且形状不发生改变,本实施例通过根据人脸的旋转角度以及旋转中心点的坐标,对该第一次平移后的坐标进行旋转来获得。It should be noted that the rotation angle of the face can be calculated from the position of the key points on the human face. For example, the angle between the bridge of the nose and the X-axis in the horizontal direction is calculated, and the calculation formula is not given in detail here. Therefore, in order to ensure that the rotated coordinates coincide with the rotation angle of the face and the shape does not change, the embodiment rotates the coordinates after the first translation according to the rotation angle of the face and the coordinates of the rotation center point. obtain.
S1.3.4、将旋转中心点的坐标由所述关键点的坐标平移回原点坐标,并根据旋转中心点的移动距离对缩放后的坐标进行平移,获得第二次平移后的坐标。S1.3.4: The coordinates of the rotation center point are translated from the coordinates of the key point back to the origin coordinates, and the scaled coordinates are translated according to the moving distance of the rotation center point to obtain the coordinates after the second translation.
S1.3.5、将所述第二次平移后的坐标缩放回原比例,获得所述转换后的坐标。S1.3.5, scaling the coordinates after the second translation back to the original scale, and obtaining the converted coordinates.
需要注意的是,在完成第二次平移后,将坐标缩放为原比例,即实现了贴图的正确显示。It should be noted that after the second translation is completed, the coordinates are scaled to the original scale, which realizes the correct display of the texture.
在一个实施例中,步骤S1.3进一步包括:In an embodiment, step S1.3 further includes:
S1.3.1、对于图像上的任意一点,将该点的坐标(x,y)转换为齐 次坐标(x,y,1),基于图像的宽高比R,对该齐次坐标进行缩放,获得缩放后的坐标(R*x,y,1)。S1.3.1, for any point on the image, the coordinates (x, y) of the point are converted into homogeneous coordinates (x, y, 1), and the homogeneous coordinates are scaled based on the aspect ratio R of the image. Get the scaled coordinates (R*x, y, 1).
需要注意的,齐次坐标就是将一个原本是n维的向量用一个n+1维向量来表示。例如,二维点(x,y)的齐次坐标表示为(hx,hy,h)。由此可以看出,一个向量的齐次表示是不唯一的,齐次坐标的h取不同的值都表示的是同一个点,比如齐次坐标(8,4,2)、(4,2,1)表示的都是二维点(4,2)。引入齐次坐标的目的主要是合并矩阵运算中的乘法和加法,表示为p'=p*M的形式。即它提供了用矩阵运算把二维、三维甚至高维空间中的一个点集从一个坐标系变换到另一个坐标系的有效方法。It should be noted that the homogeneous coordinate is to represent a vector that is originally n-dimensional with an n+1-dimensional vector. For example, the homogeneous coordinates of the two-dimensional point (x, y) are expressed as (hx, hy, h). It can be seen that the homogeneous representation of a vector is not unique, and the different values of the h of the homogeneous coordinates represent the same point, such as homogeneous coordinates (8, 4, 2), (4, 2 , 1) represents two-dimensional points (4, 2). The purpose of introducing homogeneous coordinates is mainly to multiply and add in the merging matrix operation, expressed as the form of p'=p*M. That is, it provides an efficient way to transform a set of points in a two-dimensional, three-dimensional or even high-dimensional space from one coordinate system to another using matrix operations.
缩放后坐标用矩阵M 1表示为: The scaled coordinates are represented by matrix M 1 as:
Figure PCTCN2017120135-appb-000001
Figure PCTCN2017120135-appb-000001
S1.3.2、将旋转中心点的坐标由原点坐标(0,0)平移至所述关键点的坐标(D x,D y),并根据关键点的移动距离对缩放后的坐标进行平移,获得第一次平移后的坐标(R*x+D x/R,y+D y,1)。 S1.3.2, shifting the coordinates of the rotation center point from the origin coordinates (0, 0) to the coordinates (D x , D y ) of the key points, and shifting the scaled coordinates according to the moving distance of the key points to obtain The coordinates after the first translation (R*x+D x /R, y+D y , 1).
需要注意的是,在二维坐标中,原旋转中心点的坐标为原点坐标(0,0),假设平移后的坐标为(D x,D y),在x轴方向平移了sx个单位,在y轴方向平移了sy个单位,定义[x,y]为变换前坐标,[X,Y]为变换后坐标。则:X=x+sx;Y=y+sy;用矩阵表示: It should be noted that in the two-dimensional coordinates, the coordinates of the original rotation center point are the origin coordinates (0, 0), and the coordinates after the translation are assumed to be (D x , D y ), and the sx units are translated in the x-axis direction. The sy units are translated in the y-axis direction, [x, y] is defined as the pre-transform coordinates, and [X, Y] is the transformed coordinates. Then: X = x + sx; Y = y + sy; represented by a matrix:
Figure PCTCN2017120135-appb-000002
Figure PCTCN2017120135-appb-000002
应用到本实施例中,第一次平移后的坐标用矩阵M 2表示为: Applied to the present embodiment, the first coordinates of the shifted matrix M 2 is expressed as:
Figure PCTCN2017120135-appb-000003
Figure PCTCN2017120135-appb-000003
S1.3.3、根据关键物体的转动角度a以及旋转中心点的坐标,对该第一次平移后的坐标进行旋转,获得旋转后的坐标:((R*x+D x/R)*cosa-(y+D y)*sina,(R*x+D x/R)*sina-(y+D y)*cosa,1)。 S1.3.3, according to the rotation angle a of the key object and the coordinates of the rotation center point, rotate the coordinates after the first translation to obtain the rotated coordinates: ((R*x+D x /R)*cosa- (y+D y )*sina,(R*x+D x /R)*sina-(y+D y )*cosa,1).
需要注意的是,设某点与原点连线和X轴夹角为b度,以原点为圆心,逆时针转过a度,原点与该点连线长度为R。[x,y]为变换前坐标,[X,Y]为变换后坐标。则:It should be noted that the angle between the line connecting the point and the origin is b degree, the origin is the center of the circle, and the degree is rotated counterclockwise by a degree. The length of the line connecting the origin and the point is R. [x, y] is the coordinate before transformation, and [X, Y] is the coordinate after transformation. then:
x=R*cos(b);y=R*sin(b);x=R*cos(b);y=R*sin(b);
X=R*cos(a+b)=R*cos(a)*cos(b)=R*sin(a)*sin(b)=x*cos(a)-y*sin(a);X=R*cos(a+b)=R*cos(a)*cos(b)=R*sin(a)*sin(b)=x*cos(a)-y*sin(a);
Y=R*sin(a+b)=R*sin(a)*cos(b)+R*cos(a)*sin(b)=x*sin(a)+y*cos(a);Y=R*sin(a+b)=R*sin(a)*cos(b)+R*cos(a)*sin(b)=x*sin(a)+y*cos(a);
用矩阵表示:Expressed in a matrix:
Figure PCTCN2017120135-appb-000004
Figure PCTCN2017120135-appb-000004
应用到本实施例中,旋转后的坐标用矩阵M 3表示为: Applied to the present embodiment, the rotated coordinates are represented by a matrix M 3 as:
Figure PCTCN2017120135-appb-000005
Figure PCTCN2017120135-appb-000005
S1.3.4、将旋转中心点的坐标由所述关键点的坐标平移至原点坐标,并根据旋转中心点平移距离对旋转后的坐标进行平移,获得第二次平移后的坐标:((R*x+D x/R)*cosa-(y+D y)*sina-D x/R,(R*x+D x/R)*sina-(y+D y)*cosa-D y,1)。 S1.3.4, shifting the coordinates of the rotation center point from the coordinates of the key point to the origin coordinates, and translating the rotated coordinates according to the translation distance of the rotation center point, and obtaining the coordinates after the second translation: ((R* x+D x /R)*cosa-(y+D y )*sina-D x /R,(R*x+D x /R)*sina-(y+D y )*cosa-D y ,1 ).
需要注意的是,第二次平移后的坐标用矩阵M 4表示为: It should be noted that the coordinates after the second translation are represented by the matrix M 4 as:
Figure PCTCN2017120135-appb-000006
Figure PCTCN2017120135-appb-000006
S1.3.5、将所述第二次平移后的坐标缩放回原比例,获得所述转换 后的坐标:((x+D x/R 2)*cosa-(y+D y)*sina-D x/R 2,(x+D x/R 2)*sina-(y+D y)*cosa-D y)。 S1.3.5, scaling the coordinates after the second translation back to the original scale, and obtaining the converted coordinates: ((x+D x /R 2 )*cosa-(y+D y )*sina-D x /R 2 , (x+D x /R 2 )*sina-(y+D y )*cosa-D y ).
需要注意的是,转换后的坐标用矩阵M5表示为:It should be noted that the converted coordinates are represented by matrix M5 as:
Figure PCTCN2017120135-appb-000007
Figure PCTCN2017120135-appb-000007
图3示出了本发明实施例中步骤S2的流程示意图,如图3可知,步骤S2包括:FIG. 3 is a schematic flowchart of step S2 in the embodiment of the present invention. As shown in FIG. 3, step S2 includes:
S2.1、基于关键物体的纵向长度、贴图宽度以及图像的宽度,获得贴图在x轴的缩放系数,基于关键物体的纵向长度、贴图高度以及图像的高度,获得贴图在y轴的缩放系数;S2.1, obtaining a scaling factor of the texture on the x-axis based on the longitudinal length of the key object, the width of the texture, and the width of the image, and obtaining a scaling factor of the texture on the y-axis based on the longitudinal length of the key object, the height of the texture, and the height of the image;
S2.2、对于任意一个旋转矩阵转换后的坐标,定义该旋转矩阵转换后的坐标为(dst x,dst y),关键点的坐标为(center x,center y),当该旋转后的坐标满足以下条件:(center x-resize x*0.5)<dst x≤(center x+resize x*0.5)且(center y–resize y*0.5)<dst y≤(center y+resize y*0.5),则将该旋转矩阵转换后的坐标作为位于关键点移动后的位置附近一定范围的坐标。 S2.2. For the coordinates converted by any one of the rotation matrices, the coordinates after the transformation of the rotation matrix are defined as (dst x , dst y ), and the coordinates of the key points are (center x , center y ), when the coordinates after the rotation The following conditions are satisfied: (center x -resize x *0.5) <dst x ≤(center x +resize x *0.5) and (center y -resize y *0.5)<dst y ≤(center y +resize y *0.5), Then, the coordinate converted by the rotation matrix is used as a coordinate of a certain range near the position after the key point is moved.
在一个可选实施例中,贴图在x轴的缩放系数resize x的表达式为:resize x=l*w/(W*r);贴图在y轴的缩放系数resize y的表达式为:resize y=l*h/(H*r); In an alternative embodiment, the expression of the scaling factor resize x of the texture on the x-axis is: resize x = l*w/(W*r); the expression of the scaling factor resize y of the texture on the y-axis is: resize y =l*h/(H*r);
其中,l表示关键物体的纵向长度的长度,例如人脸的长度,w表示贴图的宽度,h表示贴图的高度,r表示显示系数,W表示图像的宽度,H表示图像的高度。Where l represents the length of the longitudinal length of the key object, such as the length of the face, w represents the width of the texture, h represents the height of the texture, r represents the display coefficient, W represents the width of the image, and H represents the height of the image.
在一个可选实施例中,根据所述位于关键点移动后的位置附近一定范围的坐标、关键点的坐标以及贴图的缩放系数,获得贴图采样坐标的步骤,进一步包括:In an optional embodiment, the step of obtaining texture sampling coordinates according to the coordinate of a certain range, the coordinates of the key points, and the scaling factor of the map located near the position after the movement of the key point further includes:
定义位于关键点移动后的位置附近一定范围的坐标为(near x,near y),关键点坐标为(center x,center y),贴图在x轴的缩放系数resize x,贴图在y轴的缩放系数resize y,贴图采样坐标为(coord x,coord y),则: Defines a certain range of coordinates near the position after the key point is moved (near x , near y ), the key point coordinates are (center x , center y ), the scaling factor of the texture on the x-axis is resize x , and the texture is scaled on the y-axis. The coefficient resize y and the texture sampling coordinates are (coord x , coord y ), then:
coord x=(near x-center x+resize x*0.5)/resize xCoord x =(near x -center x +resize x *0.5)/resize x ;
coord y=(near y-center y+resize y*0.5)/resize yCoord y =(near y -center y +resize y *0.5)/resize y .
图4示出了本发明实施例的一种随图像中关键点移动的自适应贴图系统的框图,包括:4 is a block diagram of an adaptive mapping system that moves with key points in an image according to an embodiment of the present invention, including:
转换坐标装置,定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的旋转矩阵转换后的坐标;Converting the coordinate device, locating the position of the key point on the key object in the image, performing a rotation matrix transformation on any point on the image according to the position change after the key point is moved, and obtaining the coordinate converted by the rotation matrix corresponding to any point;
附近坐标生成装置,根据关键点移动后的坐标与贴图的缩放系数,获得位于关键点移动后的位置附近一定范围的坐标;The nearby coordinate generating device obtains a certain range of coordinates near the position after the key point is moved according to the coordinate of the key point movement and the scaling factor of the texture;
贴图采样坐标获得装置,根据所述位于关键点移动后的位置附近一定范围的坐标、关键点的坐标以及贴图的缩放系数,获得贴图采样坐标,并在所述贴图采样坐标上显示贴图。The texture sampling coordinate obtaining means obtains the texture sampling coordinates according to the coordinates of a certain range, the coordinates of the key points, and the scaling factor of the texture in the vicinity of the position after the key point is moved, and displays the texture on the texture sampling coordinates.
需要注意的是,本实施例通过定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,得到对应该点的旋转矩阵转换后的坐标,确保图像上的点都随关键点的位置变化而同步移动,再根据关键点移动后的坐标与贴图的缩放系数,筛选位于关键点移动后的位置附近一定范围的坐标,最后结合关键点的坐标以及贴图的缩放系数,获得显示贴图的贴图采样坐标,本发明使得在图像上关键点移动的情况下,贴图自适应地进行移动,并且不改变原有的显示比例,提高了用户的体验。It should be noted that, in this embodiment, by locating the position of the key point on the key object in the image, according to the position change after the movement of the key point, a rotation matrix transformation is performed on any point on the image to obtain a rotation matrix conversion corresponding to the point. The coordinates after the image ensure that the points on the image move synchronously with the position of the key point, and then according to the coordinates of the key point and the scaling factor of the texture, the coordinates of a certain range near the position after the key point is moved are filtered, and finally combined. The coordinate of the key point and the scaling factor of the texture obtain the texture sampling coordinates of the display texture. The present invention enables the texture to be adaptively moved when the key points on the image are moved, and the original display ratio is not changed, thereby improving the user. Experience.
在一个实施例中,转换坐标装置包括:In one embodiment, the conversion coordinate device comprises:
定位模块,用于获取图像的宽高比,定位图像中关键物体上关键点的位置;a positioning module for acquiring an aspect ratio of an image and locating a position of a key point on a key object in the image;
需要注意的是,由于常规图像的形状均为长方形,如大部分视频的宽高比为16:9、4:3、2:1,因此,当图像上的坐标发生旋转时,必然会发生扭曲,最显著的是在有手机观看视频时,手机在横屏模式下或竖屏模型下,字幕上字的宽度不同,因此,为了保证贴图在旋转过程中的形状保持不变,本实施例考虑基于贴图的宽高比对任意一点的坐标进行缩放。It should be noted that since the shape of the regular image is rectangular, such as the aspect ratio of most videos is 16:9, 4:3, 2:1, when the coordinates on the image rotate, it will inevitably be distorted. The most significant thing is that when the mobile phone is watching the video, the width of the word on the subtitle is different in the horizontal screen mode or the vertical screen model. Therefore, in order to ensure that the shape of the texture remains unchanged during the rotation process, this embodiment considers Scales the coordinates of any point based on the aspect ratio of the texture.
获取关键点参数模块、用于获取关键点移动的距离以及关键物体的转动角度;以及Obtain a key point parameter module, a distance for obtaining key point movement, and a rotation angle of a key object;
转换模块,用于根据图像的宽高比、关键点移动的距离以及关键物体的转动角度,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的转换后的坐标。The conversion module is configured to perform rotation matrix conversion on any point on the image according to the aspect ratio of the image, the distance moved by the key point, and the rotation angle of the key object, to obtain the converted coordinates corresponding to any point.
需要注意的是,将图像的坐标称之为世界坐标系,将图像中可移动的关键物体所在的坐标系称之为物体坐标系,贴图虽然位于图像的坐标系中,但贴图又始终跟随物体运动,相当于与物体的坐标系具有联系,因此为了保证贴图的旋转适应两个坐标系间的转换,需要根据图像的宽高比、关键点移动的距离以及关键物体的转动角度,对图像上的任意一点进行旋转矩阵转换。It should be noted that the coordinates of the image are called the world coordinate system, and the coordinate system of the movable key object in the image is called the object coordinate system. Although the texture is located in the coordinate system of the image, the texture always follows the object. Movement, which is equivalent to the coordinate system of the object, so in order to ensure the rotation of the texture to adapt to the conversion between the two coordinate systems, the image should be based on the aspect ratio of the image, the distance moved by the key point, and the rotation angle of the key object. Rotate the matrix transformation at any point.
图5示出了本发明实施例中转换模块的结构框图,包括:FIG. 5 is a structural block diagram of a conversion module in an embodiment of the present invention, including:
第一缩放单元,用于对图像上的任意一点,根据图像的宽高比,对该点的坐标进行缩放,获得缩放后的坐标。The first scaling unit is configured to scale the coordinates of the point according to the aspect ratio of the image to any point on the image to obtain the scaled coordinates.
第一平移单元,用于将旋转中心点的坐标由原点坐标平移至所述关键点的坐标,并根据关键点的移动距离对缩放后的坐标进行平移,获得第一次平移后的坐标。The first translation unit is configured to translate the coordinates of the rotation center point from the origin coordinates to the coordinates of the key point, and translate the scaled coordinates according to the moving distance of the key points to obtain the coordinates after the first translation.
需要注意的是,如果一个图形D绕某点O旋转α°后,得到的新图形与原图形完全重合,称D为旋转对称图形,称O为旋转对称图形D的旋转中心点。为了保证贴图能够以某个特定位置进行旋转,需要将旋转中心平移至特定位置,以保证旋转后的图像与原图像完全重合,在本发明的应用场景下,旋转中心点即为关键点,所谓的关键点,简单的说,就是贴图需要始终对齐的点,以在人的眼睛上进行贴图为例,关键点可以是人的眼睛的区域的中心点(假设这一点是瞳孔的坐标)。显然,本实施例中所述旋转中心点是指图像中人脸移动后的关键点,同样以上述举例来说,就是人脸移动后瞳孔的坐标。当然,本发明并不局限于对人眼进行贴图,本发明同样适用于对人脸其他部位,例如鼻子、嘴巴或者眉毛的贴图,在此不做赘述。It should be noted that if a graphic D is rotated by α° around a certain point O, the obtained new graphic completely coincides with the original graphic, and D is called a rotationally symmetric figure, and O is called the rotation center point of the rotationally symmetric figure D. In order to ensure that the texture can be rotated at a specific position, the rotation center needs to be translated to a specific position to ensure that the rotated image completely coincides with the original image. In the application scenario of the present invention, the rotation center point is a key point, so-called The key point, to put it simply, is that the texture needs to be aligned at all times, for example, for mapping on the human eye, the key point can be the center point of the region of the human eye (assuming this is the coordinates of the pupil). Obviously, the rotation center point in the embodiment refers to a key point after the face is moved in the image, and also in the above example, the coordinates of the pupil after the face is moved. Of course, the present invention is not limited to the mapping of the human eye, and the present invention is equally applicable to the mapping of other parts of the face, such as the nose, mouth or eyebrows, and will not be described herein.
旋转单元,用于根据关键物体的转动角度以及旋转中心点的坐标,对该第一次平移后的坐标进行旋转,获得旋转后的坐标。The rotation unit is configured to rotate the coordinates after the first translation according to the rotation angle of the key object and the coordinates of the rotation center point, and obtain the rotated coordinates.
需要注意的是,人脸的旋转角度可通过人脸上关键点的位置计算出来,例如,计算鼻梁与水平方向X轴的角度,在此不再详细给出计算公式。因此,为了保证旋转后的坐标与人脸的旋转角度一致且形状不发生改变,本实施例通过根据人脸的旋转角度以及旋转中心点的坐标,对该第一次平移后的坐标进行旋转来获得。It should be noted that the rotation angle of the face can be calculated from the position of the key points on the human face. For example, the angle between the bridge of the nose and the X-axis in the horizontal direction is calculated, and the calculation formula is not given in detail here. Therefore, in order to ensure that the rotated coordinates coincide with the rotation angle of the face and the shape does not change, the embodiment rotates the coordinates after the first translation according to the rotation angle of the face and the coordinates of the rotation center point. obtain.
第二平移单元,用于将旋转中心点的坐标由所述关键点的坐标平移回原点坐标,并根据旋转中心点的移动距离对缩放后的坐标进行平移,获得第二次平移后的坐标;以及a second translation unit, configured to translate coordinates of the rotation center point from coordinates of the key point back to the origin coordinates, and translate the scaled coordinates according to the moving distance of the rotation center point to obtain coordinates after the second translation; as well as
第二缩放单元,用于将所述第二次平移后的坐标缩放回原比例,获得所述转换后的坐标。a second scaling unit, configured to scale the coordinates after the second translation back to the original scale to obtain the converted coordinates.
在一个实施例中,附近坐标生成装置包括:In one embodiment, the nearby coordinate generation device comprises:
缩放系数获取模块,用于基于关键物体的纵向长度、贴图宽度以及图像的宽度,获得贴图在x轴的缩放系数,基于关键物体的纵向长 度、贴图高度以及图像的高度,获得贴图在y轴的缩放系数;A scaling factor acquisition module for obtaining a scaling factor of the texture on the x-axis based on the longitudinal length of the key object, the width of the texture, and the width of the image, and obtaining the texture on the y-axis based on the longitudinal length of the key object, the height of the texture, and the height of the image. Scaling factor
附件坐标获取模块,用于对于任意一个旋转后的坐标,定义该旋转后的坐标为(dstx,dsty),关键点的坐标为(centerx,centery),当该旋转后的坐标满足以下条件:(centerx-resizex*0.5)<dstx≤(centerx+resizex*0.5)且(centery–resizey*0.5)<dsty≤(centery+resizey*0.5),则将该旋转后的坐标作为位于关键点移动后的位置附近一定范围的坐标。The attachment coordinate acquisition module is configured to define (dstx, dsty) the coordinate after the rotation for any one of the rotated coordinates, and the coordinates of the key point are (centerx, centery), and the coordinates after the rotation satisfy the following conditions: Centerx-resizex*0.5)<dstx≤(centerx+resizex*0.5) and (centery–resizey*0.5)<dsty≤(centery+resizey*0.5), the rotated coordinates are taken as the position after the key point is moved A certain range of coordinates nearby.
在一个具体实施例中,所述贴图采样坐标获得装置进一步用于:In a specific embodiment, the texture sampling coordinate obtaining device is further configured to:
定义位于关键点移动后的位置附近一定范围的坐标为(near x,near y),贴图采样坐标为(coord x,coord y),则: The coordinates of a certain range around the position after the key point is moved are (near x , near y ), and the coordinates of the texture sample are (coord x , coord y ), then:
coord x=(near x-center x+resize x*0.5)/resize xCoord x =(near x -center x +resize x *0.5)/resize x ;
coord y=(near y-center y+resize y*0.5)/resize yCoord y =(near y -center y +resize y *0.5)/resize y .
在一个实施例中,本发明公开一种自适应贴图设备,如图6所示,包括:In one embodiment, the present invention discloses an adaptive mapping device, as shown in FIG. 6, comprising:
至少一个处理器601、至少一个存储器602和总线603;其中,At least one processor 601, at least one memory 602, and a bus 603; wherein
所述处理器601和存储器602通过所述总线603完成相互间的通信;所述存储器602存储有可被所述处理器601执行的程序指令,所述处理器602调用所述程序指令能够执行上述各方法实施例所提供的方法,例如包括:The processor 601 and the memory 602 complete communication with each other through the bus 603; the memory 602 stores program instructions executable by the processor 601, and the processor 602 invokes the program instructions to execute the above The methods provided by the method embodiments include, for example:
S1、定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的旋转矩阵转换后的坐标;S1. Positioning the key points on the key object in the positioning image, performing rotation matrix conversion on any point on the image according to the position change after the key point is moved, and obtaining coordinates converted by the rotation matrix corresponding to any point;
S2、根据关键点移动后的坐标与贴图的缩放系数,获得位于关键点移动后的位置附近一定范围的坐标;S2, according to the coordinate of the key point after moving and the scaling factor of the texture, obtain a certain range of coordinates near the position after the key point is moved;
S3、根据所述位于关键点移动后的位置附近一定范围的坐标、关键点的坐标以及贴图的缩放系数,获得贴图采样坐标,并在所述贴图采样坐标上显示贴图。S3. Obtain a map sampling coordinate according to a certain range of coordinates, a coordinate of a key point, and a scaling factor of the map near the position after the key point is moved, and display the map on the map sampling coordinate.
在一个实施例中,本发明公开一种计算机程序产品,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,计算机能够执行上述各方法实施例所提供的方法,例如包括:In one embodiment, the present invention discloses a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions when the program instructions are When the computer is executed, the computer can perform the methods provided by the foregoing method embodiments, including, for example:
S1、定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的旋转矩阵转换后的坐标;S1. Positioning the key points on the key object in the positioning image, performing rotation matrix conversion on any point on the image according to the position change after the key point is moved, and obtaining coordinates converted by the rotation matrix corresponding to any point;
S2、根据关键点移动后的坐标与贴图的缩放系数,获得位于关键点移动后的位置附近一定范围的坐标;S2, according to the coordinate of the key point after moving and the scaling factor of the texture, obtain a certain range of coordinates near the position after the key point is moved;
S3、根据所述位于关键点移动后的位置附近一定范围的坐标、关键点的坐标以及贴图的缩放系数,获得贴图采样坐标,并在所述贴图采样坐标上显示贴图。S3. Obtain a map sampling coordinate according to a certain range of coordinates, a coordinate of a key point, and a scaling factor of the map near the position after the key point is moved, and display the map on the map sampling coordinate.
在一个实施例中,本发明公开了一种非暂态计算机可读存储介质,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令使所述计算机执行上述各方法实施例所提供的方法,例如包括:In one embodiment, the present invention discloses a non-transitory computer readable storage medium storing computer instructions that cause the computer to perform the various method embodiments described above The methods provided include, for example:
S1、定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的转换后的坐标;S1. Positioning the key points on the key object in the positioning image, performing rotation matrix conversion on any point on the image according to the position change of the key point after moving, to obtain the converted coordinates corresponding to any point;
S2、根据关键点移动后的坐标与贴图的缩放系数,获得位于关键点移动后的位置附近一定范围的坐标;S2, according to the coordinate of the key point after moving and the scaling factor of the texture, obtain a certain range of coordinates near the position after the key point is moved;
S3、根据所述位于关键点移动后的位置附近一定范围的坐标、关键点的坐标以及贴图的缩放系数,获得贴图采样坐标,并在所述贴图 采样坐标上显示贴图。S3. Obtain a map sampling coordinate according to a certain range of coordinates, a coordinate of a key point, and a scaling factor of the map located near the position after the key point is moved, and display the map on the map sampling coordinate.
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。A person skilled in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by using hardware related to the program instructions. The foregoing program may be stored in a computer readable storage medium, and the program is executed when executed. The foregoing steps include the steps of the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
以上所描述的一种操作数据库的设备等实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。The above described embodiments of an apparatus for operating a database are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be Physical units can be located in one place or distributed to multiple network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. Those of ordinary skill in the art can understand and implement without deliberate labor.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the various embodiments can be implemented by means of software plus a necessary general hardware platform, and of course, by hardware. Based on such understanding, the above-described technical solutions may be embodied in the form of software products in essence or in the form of software products, which may be stored in a computer readable storage medium such as ROM/RAM, magnetic Discs, optical discs, etc., include instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform the methods described in various embodiments or portions of the embodiments.
最后,本申请的方法仅为较佳的实施方案,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。Finally, the method of the present application is only a preferred embodiment and is not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and scope of the present invention are intended to be included within the scope of the present invention.

Claims (13)

  1. 一种随图像中关键点移动的自适应贴图方法,其特征在于,包括:An adaptive mapping method that moves with key points in an image, and includes:
    S1、定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的经旋转矩阵转换后的坐标;S1. Positioning a key point on a key object in the positioning image, performing rotation matrix conversion on any point on the image according to the position change after the key point is moved, and obtaining a coordinate converted by the rotation matrix corresponding to an arbitrary point;
    S2、根据关键点移动后的坐标与贴图的缩放系数,获得位于关键点移动后的位置附近一定范围的坐标;S2, according to the coordinate of the key point after moving and the scaling factor of the texture, obtain a certain range of coordinates near the position after the key point is moved;
    S3、根据所述位于关键点移动后的位置附近一定范围的坐标、关键点的坐标以及贴图的缩放系数,获得贴图采样坐标,并在所述贴图采样坐标上显示贴图。S3. Obtain a map sampling coordinate according to a certain range of coordinates, a coordinate of a key point, and a scaling factor of the map near the position after the key point is moved, and display the map on the map sampling coordinate.
  2. 如权利要求1所述的自适应贴图方法,其特征在于,所述步骤S1进一步包括:The adaptive mapping method according to claim 1, wherein the step S1 further comprises:
    S1.1、获取图像的宽高比,定位图像中关键物体上关键点的位置;S1.1. Obtain an aspect ratio of the image, and locate a key point on a key object in the image;
    S1.2、获取关键点移动的距离以及关键物体的转动角度;以及S1.2. Obtaining the distance moved by the key point and the rotation angle of the key object;
    S1.3、根据图像的宽高比、关键点移动的距离以及关键物体的转动角度,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的旋转矩阵转换后的坐标。S1.3. Perform a rotation matrix transformation on any point on the image according to the aspect ratio of the image, the distance moved by the key point, and the rotation angle of the key object, and obtain the coordinates after the rotation matrix transformation corresponding to any point.
  3. 如权利要求2所述的自适应贴图方法,其特征在于,所述步骤S1.3进一步包括:The adaptive mapping method according to claim 2, wherein the step S1.3 further comprises:
    S1.3.1、对图像上的任意一点,根据图像的宽高比,对该点的坐标进行缩放,获得缩放后的坐标;S1.3.1, for any point on the image, according to the aspect ratio of the image, the coordinates of the point are scaled to obtain the scaled coordinates;
    S1.3.2、将旋转中心点的坐标由原点坐标平移至所述关键点的坐标,并根据关键点的移动距离对缩放后的坐标进行平移,获得第一次平移后的坐标;S1.3.2: shifting the coordinates of the rotation center point from the origin coordinate to the coordinate of the key point, and shifting the scaled coordinate according to the moving distance of the key point to obtain the coordinate after the first translation;
    S1.3.3、根据关键物体的转动角度以及旋转中心点的坐标,对该 第一次平移后的坐标进行旋转,获得旋转后的坐标;S1.3.3, according to the rotation angle of the key object and the coordinates of the rotation center point, the coordinates after the first translation are rotated to obtain the rotated coordinates;
    S1.3.4、将旋转中心点的坐标由所述关键点的坐标平移回原点坐标,并根据旋转中心点的移动距离对缩放后的坐标进行平移,获得第二次平移后的坐标;以及S1.3.4, shifting the coordinates of the rotation center point from the coordinates of the key point back to the origin coordinates, and translating the scaled coordinates according to the moving distance of the rotation center point to obtain the coordinates after the second translation;
    S1.3.5、将所述第二次平移后的坐标缩放回原比例,获得所述转换后的坐标。S1.3.5, scaling the coordinates after the second translation back to the original scale, and obtaining the converted coordinates.
  4. 如权利要求2所述的自适应贴图方法,其特征在于,所述步骤S1.3进一步包括:The adaptive mapping method according to claim 2, wherein the step S1.3 further comprises:
    S1.3.1、对于图像上的任意一点,将该点的坐标(x,y)转换为齐次坐标(x,y,1),基于图像的宽高比R,对该齐次坐标进行缩放,获得缩放后的坐标(R*x,y,1);S1.3.1, for any point on the image, the coordinates (x, y) of the point are converted into homogeneous coordinates (x, y, 1), and the homogeneous coordinates are scaled based on the aspect ratio R of the image. Get the scaled coordinates (R*x, y, 1);
    S1.3.2、将旋转中心点的坐标由原点坐标(0,0)平移至所述关键点的坐标(D x,D y),并根据关键点的移动距离对缩放后的坐标进行平移,获得第一次平移后的坐标(R*x+D x/R,y+D y,1); S1.3.2, shifting the coordinates of the rotation center point from the origin coordinates (0, 0) to the coordinates (D x , D y ) of the key points, and shifting the scaled coordinates according to the moving distance of the key points to obtain The coordinates after the first translation (R*x+D x /R, y+D y , 1);
    S1.3.3、根据关键物体的转动角度a以及旋转中心点的坐标,对该第一次平移后的坐标进行旋转,获得旋转后的坐标:((R*x+D x/R)*cosa-(y+D y)*sina,(R*x+D x/R)*sina-(y+D y)*cosa,1); S1.3.3, according to the rotation angle a of the key object and the coordinates of the rotation center point, rotate the coordinates after the first translation to obtain the rotated coordinates: ((R*x+D x /R)*cosa- (y+D y )*sina,(R*x+D x /R)*sina-(y+D y )*cosa,1);
    S1.3.4、将旋转中心点的坐标由所述关键点的坐标平移至原点坐标,并根据旋转中心点平移距离对旋转后的坐标进行平移,获得第二次平移后的坐标:((R*x+D x/R)*cosa-(y+D y)*sina-D x/R,(R*x+D x/R)*sina-(y+D y)*cosa-D y,1);以及 S1.3.4, shifting the coordinates of the rotation center point from the coordinates of the key point to the origin coordinates, and translating the rotated coordinates according to the translation distance of the rotation center point, and obtaining the coordinates after the second translation: ((R* x+D x /R)*cosa-(y+D y )*sina-D x /R,(R*x+D x /R)*sina-(y+D y )*cosa-D y ,1 );as well as
    S1.3.5、将所述第二次平移后的坐标缩放回原比例,获得所述转换后的坐标:((x+D x/R 2)*cosa-(y+D y)*sina-D x/R 2,(x+D x/R 2)*sina-(y+D y)*cosa-D y)。 S1.3.5, scaling the coordinates after the second translation back to the original scale, and obtaining the converted coordinates: ((x+D x /R 2 )*cosa-(y+D y )*sina-D x /R 2 , (x+D x /R 2 )*sina-(y+D y )*cosa-D y ).
  5. 如权利要求1所述的自适应贴图方法,其特征在于,所述步骤S2进一步包括:The adaptive mapping method according to claim 1, wherein the step S2 further comprises:
    S2.1、基于关键物体的纵向长度、贴图宽度以及图像的宽度,获得贴图在x轴的缩放系数,基于关键物体的纵向长度、贴图高度以及 图像的高度,获得贴图在y轴的缩放系数;S2.1. Obtain a scaling factor of the texture on the x-axis based on the longitudinal length of the key object, the width of the texture, and the width of the image, and obtain a scaling factor of the texture on the y-axis based on the longitudinal length of the key object, the height of the texture, and the height of the image;
    S2.2、对于任意一个经旋转矩阵转换后的坐标,定义该旋转矩阵转换后的坐标为(dst x,dst y),关键点的坐标为(center x,center y),当该旋转后的坐标满足以下条件:(center x-resize x*0.5)<dst x≤(center x+resize x*0.5)且(center y–resize y*0.5)<dst y≤(center y+resize y*0.5),则将该旋转矩阵转换后的坐标作为位于关键点移动后的位置附近一定范围的坐标; S2.2. For any coordinate converted by the rotation matrix, the coordinates after the transformation of the rotation matrix are defined as (dst x , dst y ), and the coordinates of the key point are (center x , center y ), when the rotation is The coordinates satisfy the following conditions: (center x -resize x *0.5)<dst x ≤(center x +resize x *0.5) and (center y –resize y *0.5)<dst y ≤(center y +resize y *0.5) , the coordinate converted by the rotation matrix is used as a coordinate of a certain range near the position after the key point is moved;
    其中,所述贴图在x轴的缩放系数resize x的表达式为:resize x=l*w/(W*r);所述贴图在y轴的缩放系数resize y的表达式为:resize y=l*h/(H*r); The expression of the scaling factor resize x of the texture on the x-axis is: resize x = l * w / (W * r); the expression of the scaling factor resize y of the texture on the y-axis is: resize y = L*h/(H*r);
    其中,l表示关键物体的纵向长度,w表示贴图的宽度,h表示贴图的高度,r表示显示系数,W表示图像的宽度,H表示图像的高度。Where l represents the longitudinal length of the key object, w represents the width of the texture, h represents the height of the texture, r represents the display coefficient, W represents the width of the image, and H represents the height of the image.
  6. 如权利要求5所述的自适应贴图方法,其特征在于,所述根据所述位于关键点移动后的位置附近一定范围的坐标、关键点的坐标以及贴图的缩放系数,获得贴图采样坐标的步骤,进一步包括:The adaptive mapping method according to claim 5, wherein the step of obtaining texture sampling coordinates according to a certain range of coordinates, a coordinate of a key point, and a scaling factor of the texture in the vicinity of the position after the movement of the key point , further including:
    定义位于关键点移动后的位置附近一定范围的坐标为(near x,near y),贴图采样坐标为(coord x,coord y),则: The coordinates of a certain range around the position after the key point is moved are (near x , near y ), and the coordinates of the texture sample are (coord x , coord y ), then:
    coord x=(near x-center x+resize x*0.5)/resize xCoord x =(near x -center x +resize x *0.5)/resize x ;
    coord y=(near y-center y+resize y*0.5)/resize yCoord y =(near y -center y +resize y *0.5)/resize y .
  7. 一种随图像中关键点移动的自适应贴图系统,其特征在于,包括:An adaptive mapping system that moves with key points in an image, and includes:
    转换坐标装置,定位图像中关键物体上关键点的位置,根据所述关键点移动后的位置变化,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的旋转矩阵转换后的坐标;Converting the coordinate device, locating the position of the key point on the key object in the image, performing a rotation matrix transformation on any point on the image according to the position change after the key point is moved, and obtaining the coordinate converted by the rotation matrix corresponding to any point;
    附近坐标生成装置,根据关键点移动后的坐标与贴图的缩放系数,获得位于关键点移动后的位置附近一定范围的坐标;The nearby coordinate generating device obtains a certain range of coordinates near the position after the key point is moved according to the coordinate of the key point movement and the scaling factor of the texture;
    贴图采样坐标获得装置,根据所述位于关键点移动后的位置附近 一定范围的坐标、关键点的坐标以及贴图的缩放系数,获得贴图采样坐标,并在所述贴图采样坐标上显示贴图。The texture sampling coordinate obtaining means obtains the texture sampling coordinates according to the coordinates of a certain range, the coordinates of the key points, and the scaling factor of the texture in the vicinity of the position after the movement of the key point, and displays the texture on the texture sampling coordinates.
  8. 如权利要求7所述的自适应贴图系统,其特征在于,所述转换坐标装置包括:The adaptive mapping system of claim 7 wherein said converting coordinate means comprises:
    定位模块,用于获取图像的宽高比,定位图像中关键物体上关键点的位置;a positioning module for acquiring an aspect ratio of an image and locating a position of a key point on a key object in the image;
    获取关键点参数模块、用于获取关键点移动的距离以及关键物体的转动角度;以及Obtain a key point parameter module, a distance for obtaining key point movement, and a rotation angle of a key object;
    转换模块,用于根据图像的宽高比、关键点移动的距离以及关键物体的转动角度,对图像上的任意一点进行旋转矩阵转换,获得对应该任意一点的转换后的坐标。The conversion module is configured to perform rotation matrix conversion on any point on the image according to the aspect ratio of the image, the distance moved by the key point, and the rotation angle of the key object, to obtain the converted coordinates corresponding to any point.
  9. 如权利要求8所述的自适应贴图系统,其特征在于,所述附近坐标生成装置包括:The adaptive mapping system of claim 8 wherein said nearby coordinate generation means comprises:
    缩放系数获取模块,用于基于关键物体的纵向长度、贴图宽度以及图像的宽度,获得贴图在x轴的缩放系数,基于关键物体的纵向长度、贴图高度以及图像的高度,获得贴图在y轴的缩放系数;A scaling factor acquisition module for obtaining a scaling factor of the texture on the x-axis based on the longitudinal length of the key object, the width of the texture, and the width of the image, and obtaining the texture on the y-axis based on the longitudinal length of the key object, the height of the texture, and the height of the image. Scaling factor
    附件坐标获取模块,用于对于任意一个旋转后的坐标,定义该旋转后的坐标为(dstx,dsty),关键点的坐标为(centerx,centery),当该旋转后的坐标满足以下条件:(centerx-resizex*0.5)<dstx≤(centerx+resizex*0.5)且(centery–resizey*0.5)<dsty≤(centery+resizey*0.5),则将该旋转后的坐标作为位于关键点移动后的位置附近一定范围的坐标。The attachment coordinate acquisition module is configured to define (dstx, dsty) the coordinate after the rotation for any one of the rotated coordinates, and the coordinates of the key point are (centerx, centery), and the coordinates after the rotation satisfy the following conditions: Centerx-resizex*0.5)<dstx≤(centerx+resizex*0.5) and (centery–resizey*0.5)<dsty≤(centery+resizey*0.5), the rotated coordinates are taken as the position after the key point is moved A certain range of coordinates nearby.
  10. 如权利要求9所述的自适应贴图系统,其特征在于,所述贴图采样坐标获得装置进一步用于:The adaptive mapping system according to claim 9, wherein the texture sampling coordinate obtaining means is further configured to:
    定义位于关键点移动后的位置附近一定范围的坐标为(near x,near y),贴图采样坐标为(coord x,coord y),则: The coordinates of a certain range around the position after the key point is moved are (near x , near y ), and the coordinates of the texture sample are (coord x , coord y ), then:
    coord x=(near x-center x+resize x*0.5)/resize xCoord x =(near x -center x +resize x *0.5)/resize x ;
    coord y=(near y-center y+resize y*0.5)/resize yCoord y =(near y -center y +resize y *0.5)/resize y .
  11. 一种自适应贴图设备,其特征在于,包括:An adaptive mapping device, comprising:
    至少一个处理器、至少一个存储器和总线;其中,At least one processor, at least one memory, and a bus; wherein
    所述处理器和存储器通过所述总线完成相互间的通信;所述存储器存储有可被所述处理器执行的程序指令,所述处理器调用所述程序指令能够执行如权利要求1至6任一所述的方法。The processor and the memory complete communication with each other through the bus; the memory stores program instructions executable by the processor, the processor invoking the program instructions capable of performing any of claims 1 to 6 A method as described.
  12. 一种计算机程序产品,其特征在于,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使所述计算机执行如权利要求1至6任一所述的方法。A computer program product, comprising: a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer, The computer performs the method of any of claims 1 to 6.
  13. 一种非暂态计算机可读存储介质,其特征在于,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令使所述计算机执行如权利要求1至6任一所述的方法。A non-transitory computer readable storage medium, wherein the non-transitory computer readable storage medium stores computer instructions, the computer instructions causing the computer to perform the method of any one of claims 1 to 6. .
PCT/CN2017/120135 2017-03-28 2017-12-29 Adaptive mapping method and system depending on movement of key points in image WO2018176958A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710193044.4 2017-03-28
CN201710193044.4A CN107122774B (en) 2017-03-28 2017-03-28 A kind of adaptive chart pasting method and system mobile with key point in image

Publications (1)

Publication Number Publication Date
WO2018176958A1 true WO2018176958A1 (en) 2018-10-04

Family

ID=59717365

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/120135 WO2018176958A1 (en) 2017-03-28 2017-12-29 Adaptive mapping method and system depending on movement of key points in image

Country Status (2)

Country Link
CN (1) CN107122774B (en)
WO (1) WO2018176958A1 (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109614059A (en) * 2018-12-19 2019-04-12 森大(深圳)技术有限公司 Gerber document handling method, device and computer readable storage medium
CN111126344A (en) * 2019-12-31 2020-05-08 杭州趣维科技有限公司 Method and system for generating key points of forehead of human face
CN111652918A (en) * 2020-06-04 2020-09-11 深圳地平线机器人科技有限公司 Method, apparatus, medium, and electronic device for determining 3D face model
CN113487717A (en) * 2021-07-13 2021-10-08 网易(杭州)网络有限公司 Picture processing method and device, computer readable storage medium and electronic equipment
CN114119684A (en) * 2020-08-31 2022-03-01 中国移动通信集团浙江有限公司 Marker point registration method based on tetrahedral structure
CN114429666A (en) * 2022-04-06 2022-05-03 深圳市大头兄弟科技有限公司 Video face replacement method, device, equipment and storage medium

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107122774B (en) * 2017-03-28 2019-12-03 武汉斗鱼网络科技有限公司 A kind of adaptive chart pasting method and system mobile with key point in image
CN109509140A (en) * 2017-09-15 2019-03-22 阿里巴巴集团控股有限公司 Display methods and device
CN109587390B (en) * 2017-09-29 2021-05-07 腾讯科技(深圳)有限公司 Picture rendering method, picture rendering device and storage medium
CN107679497B (en) * 2017-10-11 2023-06-27 山东新睿信息科技有限公司 Video face mapping special effect processing method and generating system
CN107808372B (en) * 2017-11-02 2022-01-28 北京奇虎科技有限公司 Image crossing processing method and device, computing equipment and computer storage medium
CN108205822B (en) * 2017-12-13 2020-09-08 中兴通讯股份有限公司 Picture pasting method and device
CN108305212A (en) * 2018-01-09 2018-07-20 武汉斗鱼网络科技有限公司 Image mixing method, storage medium, electronic equipment and system
CN110020577B (en) * 2018-01-10 2021-03-16 武汉斗鱼网络科技有限公司 Face key point expansion calculation method, storage medium, electronic device and system
CN108921000B (en) * 2018-04-16 2024-02-06 深圳市深网视界科技有限公司 Head angle labeling, prediction model training, prediction method, device and medium
CN108846878A (en) * 2018-06-07 2018-11-20 奇酷互联网络科技(深圳)有限公司 Face textures generation method, device, readable storage medium storing program for executing and mobile terminal
CN110378991A (en) * 2018-11-07 2019-10-25 深圳格调网络运营有限公司 The matching process of virtual environment drag and textures
CN109819316B (en) * 2018-12-28 2021-06-01 北京字节跳动网络技术有限公司 Method and device for processing face sticker in video, storage medium and electronic equipment
CN111383170B (en) * 2018-12-28 2023-08-15 广州市百果园网络科技有限公司 Picture key point adjusting method, device and terminal
CN112489157B (en) * 2020-12-18 2024-03-19 广州视源电子科技股份有限公司 Photo frame drawing method, device and storage medium
CN113687823B (en) * 2021-07-30 2023-08-01 稿定(厦门)科技有限公司 Quadrilateral block nonlinear transformation method and system based on HTML

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130083976A1 (en) * 2011-10-03 2013-04-04 Qualcomm Incorporated Image-based head position tracking method and system
CN103090875A (en) * 2012-11-26 2013-05-08 华南理工大学 Real-time real-scene matching vehicle navigation method and device based on double cameras
CN104881114A (en) * 2015-05-13 2015-09-02 深圳彼爱其视觉科技有限公司 Angle rotation real-time matching method based on try wearing of 3D (three dimensional) glasses
CN104881526A (en) * 2015-05-13 2015-09-02 深圳彼爱其视觉科技有限公司 Article wearing method and glasses try wearing method based on 3D (three dimensional) technology
CN104898832A (en) * 2015-05-13 2015-09-09 深圳彼爱其视觉科技有限公司 Intelligent terminal based 3D real-time glass fitting method
CN104899917A (en) * 2015-05-13 2015-09-09 深圳彼爱其视觉科技有限公司 Image storage and sharing method of virtual item wear based on 3D
CN107122774A (en) * 2017-03-28 2017-09-01 武汉斗鱼网络科技有限公司 A kind of adaptive chart pasting method moved with key point in image and system

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101231658A (en) * 2008-02-02 2008-07-30 谢亦玲 Ornaments computer simulation wearing apparatus
CN105719351B (en) * 2014-12-04 2018-09-28 高德软件有限公司 A kind of method and apparatus of display electronic map
CN105069745A (en) * 2015-08-14 2015-11-18 济南中景电子科技有限公司 face-changing system based on common image sensor and enhanced augmented reality technology and method
CN105354876B (en) * 2015-10-20 2018-10-09 何家颖 A kind of real-time volume fitting method based on mobile terminal

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130083976A1 (en) * 2011-10-03 2013-04-04 Qualcomm Incorporated Image-based head position tracking method and system
CN103090875A (en) * 2012-11-26 2013-05-08 华南理工大学 Real-time real-scene matching vehicle navigation method and device based on double cameras
CN104881114A (en) * 2015-05-13 2015-09-02 深圳彼爱其视觉科技有限公司 Angle rotation real-time matching method based on try wearing of 3D (three dimensional) glasses
CN104881526A (en) * 2015-05-13 2015-09-02 深圳彼爱其视觉科技有限公司 Article wearing method and glasses try wearing method based on 3D (three dimensional) technology
CN104898832A (en) * 2015-05-13 2015-09-09 深圳彼爱其视觉科技有限公司 Intelligent terminal based 3D real-time glass fitting method
CN104899917A (en) * 2015-05-13 2015-09-09 深圳彼爱其视觉科技有限公司 Image storage and sharing method of virtual item wear based on 3D
CN107122774A (en) * 2017-03-28 2017-09-01 武汉斗鱼网络科技有限公司 A kind of adaptive chart pasting method moved with key point in image and system

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109614059A (en) * 2018-12-19 2019-04-12 森大(深圳)技术有限公司 Gerber document handling method, device and computer readable storage medium
CN111126344A (en) * 2019-12-31 2020-05-08 杭州趣维科技有限公司 Method and system for generating key points of forehead of human face
CN111126344B (en) * 2019-12-31 2023-08-01 杭州趣维科技有限公司 Method and system for generating key points of forehead of human face
CN111652918A (en) * 2020-06-04 2020-09-11 深圳地平线机器人科技有限公司 Method, apparatus, medium, and electronic device for determining 3D face model
CN111652918B (en) * 2020-06-04 2023-08-18 深圳地平线机器人科技有限公司 Method, device, medium and electronic equipment for determining 3D face model
CN114119684A (en) * 2020-08-31 2022-03-01 中国移动通信集团浙江有限公司 Marker point registration method based on tetrahedral structure
CN114119684B (en) * 2020-08-31 2023-02-28 中国移动通信集团浙江有限公司 Marker point registration method based on tetrahedral structure
CN113487717A (en) * 2021-07-13 2021-10-08 网易(杭州)网络有限公司 Picture processing method and device, computer readable storage medium and electronic equipment
CN113487717B (en) * 2021-07-13 2024-02-23 网易(杭州)网络有限公司 Picture processing method and device, computer readable storage medium and electronic equipment
CN114429666A (en) * 2022-04-06 2022-05-03 深圳市大头兄弟科技有限公司 Video face replacement method, device, equipment and storage medium
CN114429666B (en) * 2022-04-06 2022-07-01 深圳市大头兄弟科技有限公司 Video face replacement method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN107122774B (en) 2019-12-03
CN107122774A (en) 2017-09-01

Similar Documents

Publication Publication Date Title
WO2018176958A1 (en) Adaptive mapping method and system depending on movement of key points in image
US11645801B2 (en) Method for synthesizing figure of virtual object, electronic device, and storage medium
WO2022002032A1 (en) Image-driven model training and image generation
CN110517214B (en) Method and apparatus for generating image
CN108769517A (en) A kind of method and apparatus carrying out remote assistant based on augmented reality
WO2023019974A1 (en) Correction method and apparatus for document image, and electronic device and storage medium
US20220358675A1 (en) Method for training model, method for processing video, device and storage medium
CN109754464B (en) Method and apparatus for generating information
WO2023035531A1 (en) Super-resolution reconstruction method for text image and related device thereof
CN115147265B (en) Avatar generation method, apparatus, electronic device, and storage medium
CN115668300A (en) Object reconstruction with texture resolution
WO2018113339A1 (en) Projection image construction method and device
JP2021523455A (en) Projection distortion correction for the face
WO2022016996A1 (en) Image processing method, device, electronic apparatus, and computer readable storage medium
US9196096B2 (en) 3D-consistent 2D manipulation of images
US11170550B2 (en) Facial animation retargeting using an anatomical local model
CN112528707A (en) Image processing method, device, equipment and storage medium
US10768692B2 (en) Systems and methods for capturing and rendering hand skeletons over documents images for telepresence
US20240046554A1 (en) Presenting virtual representation of real space using spatial transformation
CN112734628A (en) Method and system for calculating projection position of tracking point after three-dimensional conversion
CN108171802B (en) Panoramic augmented reality implementation method realized by combining cloud and terminal
US11663752B1 (en) Augmented reality processing device and method
CN112465692A (en) Image processing method, device, equipment and storage medium
US20240096000A1 (en) Method, device, and computer program product for rendering image
EP4350605A1 (en) Image processing method and apparatus, device, and medium

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17902963

Country of ref document: EP

Kind code of ref document: A1