












技术领域technical field
本发明涉及计算机领域,具体而言,涉及一种相机参数确定方法、图 像处理方法、存储介质及电子装置。The present invention relates to the field of computers, and in particular, to a camera parameter determination method, an image processing method, a storage medium and an electronic device.
背景技术Background technique
目前,对于相机参数的确定可以采用借助标定物的确定方式,通过标 定物上多个点对应的世界坐标系中的坐标,以及该标定物的多个点在图 像坐标系中的坐标,建立世界坐标系与图像坐标系之间的映射关系,求 解获得相机参数。At present, the camera parameters can be determined by means of a calibration object, and the world coordinate system can be established by using the coordinates in the world coordinate system corresponding to multiple points on the calibration object, and the coordinates of the multiple points of the calibration object in the image coordinate system. The mapping relationship between the coordinate system and the image coordinate system is solved to obtain the camera parameters.
在实践中发现,上述借助标定物的确定方式需要使用待确定参数的相 机拍摄标定物,而无法针对确定的图像确定相机参数,对此,可以采用 消失点法来对确定的图像确定相机参数。具体的,需要在图像上确定出 至少两组正交的平行线,根据每组正交的平行线确定出消失点,通过消 失点的坐标来确定相机参数。但是很多图像中不存在正交的平行线,此 时也无法采用这种消失点法来确定相机参数。可见,针对不存在正交的 平行线的指定图像,尚且不能够确定出该图像对应的相机参数。In practice, it is found that the above-mentioned determination method by means of the calibration object requires the use of the camera with the parameters to be determined to shoot the calibration object, and the camera parameters cannot be determined for the determined image. In this regard, the vanishing point method can be used to determine the camera parameters for the determined image. Specifically, at least two groups of orthogonal parallel lines need to be determined on the image, the vanishing point is determined according to each group of orthogonal parallel lines, and the camera parameters are determined by the coordinates of the vanishing point. However, there are no orthogonal parallel lines in many images, and this vanishing point method cannot be used to determine camera parameters. It can be seen that, for a specified image without orthogonal parallel lines, the camera parameters corresponding to the image cannot be determined yet.
针对上述的问题,目前尚未提出有效的解决方案。For the above problems, no effective solution has been proposed yet.
发明内容SUMMARY OF THE INVENTION
本发明实施例提供了一种相机参数确定方法、图像处理方法、存储介 质及电子装置,以至少能够确定出不存在正交的平行线的指定图像对应的 相机参数。Embodiments of the present invention provide a camera parameter determination method, an image processing method, a storage medium, and an electronic device, so as to at least determine camera parameters corresponding to a specified image without orthogonal parallel lines.
根据本发明实施例的一个方面,提供了一种相机参数确定方法,包括: 将目标图片输入目标识别模型中,其中,上述目标识别模型为利用多个样 本图片及与上述多个样本图片中每个样本图片分别匹配的图片参数标签 进行训练后得到的神经网络模型,上述目标识别模型用于识别拍摄上述样 本图片的相机的视角参数,上述视角参数包括:翻滚角、俯仰角及视场角; 获取上述目标识别模型输出的识别结果,其中,上述识别结果用于指示拍 摄上述目标图片的目标相机的视角参数;根据上述目标相机的视场角确定 上述目标相机的焦距。According to an aspect of the embodiments of the present invention, a method for determining camera parameters is provided, including: inputting a target picture into a target recognition model, wherein the target recognition model uses a plurality of sample pictures and a A neural network model obtained after training the image parameter labels matched with the sample images, the target recognition model is used to identify the viewing angle parameters of the camera that shoots the sample images, and the viewing angle parameters include: roll angle, pitch angle, and field of view angle; The recognition result output by the target recognition model is obtained, wherein the recognition result is used to indicate the viewing angle parameter of the target camera that captures the target picture; the focal length of the target camera is determined according to the field of view of the target camera.
根据本发明实施例的另一方面,还提供了一种相机参数确定装置,包 括:输入单元,用于将目标图片输入目标识别模型中,其中,上述目标识 别模型为利用多个样本图片及与上述多个样本图片中每个样本图片分别 匹配的图片参数标签进行训练后得到的神经网络模型,上述目标识别模型 用于识别拍摄上述样本图片的相机的视角参数,上述视角参数包括:翻滚 角、俯仰角及视场角;第一获取单元,用于获取上述目标识别模型输出的 识别结果,其中,上述识别结果用于指示拍摄上述目标图片的目标相机的 视角参数;确定单元,用于根据上述目标相机的视场角确定上述目标相机 的焦距。According to another aspect of the embodiments of the present invention, an apparatus for determining camera parameters is also provided, including: an input unit for inputting a target image into a target recognition model, wherein the target recognition model uses a plurality of sample pictures and A neural network model obtained after training the image parameter labels matched by each sample picture in the above-mentioned multiple sample pictures, the above-mentioned target recognition model is used to identify the viewing angle parameters of the camera that shoots the above-mentioned sample pictures, and the above-mentioned viewing angle parameters include: roll angle, a pitch angle and a field of view angle; a first acquisition unit, used for acquiring the recognition result output by the above-mentioned target recognition model, wherein the above-mentioned recognition result is used to indicate the angle of view parameter of the target camera that shoots the above-mentioned target picture; The field of view of the target camera determines the focal length of the above target camera.
根据本发明实施例的另一个方面,提供了一种图片处理方法,包括: 根据上述相机参数确定方法确定上述目标图片所对应的相机参数;获取目 标对象参数和待植入位置;基于上述相机参数、上述目标对象参数以及上 述待植入位置,将上述目标对象植入到上述目标图片中。According to another aspect of the embodiments of the present invention, there is provided a picture processing method, comprising: determining the camera parameters corresponding to the above target picture according to the above camera parameter determination method; acquiring the target object parameters and the position to be implanted; based on the above camera parameters , the above-mentioned target object parameters and the above-mentioned position to be implanted, and the above-mentioned target object is implanted into the above-mentioned target picture.
根据本发明实施例的另一个方面,提供了一种图片处理装置,包括: 输入单元,用于将目标图片输入目标识别模型中,其中,上述目标识别模 型为利用多个样本图片及与上述多个样本图片中每个样本图片分别匹配 的图片参数标签进行训练后得到的神经网络模型,上述目标识别模型用于 识别拍摄上述样本图片的相机的视角参数,上述视角参数包括:翻滚角、 俯仰角及视场角;第一获取单元,用于获取上述目标识别模型输出的识别 结果,其中,上述识别结果用于指示拍摄上述目标图片的目标相机的视角 参数;确定单元,用于根据上述目标相机的视场角确定上述目标相机的焦 距;目标对象获取单元,用于获取待植入的目标对象参数以及待植入位置; 植入单元,用于基于上述相机参数、上述目标对象参数以及上述待植入位 置,将上述目标对象植入到上述目标图片中。According to another aspect of the embodiments of the present invention, a picture processing apparatus is provided, including: an input unit, configured to input a target picture into a target recognition model, wherein the target recognition model uses a plurality of sample pictures and the A neural network model obtained after training the image parameter labels matched by each sample picture in the sample pictures, the above-mentioned target recognition model is used to identify the perspective parameters of the camera that took the above-mentioned sample pictures, and the above-mentioned perspective parameters include: roll angle, pitch angle and a field of view; a first acquisition unit, used for acquiring the recognition result output by the above-mentioned target recognition model, wherein the above-mentioned recognition result is used to indicate the angle of view parameter of the target camera that shoots the above-mentioned target picture; a determining unit is used for according to the above-mentioned target camera The focal length of the above-mentioned target camera is determined by the angle of view of the target object; the target object acquisition unit is used to obtain the parameters of the target object to be implanted and the position to be implanted; At the implantation position, the above target object is implanted into the above target picture.
根据本发明实施例的又一方面,还提供了一种存储介质,该存储介质 中存储有计算机程序,其中,该计算机程序被设置为运行时执行上述相机 参数确定方法或者上述图片处理方法。According to another aspect of the embodiments of the present invention, a storage medium is also provided, and a computer program is stored in the storage medium, wherein the computer program is configured to execute the above-mentioned camera parameter determination method or the above-mentioned picture processing method when running.
根据本发明实施例的又一方面,还提供了一种电子装置,包括存储器、 处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,上述 处理器通过计算机程序执行上述相机参数确定方法或者上述图片处理方 法。According to another aspect of the embodiments of the present invention, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the camera through the computer program. The parameter determination method or the above-mentioned image processing method.
在本发明实施例中,将目标图片输入目标识别模型中,其中,目标识 别模型为利用多个样本图片及与多个样本图片中每个样本图片分别匹配 的图片参数标签进行训练后得到的神经网络模型,目标识别模型用于识别 拍摄样本图片的相机的视角参数,视角参数包括:翻滚角、俯仰角及视场 角;获取目标识别模型输出的识别结果,其中,识别结果用于指示拍摄目 标图片的目标相机的视角参数;根据目标相机的视场角确定目标相机的焦距。这一过程可以通过训练好的目标识别模型根据图片特征确定出目标相 机的翻滚角、俯仰角以及相机焦距等相机参数,无需依赖标定物,并且无 需目标图片中存在正交的平行线,能够实现确定出不存在正交的平行线的 指定图像对应的相机参数。In the embodiment of the present invention, the target image is input into the target recognition model, wherein the target recognition model is a neural network obtained after training using multiple sample images and image parameter labels that match each sample image in the multiple sample images. Network model, the target recognition model is used to identify the viewing angle parameters of the camera that shoots the sample picture, and the viewing angle parameters include: roll angle, pitch angle and field of view angle; obtain the recognition result output by the target recognition model, wherein the recognition result is used to indicate the shooting target The viewing angle parameter of the target camera of the picture; the focal length of the target camera is determined according to the field of view of the target camera. In this process, camera parameters such as roll angle, pitch angle and camera focal length of the target camera can be determined by the trained target recognition model according to the image features, without relying on calibration objects, and without the existence of orthogonal parallel lines in the target image, which can achieve Determine the camera parameters corresponding to the specified image for which there are no orthogonal parallel lines.
附图说明Description of drawings
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一 部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发 明的不当限定。在附图中:The accompanying drawings described herein are used to provide a further understanding of the present invention, and constitute a part of the present application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention, and do not constitute an improper limitation of the present invention. In the attached image:
图1是根据本发明实施例的一种可选的相机参数确定方法的网络环境 的示意图;1 is a schematic diagram of a network environment of an optional camera parameter determination method according to an embodiment of the present invention;
图2是根据本发明实施例的一种可选的广告植入的应用示意图;FIG. 2 is an application schematic diagram of an optional advertisement implantation according to an embodiment of the present invention;
图3是根据本发明实施例的一种可选的相机参数确定方法的流程图;3 is a flowchart of an optional camera parameter determination method according to an embodiment of the present invention;
图4是根据本发明实施例的一种可选的相机参数的确定示意图;FIG. 4 is a schematic diagram of determining an optional camera parameter according to an embodiment of the present invention;
图5是根据本发明实施例的一种可选的对识别模型进行训练的示意图;5 is a schematic diagram of an optional training recognition model according to an embodiment of the present invention;
图6是根据本发明实施例的一种可选的生成样本图片的示意图;6 is a schematic diagram of an optional sample image generation according to an embodiment of the present invention;
图7是根据本发明实施例的一种可选的误差函数的训练结果的示意图;7 is a schematic diagram of a training result of an optional error function according to an embodiment of the present invention;
图8是根据本发明实施例的一种可选的第一坐标和第二坐标的选取示 意图;8 is a schematic diagram of the selection of an optional first coordinate and a second coordinate according to an embodiment of the present invention;
图9是根据本发明实施例的一种可选的图片处理方法的流程图;9 is a flowchart of an optional image processing method according to an embodiment of the present invention;
图10是根据本发明实施例的一种可选的相机参数确定装置的结构示 意图;10 is a schematic structural diagram of an optional camera parameter determination device according to an embodiment of the present invention;
图11是根据本发明实施例的一种可选的图片处理装置的结构示意图;11 is a schematic structural diagram of an optional picture processing apparatus according to an embodiment of the present invention;
图12是根据本发明实施例的一种可选的电子装置的结构示意图;12 is a schematic structural diagram of an optional electronic device according to an embodiment of the present invention;
图13是根据本发明实施例的一种可选的电子装置的结构示意图。FIG. 13 is a schematic structural diagram of an optional electronic device according to an embodiment of the present invention.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明 实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述, 显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施 例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动 前提下所获得的所有其他实施例,都应当属于本发明保护的范围。In order to make those skilled in the art better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only Embodiments are part of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention.
需要说明的是,本发明的说明书和权利要求书及上述附图中的术语 “第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或 先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描 述的本发明的实施例能够以除了在这里图示或描述的那些以外的顺序实 施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排 他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或 设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出 的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific sequence or sequence. It is to be understood that the data so used may be interchanged under appropriate circumstances such that the embodiments of the invention described herein can be practiced in sequences other than those illustrated or described herein. Furthermore, the terms "comprising" and "having" and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those expressly listed Rather, those steps or units may include other steps or units not expressly listed or inherent to these processes, methods, products or devices.
根据本发明实施例的一个方面,提供了一种相机参数确定方法,可选 地,作为一种可选的实施方式,上述相机参数确定方法可以但不限于应用 于如图1所示的网络环境中的相机参数确定系统中,该相机参数确定系统 包括用户设备102、网络110及服务器112。其中,用户设备102中包括 人机交互屏幕104,处理器106及存储器108。人机交互屏幕104用于显 示人机交互信息,例如可以显示用于提示用户输入目标图片的输入提示信 息,又或者,在接收到用户输入目标图片的输入指令之后,还可以显示目 标图片等,本发明实施例中不做限定;处理器106,用于获取用户输入的 目标图片,并将目标图片输入训练好的目标识别模型,其中,目标识别模 型可以利用多个样本图片及多个样本图片中每个样本图片分别匹配的图 片参数标签进行训练后得到的神经网络模型,将目标图片输入该目标识别 模型之后,目标识别模型可以输出拍摄该目标图片的目标相机的翻滚角、 俯仰角及视场角等视角参数。存储器108用于存储目标识别模型输出的识 别结果。可选的,目标识别模型可以搭建于用户设备102上,也可以搭建 于服务器114上。进一步的,在目标识别模型搭建于服务器114上的情况 下,服务器112可以对识别模型进行训练,具体的,服务器112中包括数 据库114及处理引擎116。其中,数据库114用于存储多个用于训练识别 模型的多个样本图片,并且每一样本图片具有对应存储的图片参数标签。 处理器引擎116用于将对应存储的样本图片和图片参数标签输入待训练的 识别模型,获得训练识别结果,训练识别结果为该样本图片对应的翻滚角、 俯仰角及视场角,将图片参数标签中的翻滚角、俯仰角以及视场角和训练 识别结果代入误差函数进行训练,可以获得视角权重,进而获得具有该视 角权重的目标识别模型,这一过程可以在服务器112上实现对目标识别模 型的训练,获得目标识别模型。在获得目标识别模型之后,用户设备102 可以将目标图片通过网络110发送给服务器112,服务器112可以将目标 识别模型输出的识别结果通过网络110返回给用户设备102。具体的,可 以执行以下步骤:According to an aspect of the embodiments of the present invention, a method for determining camera parameters is provided. Optionally, as an optional implementation manner, the above-mentioned method for determining camera parameters may be applied, but not limited to, in the network environment as shown in FIG. 1 . In the camera parameter determination system in , the camera parameter determination system includes the user equipment 102 , the network 110 and the server 112 . The user equipment 102 includes a human-
S101,用户设备102将目标图片发送给网络110;S101, the user equipment 102 sends the target picture to the network 110;
S102,网络110将目标图片发送给服务器112;S102, the network 110 sends the target image to the server 112;
S103,服务器112将目标图片输入目标识别模型,其中,目标识别模 型为利用多个样本图片及与多个样本图片中每个样本图片分别匹配的图 片参数标签进行训练后得到的神经网络模型,目标识别模型用于识别拍摄 样本图片的相机的视角参数,视角参数包括:翻滚角、俯仰角及视场角;S103, the server 112 inputs the target image into the target recognition model, wherein the target recognition model is a neural network model obtained after training by using multiple sample images and image parameter labels that are respectively matched with each sample image in the multiple sample images. The recognition model is used to identify the viewing angle parameters of the camera that took the sample image, and the viewing angle parameters include: roll angle, pitch angle and field of view angle;
S104,服务器112将目标识别模型输出的识别结果返回给网络110, 其中,识别结果用于指示拍摄目标图片的目标相机的视角参数;S104, the server 112 returns the recognition result output by the target recognition model to the network 110, wherein the recognition result is used to indicate the viewing angle parameter of the target camera that shoots the target picture;
S105,网络110将识别结果返回给用户设备102;S105, the network 110 returns the identification result to the user equipment 102;
S106,用户设备102获取该识别结果,并根据目标相机的视场角确定 目标相机的焦距。S106, the user equipment 102 obtains the identification result, and determines the focal length of the target camera according to the field of view of the target camera.
本发明实施例中,目标识别模型为利用大量样本图片进行训练得到的 神经网络模型,通过将该大量样本图片以及每一样本图片匹配的图片参数 标签输入待训练的识别模型,并构建误差函数求解视角权重,获得目标识 别模型,其中,目标识别模型具有训练好的视角权重。用户设备102可以 获取需要识别相机参数的目标图片,并将该目标图片输入目标识别模型获 取识别结果,来确定拍摄该目标图片的目标识别模型输出的识别结果。具体的,在广告植入场景下,需要将广告页面植入图片中,或者将广告页面 植入一段视频,针对将广告页面植入视频的场景而言,也可以将其拆分为 将广告页面植入多个视频帧图片中,也即是,无论将广告页面植入图片或 者植入视频,最终要解决的问题都是将待植入的广告页面植入图片中。此 时,为了使得待植入的广告页面能够自然地植入图片,需要获取拍摄目标 图片的目标相机的视角参数,从而利用该视角参数对待植入的广告页面进 行渲染,使得广告页面自然地植入图片。具体的,可以将该图片通过用户 设备102输入目标识别模型,并获取该目标识别模型输出的识别结果,可 以根据该识别结果确定出拍摄目标图片的目标相机的视角参数。In the embodiment of the present invention, the target recognition model is a neural network model obtained by training a large number of sample pictures. By inputting the large number of sample pictures and the picture parameter labels matched with each sample picture into the recognition model to be trained, and constructing an error function to solve the problem The viewpoint weight is obtained to obtain the target recognition model, wherein the target recognition model has the trained viewpoint weight. The user equipment 102 can obtain the target picture that needs to recognize the camera parameters, and input the target picture into the target recognition model to obtain the recognition result, so as to determine the recognition result output by the target recognition model that captures the target picture. Specifically, in the advertisement placement scenario, the advertisement page needs to be embedded in a picture, or the advertisement page needs to be embedded in a video. For the scenario where the advertisement page is embedded in the video, it can also be split into the advertisement page. Embedding multiple video frame pictures, that is, whether the advertisement page is embedded in a picture or a video, the final problem to be solved is to embed the to-be-implanted advertisement page into a picture. At this time, in order to allow the advertisement page to be implanted to be implanted with pictures naturally, it is necessary to obtain the viewing angle parameter of the target camera that shoots the target image, so as to use the viewing angle parameter to render the advertisement page to be implanted, so that the advertisement page is naturally implanted. Enter the picture. Specifically, the picture can be input into the target recognition model through the user equipment 102, and the recognition result output by the target recognition model can be obtained, and the viewing angle parameter of the target camera that shoots the target picture can be determined according to the recognition result.
请一并参阅图2,图2是本发明实施例公开的一种可选的广告植入的 应用示意图,如图2所示,需要将待植入商品201自然地植入左边第一张 图片中,此时,可以将左边第一张图片确定为目标图片,为了获取拍摄目 标图片的目标相机的参数,可以将目标图片输入目标识别模型,目标识别 模型可以输出拍摄目标图片的目标相机的视角参数,也即是,通过将目标 图片输入目标识别模型可以获得拍摄目标图片的目标相机的视场角、俯仰 角以及旋转角,进一步的,还可以根据目标相机的视场角通过转换公式获 得目标相机的焦距,更进一步的,还可以通过标注目标图片上的两个坐标 点的方式获得目标相机的平移距离,从而获得目标相机的内参以及外参。 其中,目标相机的内参包括相机焦距和图像中心点坐标,目标相机的外参 包括旋转角度和平移距离,旋转角度包括俯仰角、旋转角以及偏航角。其 中,图像中心点坐标的横坐标可以确定为图像宽度值除以2的值,图像中 心点坐标的纵坐标可以确定为图像高度值除以2的值,偏航角可以确定为 0。利用确定出的拍摄目标图片的目标相机的相机参数,可以对图2中待 植入商品对应的图片进行渲染,使得待植入商品能够映射到目标图片中合 适的位置,例如可以将待植入商品映射到目标图片中的桌子上,从而实现 自然的广告植入。又或者,上述相机参数确定方法还可以应用于增强现实 场景中,具体的,在增强现实场景中,往往需要将虚拟物体叠加至现实场 景对应的画面中。此时可以获取现实场景对应的画面图片,将该画面图片 作为目标图片输入目标识别模型,获取相应的相机参数,利用该相机参数 对虚拟物体进行渲染,实现虚拟物体与现实场景的叠加画面。Please refer to FIG. 2 together. FIG. 2 is an application schematic diagram of an optional advertisement implantation disclosed by an embodiment of the present invention. As shown in FIG. 2 , the
可选地,在本实施例中,上述用户设备可以但不限于为手机、平板电 脑、笔记本电脑、PC机等支持运行应用客户端的计算机设备。上述服务 器和用户设备可以但不限于通过网络实现数据交互,上述网络可以包括但 不限于无线网络或有线网络。其中,该无线网络包括:蓝牙、WIFI及其 他实现无线通信的网络。上述有线网络可以包括但不限于:广域网、城域 网、局域网。上述仅是一种示例,本实施例中对此不作任何限定。Optionally, in this embodiment, the above-mentioned user equipment may be, but is not limited to, a mobile phone, a tablet computer, a notebook computer, a PC, and other computer equipment that supports running application clients. The above-mentioned server and user equipment may, but are not limited to, implement data interaction through a network, and the above-mentioned network may include, but is not limited to, a wireless network or a wired network. Wherein, the wireless network includes: Bluetooth, WIFI and other networks that realize wireless communication. The above wired network may include, but is not limited to, a wide area network, a metropolitan area network, and a local area network. The above is only an example, which is not limited in this embodiment.
可选地,作为一种可选的实施方式,如图3所示,上述相机参数确定 方法包括:Optionally, as an optional implementation manner, as shown in Figure 3, the above-mentioned camera parameter determination method includes:
S301,将目标图片输入目标识别模型中,其中,目标识别模型为利用 多个样本图片及与多个样本图片中每个样本图片分别匹配的图片参数标 签进行训练后得到的神经网络模型,目标识别模型用于识别拍摄样本图片 的相机的视角参数,视角参数包括:翻滚角、俯仰角及视场角;S301, input the target picture into the target recognition model, wherein the target recognition model is a neural network model obtained after training by using a plurality of sample pictures and a picture parameter label matched with each sample picture in the plurality of sample pictures, and the target recognition model The model is used to identify the viewing angle parameters of the camera that takes the sample image, and the viewing angle parameters include: roll angle, pitch angle and field of view;
S302,获取目标识别模型输出的识别结果,其中,识别结果用于指示 拍摄目标图片的目标相机的视角参数;S302, obtain the recognition result output by the target recognition model, wherein, the recognition result is used to indicate the viewing angle parameter of the target camera of the target picture;
S303,根据目标相机的视场角确定目标相机的焦距。S303, determining the focal length of the target camera according to the field of view of the target camera.
本发明实施例中,目标图片为需要识别拍摄该图片的相机参数的图片, 目标识别模型为利用大量样本图片和每一样本图片对应的图片参数标签 进行训练得到的神经网络模型,可以包括但不限于ResNet卷积神经网络 模型或者DenseNet卷积神经网络模型等。并且该目标识别模型用于识别 拍摄目标图片的目标相机的视角参数,也即是,将目标图片输入该目标识 别模型,该目标识别模型会输出拍摄目标图片的目标相机的视角参数,其 中,视角参数包括翻滚角、俯仰角及视场角。其中,视场角用于描述目标 相机的视野范围,翻滚角和俯仰角用于描述物体从世界坐标系转换至相机 坐标系的旋转角度,并且翻滚角可以用于描述绕相机坐标系的x轴的旋转 角度,俯仰角可以用于描述绕相机坐标系的y轴的旋转角度。进一步的, 在目标识别模型输出识别结果之后,还可以根据识别结果中的相机的视场 角来确定相机的焦距,这一过程可以利用神经网络模型识别图片特征,直 接获取图片对应的相机参数,无需使用标定物,也无需要求目标图片中具 有消失点,能够识别不存在正交平行线的指定图片对应的相机参数。In the embodiment of the present invention, the target picture is a picture that needs to identify the camera parameters for shooting the picture, and the target recognition model is a neural network model obtained by training a large number of sample pictures and the picture parameter labels corresponding to each sample picture, which may include but not Limited to ResNet convolutional neural network model or DenseNet convolutional neural network model, etc. And the target recognition model is used to identify the viewing angle parameters of the target camera that shoots the target picture, that is, the target picture is input into the target recognition model, and the target recognition model outputs the viewing angle parameters of the target camera that shoots the target picture, wherein the viewing angle is Parameters include roll angle, pitch angle, and field of view. Among them, the field of view angle is used to describe the field of view of the target camera, the roll angle and pitch angle are used to describe the rotation angle of the object converted from the world coordinate system to the camera coordinate system, and the roll angle can be used to describe the x-axis around the camera coordinate system The rotation angle, the pitch angle can be used to describe the rotation angle around the y-axis of the camera coordinate system. Further, after the target recognition model outputs the recognition result, the focal length of the camera can also be determined according to the field of view of the camera in the recognition result. In this process, the neural network model can be used to recognize the picture features and directly obtain the camera parameters corresponding to the picture. There is no need to use a calibration object, and there is no need to require a vanishing point in the target image, and the camera parameters corresponding to the specified image without orthogonal parallel lines can be identified.
请参阅图4,图4是本发明实施例公开的一种可选的相机参数的确定 示意图,如图4所示,使用本发明实施例所描述的相机参数确定方法进行 相机参数确定时,首先需要将目标图片输入目标识别模型,目标识别模型 会输出目标图片对应的相机参数,该相机参数为拍摄目标图片的目标相机 的相机参数。具体的,目标识别模型可以为卷积神经网络模型,在目标图 片输入目标识别模型之后,目标识别模型可以利用卷积核对目标图片进行卷积操作,其中,卷积核为若干个用于识别指定图像特征的矩阵,并且目 标图片被目标识别模型识别后的形式为矩阵,利用卷积核对目标图片进行 卷积操作即为卷积核与目标图片的矩阵相乘运算,这一过程可以通过卷积 核与目标图片的矩阵相乘结果识别出目标图片的图片特征,目标识别模型 可以根据图片特征输出特征值,其中,图片特征的表现形式可以为多维向 量矩阵,将该多维向量矩阵中每一向量的权重值和特征值可以进行加权求和运算获得特征值,这一过程可以将计算量较大的矩阵转换为计算量较小 的特征值,降低运算量,提高运算效率。由于目标识别模型是经过大量样 本图片训练好的模型,因而可以利用训练好的视角权重与该特征值计算得 到视角参数,也即是,可以直接计算得到目标相机的俯仰角、旋转角和视 场角。进一步的,根据视场角和焦距的转换公式,可以利用视场角计算相 机焦距。更进一步的,可以根据对目标图片上的坐标点进行标记求解获得 相机的平移距离,从而可以利用目标识别模型输出相机的俯仰角、旋转角、 焦距和平移距离等相机参数。Please refer to FIG. 4 . FIG. 4 is a schematic diagram of an optional camera parameter determination disclosed in an embodiment of the present invention. As shown in FIG. 4 , when the camera parameter determination method described in the embodiment of the present invention is used to determine the camera parameters, first The target picture needs to be input into the target recognition model, and the target recognition model will output the camera parameters corresponding to the target picture, and the camera parameters are the camera parameters of the target camera that took the target picture. Specifically, the target recognition model can be a convolutional neural network model. After the target image is input to the target recognition model, the target recognition model can use a convolution kernel to perform a convolution operation on the target image. The matrix of image features, and the target image is recognized by the target recognition model in the form of a matrix. Using the convolution kernel to perform the convolution operation on the target image is the matrix multiplication operation between the convolution kernel and the target image. This process can be done by convolution The matrix multiplication result of the kernel and the target picture identifies the picture features of the target picture, and the target recognition model can output feature values according to the picture features. The weights and eigenvalues of , can be weighted and summed to obtain eigenvalues. This process can convert a matrix with a large amount of calculation into an eigenvalue with a small amount of calculation, reduce the amount of calculation, and improve the efficiency of the calculation. Since the target recognition model is a model trained with a large number of sample pictures, the viewing angle parameters can be calculated by using the trained viewing angle weight and the eigenvalue, that is, the pitch angle, rotation angle and field of view of the target camera can be directly calculated. horn. Further, according to the conversion formula between the angle of view and the focal length, the focal length of the camera can be calculated by using the angle of view. Further, the translation distance of the camera can be obtained by marking and solving the coordinate points on the target image, so that the camera parameters such as the pitch angle, rotation angle, focal length and translation distance of the camera can be output by using the target recognition model.
作为一种可选的实施方式,获取目标识别模型输出的识别结果可以包 括以下步骤:As an optional implementation manner, obtaining the recognition result output by the target recognition model may include the following steps:
S1,利用目标识别模型识别目标图片的图片特征,获取图片特征对应 的特征值;S1, use the target recognition model to identify the picture features of the target picture, and obtain the feature values corresponding to the picture features;
S2,将特征值与视角参数对应的视角权重输入激活函数,获得激活函 数输出的识别结果。S2, input the viewing angle weight corresponding to the feature value and the viewing angle parameter into the activation function, and obtain the recognition result output by the activation function.
本发明实施例中,可以利用神经网络模型的特性去识别目标图片的图 片特征,并且获取图片特征对应的特征值,进一步的,可以获取目标识别 模型中的视角权重,其中,视角权重包括视场角对应的第一权重、翻滚角 对应的第二权重以及俯仰角对应的第三权重。可以将特征值与第一权重的 乘积代入激活函数,获得视场角;可以将特征值与第二权重的乘积代入激 活函数,获得翻滚角;可以将特征值与第三权重的乘积代入激活函数,获 得俯仰角。其中,激活函数可以包括但不限于Relu激活函数或sigmoid激 活函数。进一步的,激活函数输出的识别结果包括视场角、翻滚角以及俯 仰角,也即是识别结果用于指示拍摄目标图片的目标相机的视角参数。In the embodiment of the present invention, the characteristics of the neural network model can be used to identify the picture features of the target picture, and the feature values corresponding to the picture features can be obtained, and further, the perspective weight in the target recognition model can be obtained, wherein the perspective weight includes the field of view The first weight corresponding to the angle, the second weight corresponding to the roll angle, and the third weight corresponding to the pitch angle. The product of the eigenvalue and the first weight can be substituted into the activation function to obtain the angle of view; the product of the eigenvalue and the second weight can be substituted into the activation function to obtain the roll angle; the product of the eigenvalue and the third weight can be substituted into the activation function , to get the pitch angle. Wherein, the activation function may include but not limited to Relu activation function or sigmoid activation function. Further, the recognition result output by the activation function includes the field of view angle, the roll angle and the pitch angle, that is, the recognition result is used to indicate the viewing angle parameter of the target camera that shoots the target picture.
作为一种可选的实施方式,在将目标图片输入目标识别模型中之前, 还可以执行以下步骤:As an optional implementation manner, before inputting the target image into the target recognition model, the following steps may also be performed:
S1,利用虚拟相机模型模拟多个样本视角参数生成多个样本图片,每 一样本图片具有对应存储的图片参数标签,图片参数标签包含样本图片对 应的样本视角参数,样本视角参数至少包括翻滚角、俯仰角以及视场角;S1, using a virtual camera model to simulate multiple sample viewing angle parameters to generate multiple sample images, each sample image has a corresponding stored image parameter label, the image parameter label includes the sample viewing angle parameter corresponding to the sample image, and the sample viewing angle parameter includes at least the roll angle, Pitch angle and field of view;
S2,将对应存储的样本图片和图片参数标签输入待训练的识别模型, 获得待训练的识别模型输出的训练识别结果;S2, input the corresponding stored sample pictures and picture parameter labels into the recognition model to be trained, and obtain the training recognition result output by the recognition model to be trained;
S3,将图片参数标签中的翻滚角、俯仰角以及视场角和训练识别结果 代入误差函数进行训练,获得视角权重。S3: Substitute the roll angle, pitch angle, field of view angle and training recognition result in the picture parameter label into the error function for training to obtain the view angle weight.
本发明实施例中,虚拟相机模型为能够模拟各种视角参数生成样本图 片的相机模型,也即是,虚拟相机模型可以模拟不同的翻滚角、俯仰角、 偏航角以及视场角生成样本图片。并且,生成的每一个样本图片和它的图 片参数标签对应存储,图片参数标签为该样本图片对应的翻滚角、俯仰角、 偏航角以及视场角。可以将大量的样本图片和其对应存储的图片参数标签 输入待训练的识别模型,获得待训练的识别模型输出的训练识别结果,其中,训练识别结果为识别模型对样本图片进行识别后输出的翻滚角、俯仰 角以及视场角。利用图片参数标签中的视角参数和训练识别结果中的视角 参数之差,对模型的视角权重进行训练,获得训练后的视角权重。其中, 视角权重包含视场角对应的第一权重、翻滚角对应的第二权重以及俯仰角 对应的第三权重。In this embodiment of the present invention, the virtual camera model is a camera model that can simulate various viewing angle parameters to generate sample pictures, that is, the virtual camera model can simulate different roll angles, pitch angles, yaw angles, and field angles to generate sample pictures . And, each generated sample picture and its picture parameter label are stored correspondingly, and the picture parameter label is the roll angle, pitch angle, yaw angle and field angle corresponding to the sample picture. A large number of sample pictures and their corresponding stored picture parameter labels can be input into the recognition model to be trained, and the training recognition result output by the recognition model to be trained can be obtained, wherein the training recognition result is the tumbling output after the recognition model recognizes the sample picture angle, pitch angle, and field of view. Using the difference between the perspective parameter in the image parameter label and the perspective parameter in the training recognition result, the perspective weight of the model is trained, and the trained perspective weight is obtained. The viewing angle weight includes a first weight corresponding to the viewing angle, a second weight corresponding to the roll angle, and a third weight corresponding to the pitch angle.
请参阅图5,图5是本发明实施例公开的一种可选的对识别模型进行 训练的示意图,如图5所示,对识别模型进行训练需要将具有图片参数标 签的样本图片输入待训练的识别模型,识别模型会输出特征值,将特征值 代入翻滚角对应的第一误差函数、俯仰角对应的第二误差函数以及视场角 对应的第三误差函数,对第一误差函数中的翻滚角的权重进行训练学习, 获得第二权重,对第二误差函数中俯仰角的权重进行训练学习,获得第三权重,以及对第三误差函数中视场角的权重进行训练学习,获得第一权重, 从而获得视角权重,进而获得训练出视角权重的目标识别模型。Please refer to FIG. 5. FIG. 5 is a schematic diagram of an optional training of a recognition model disclosed in an embodiment of the present invention. As shown in FIG. 5, training a recognition model requires inputting sample pictures with picture parameter labels to be trained. The recognition model will output eigenvalues, and substitute the eigenvalues into the first error function corresponding to the roll angle, the second error function corresponding to the pitch angle, and the third error function corresponding to the field angle. The weight of the roll angle is trained and learned to obtain the second weight, the weight of the pitch angle in the second error function is trained and learned to obtain the third weight, and the weight of the field of view angle in the third error function is trained and learned to obtain the first weights, so as to obtain the perspective weights, and then obtain the target recognition model trained with the perspective weights.
请参阅图6,图6是本发明实施例公开的一种可选的生成样本图片的 示意图,如图6所示,生成样本图片时可以选用360全景图像数据集,该 360全景图像数据集中包含5万张各种场景下的360全景图数据,针对每 张全景图数据,本发明实施例所描述的虚拟相机模型可以模拟不同的翻滚 角、俯仰角、偏航角、视场角生成不同的样本图片。可选的,本发明实施 例所描述的虚拟相机模型可以选用透视投影模型,并且可以通过设定透视 投影模型的参数来模拟不同的翻滚角、俯仰角、偏航角、视场角。例如, 在图6所示的生成样本图片的示意图中,可以将透视投影模型的视场角参 数设置为90生成样本图片,又或者,可以将透视投影模型的俯仰角参数 设置为30生成样本图片,又或者,可以将透视投影模型的偏航角参数设 置为30生成样本图片,又或者,可以将透视投影模型的翻滚角参数设置 为30生成样本图片。Please refer to FIG. 6 . FIG. 6 is a schematic diagram of an optional sample image generation disclosed in an embodiment of the present invention. As shown in FIG. 6 , a 360-degree panoramic image dataset may be selected when generating a sample image, and the 360-degree panoramic image dataset includes 50,000 pieces of 360 panorama data in various scenarios, for each piece of panorama data, the virtual camera model described in the embodiment of the present invention can simulate different roll angles, pitch angles, yaw angles, and field angles to generate different Sample picture. Optionally, the virtual camera model described in the embodiment of the present invention can use a perspective projection model, and can simulate different roll angles, pitch angles, yaw angles, and field angles by setting the parameters of the perspective projection model. For example, in the schematic diagram of generating a sample picture shown in FIG. 6 , the field of view parameter of the perspective projection model can be set to 90 to generate a sample picture, or, the pitch angle parameter of the perspective projection model can be set to 30 to generate a sample picture , or, the yaw angle parameter of the perspective projection model can be set to 30 to generate a sample picture, or alternatively, the roll angle parameter of the perspective projection model can be set to 30 to generate a sample picture.
请参阅图7,图7是本发明实施例公开的一种可选的误差函数的训练 结果的示意图,在本发明实施例中对于识别模型的训练,可以设置一次训 练选取256个样本图片,共进行24次训练,可以理解的是,以上数字仅 做举例,不代表对本发明的限制。如图7所示,图7是对于俯仰角对应的 第二误差函数的训练结果,其中,图7中左边的图用于描述待训练的识别 模型计算俯仰角的误差率,图7右边的图用于描述待训练的识别模型计算 俯仰角的准确率,其中,误差率的计算方式可以采用KL散度进行计算, 准确率的计算方式可以为计算俯仰角的误差小于5度的比例。进一步的, 对于误差函数的优化方法可以采用adam算法,对于误差函数的优化算法 也可以采用随机梯度下降算法等其它算法,本发明实施例对此不做限定。 进一步的,图7中的train对应的曲线表示训练集数据输入识别模型对应 的误差率与准确率,图7中的val对应的曲线表示验证集数据输入识别模 型对应的误差率与准确率,其中训练集数据为样本图片对应的数据,训练 集数据为非样本图片的其他图片对应的数据。使用本发明实施例所描述的 对识别模型进行训练的方式,最终得到俯仰角对应的准确率为84.4%,旋 转角对应的准确率为92.6%,视场角对应的准确率为60.2%。目前使用消 失点法确定目标图片的相机参数的准确率约为10%,本发明实施例所描述 的这种对于识别模型的训练方式最终获得的目标识别模型提高了目标图 片的相机参数标定准确率,相机参数标定效果更佳。Please refer to FIG. 7. FIG. 7 is a schematic diagram of a training result of an optional error function disclosed in an embodiment of the present invention. In the embodiment of the present invention, for the training of the recognition model, 256 sample pictures can be selected for one training, and a total of 256 sample pictures can be selected. After 24 training sessions, it can be understood that the above numbers are only examples and do not represent limitations to the present invention. As shown in Figure 7, Figure 7 is the training result of the second error function corresponding to the pitch angle, wherein the figure on the left in Figure 7 is used to describe the error rate of the recognition model to be trained to calculate the pitch angle, and the figure on the right side of Figure 7 Used to describe the accuracy rate of the pitch angle calculated by the recognition model to be trained, wherein the calculation method of the error rate can be calculated by using KL divergence, and the calculation method of the accuracy rate can be the ratio of calculating the error of the pitch angle less than 5 degrees. Further, the adam algorithm may be used for the optimization method of the error function, and other algorithms such as the stochastic gradient descent algorithm may also be used for the optimization algorithm of the error function, which is not limited in this embodiment of the present invention. Further, the curve corresponding to train in Figure 7 represents the error rate and accuracy rate corresponding to the training set data input recognition model, and the curve corresponding to val in Figure 7 represents the error rate and accuracy rate corresponding to the validation set data input recognition model, wherein The training set data is the data corresponding to the sample pictures, and the training set data is the data corresponding to other pictures other than the sample pictures. Using the method of training the recognition model described in the embodiment of the present invention, the accuracy rate corresponding to the pitch angle is 84.4%, the accuracy rate corresponding to the rotation angle is 92.6%, and the accuracy rate corresponding to the field angle is 60.2%. At present, the accuracy rate of using the vanishing point method to determine the camera parameters of the target picture is about 10%. The target recognition model finally obtained by the training method for the recognition model described in the embodiment of the present invention improves the calibration accuracy of the camera parameters of the target picture. , the camera parameter calibration effect is better.
作为一种可选的实施方式,将图片参数标签中的翻滚角、俯仰角以及 视场角和待训练识别结果代入误差函数,对待训练权重进行训练,获得视 角权重可以包括以下步骤:As an optional embodiment, the roll angle, pitch angle and field of view in the picture parameter label and the recognition result to be trained are substituted into the error function, the weight to be trained is trained, and obtaining the angle of view weight can include the following steps:
S1,构建翻滚角对应的第一误差函数、俯仰角对应的第二误差函数以 及视场角对应的第三误差函数,其中,第一误差函数公式如下:S1, build the first error function corresponding to the roll angle, the second error function corresponding to the pitch angle and the third error function corresponding to the angle of view, wherein, the first error function formula is as follows:
lossroll=||rollgt-g(Wrollx)||lossroll =||rollgt -g(Wroll x)||
其中,rollgt表示翻滚角,Wroll为翻滚角权重,x为待训练识别模型 计算出的特征值;Among them, rollgt represents the roll angle, Wroll is the roll angle weight, and x is the feature value calculated by the recognition model to be trained;
第二误差公式如下:The second error formula is as follows:
losspitch=||pitchgt-g(Wpitchx)||losspitch =||pitchgt -g(Wpitch x)||
其中,pitchgt表示俯仰角参数,Wpitch为俯仰角权重,x为待训练识 别模型计算出的特征值;Wherein, pitchgt represents the pitch angle parameter, Wpitch is the pitch angle weight, and x is the eigenvalue calculated by the recognition model to be trained;
第三误差函数公式如下:The third error function formula is as follows:
lossvfov=||vfovgt-g(Wvfovx)||lossvfov =||vfovgt -g(Wvfov x)||
其中,vfovgt表示视场角参数,Wvfov为视场角权重,x为待训练的识 别模型计算出的特征值;Among them, vfovgt represents the angle of view parameter, Wvfov is the weight of the angle of view, and x is the eigenvalue calculated by the recognition model to be trained;
S2,将第一误差函数、第二误差函数以及第三误差函数之和确定为第 四误差函数,第四误差函数公式如下:S2, the sum of the first error function, the second error function and the third error function is determined as the fourth error function, and the formula of the fourth error function is as follows:
loss=lossvfov+lossroll+losspitchloss=lossvfov +lossroll +losspitch
其中,lossroll为第一误差函数,losspitch为第二误差函数,lossvfov为 第三误差函数;Among them, lossroll is the first error function, losspitch is the second error function, and lossvfov is the third error function;
S3,对第一误差函数、第二误差函数、第三误差函数和第四误差函数 进行训练,获得翻滚角权重、俯仰角权重以及视场角权重,视角权重包含 翻滚角权重、俯仰角权重以及视场角权重。S3, train the first error function, the second error function, the third error function and the fourth error function to obtain the roll angle weight, the pitch angle weight and the field angle weight, and the viewing angle weight includes the roll angle weight, the pitch angle weight and the Field of view weights.
本发明实施例中,对于误差函数的构建方式是将视角权重与特征值的 乘积代入激活函数,利用样本图片对应的图片参数标签中的视角参数减去 代入激活函数的视角权重与特征值的乘积,并对相减的值进行L2范式运 算。可选的,误差函数的构建不仅可以采用回归参数的构建方式,还可以 采用分类参数构建方式。具体的,在采用分类参数构建方式构建误差函数 的情况下,可以将视角参数的取值范围分割为多个取值区段,可以确定出样本图片对应的图片参数标签对应的第一取值区段以及待训练的识别模 型输出的视角参数对应的第二取值区段,将第一取值区段和第二取值区段 代入交叉熵函数来构建误差函数。对于误差函数构建的具体方式本发明实 施例中不做限定。In the embodiment of the present invention, the construction method of the error function is to substitute the product of the viewing angle weight and the eigenvalue into the activation function, and use the viewing angle parameter in the picture parameter label corresponding to the sample picture to subtract the product of the viewing angle weight and the eigenvalue substituted into the activation function. , and perform the L2 normal form operation on the subtracted value. Optionally, the construction of the error function may adopt not only the construction method of regression parameters, but also the construction method of classification parameters. Specifically, when the error function is constructed by using the classification parameter construction method, the value range of the viewing angle parameter can be divided into multiple value sections, and the first value section corresponding to the picture parameter label corresponding to the sample picture can be determined. and the second value section corresponding to the viewing angle parameter output by the recognition model to be trained, and the first value section and the second value section are substituted into the cross entropy function to construct an error function. The specific manner of constructing the error function is not limited in this embodiment of the present invention.
作为一种可选的实施方式,根据目标相机的视场角确定目标相机的焦 距可以包括以下步骤:As an optional implementation manner, determining the focal length of the target camera according to the field of view of the target camera may include the following steps:
将目标相机的视场角代入转换公式,计算获得目标相机的焦距,其中, 转换公式如下:Substitute the field of view of the target camera into the conversion formula, and calculate the focal length of the target camera. The conversion formula is as follows:
其中,hfov表示水平视场角,vfov表示垂直视场角,width表示目标图 片的宽度,height表示目标图片的高度,f表示焦距。Among them, hfov represents the horizontal field of view, vfov represents the vertical field of view, width represents the width of the target image, height represents the height of the target image, and f represents the focal length.
本发明实施例中,视场角可以包含水平视场角以及垂直视场角,上述 目标识别模型输出的视场角可以为水平视场角,也可以为垂直视场角。在 目标识别模型输出的视场角为水平视场角的情况下,对待训练的识别模型 进行训练时视场角对应的误差函数可以构建为水平视场角对应的误差函 数,在目标识别模型输出的视场角为垂直视场角的情况下,对待训练的识 别模型进行训练时视场角对应的误差函数可以构建为垂直视场角对应的误差函数。并且水平视场角和垂直视场角能够相互求解,也即是利用水平 视场角可以计算出垂直视场角,利用垂直视场角可以计算出水平视场角。 在已知上述公式中的水平视场角、垂直视场角、图像宽度和图像高度的情 况,可以求解获得焦距。In the embodiment of the present invention, the viewing angle may include a horizontal viewing angle and a vertical viewing angle, and the viewing angle output by the above-mentioned target recognition model may be a horizontal viewing angle or a vertical viewing angle. When the field of view output by the target recognition model is the horizontal field of view, the error function corresponding to the field of view can be constructed as the error function corresponding to the horizontal field of view when the recognition model to be trained is trained. In the case where the field of view angle is a vertical field of view, the error function corresponding to the field of view can be constructed as an error function corresponding to the vertical field of view when the recognition model to be trained is trained. And the horizontal field of view and the vertical field of view can be solved each other, that is, the horizontal field of view can be used to calculate the vertical field of view, and the vertical field of view can be used to calculate the horizontal field of view. In the case of knowing the horizontal field of view, vertical field of view, image width and image height in the above formula, it can be solved to obtain the focal length.
作为一种可选的实施方式,在根据目标相机的视场角确定目标相机的 焦距之后,还可以执行以下步骤:As an optional implementation manner, after determining the focal length of the target camera according to the field of view of the target camera, the following steps can also be performed:
S1,获取目标图片中的虚拟对象对应的第一坐标以及第二坐标,第一 坐标与第二坐标为世界坐标系中的坐标;S1, obtain the first coordinate and the second coordinate corresponding to the virtual object in the target picture, and the first coordinate and the second coordinate are the coordinates in the world coordinate system;
S2,将第一坐标和第二坐标代入相机成像公式,求解获得目标图片对 应的平移距离,其中,相机成像公式如下:S2: Substitute the first coordinate and the second coordinate into the camera imaging formula, and solve the translation distance corresponding to the obtained target image, where the camera imaging formula is as follows:
λ1p1=K(RP1+t)λ1 p1 =K(RP1 +t)
λ2p2=K(RP2+t)λ2 p2 =K(RP2 +t)
其中,K表示相机内参,相机内参至少包括焦距和目标图片对应的中 心点坐标,P1表示第一坐标,P2表示第二坐标,t表示平移距离,R表示翻 滚角和俯仰角,λ1为第一待求解系数,λ2为第二待求解系数,p1为图像坐 标系中第一坐标对应的坐标,p2为图像坐标系中第二坐标对应的坐标。Among them, K represents the camera internal parameters, the camera internal parameters at least include the focal length and the coordinates of the center point corresponding to the target image, P1 represents the first coordinate, P2 represents the second coordinate, t represents the translation distance, R represents the roll angle and pitch angle, λ1 is the first coefficient to be solved, λ2 is the second coefficient to be solved, p1 is the coordinate corresponding to the first coordinate in the image coordinate system, and p2 is the coordinate corresponding to the second coordinate in the image coordinate system.
其中,(u0,v0)为目标图片的中心点坐标,u0为目标图 片的宽度除以2得到,v0为目标图片的高度除以2得到,上述两个公式相 减获得:in, (u0 , v0 ) is the coordinate of the center point of the target image, u0 is the width of the target image divided by 2, and v0 is the height of the target image divided by 2. The above two formulas are subtracted to obtain:
解得再求解t:Solutions have to Then solve for t:
本发明实施例中,虚拟对象可以为目标图片中的任一物体对象或者人 物对象等,本发明实施例中不做限定。选取的虚拟对象的第一坐标和第二 坐标可以为虚拟对象的底部中点坐标和虚拟对象的顶部中点坐标,也可以 为虚拟对象的底部右下角坐标以及虚拟对象的顶部左上角坐标。优选的, 获取目标图片中的虚拟对象对应的第一坐标以及第二坐标的方式具体可 以为:随机选取目标图片中虚拟对象上的任一点对应的第一坐标,将第一坐标的纵坐标加预设高度值获得第一端点,将第一坐标的纵坐标减预设高 度值获得第二端点;在第一端点和第二端点构成的高度区间中随机选取第 二坐标,其中,第二坐标的纵坐标落入该高度区间。例如,高度区间可以 为6厘米,也即是第一坐标的纵坐标向上3厘米以及第一坐标的纵坐标向 下3厘米的范围内,此时选取的第一坐标和第二坐标的具有一定的高度差, 确定第一坐标和第二坐标更加方便。In the embodiment of the present invention, the virtual object may be any object object or a human object in the target picture, which is not limited in the embodiment of the present invention. The first and second coordinates of the selected virtual object can be the coordinates of the bottom midpoint of the virtual object and the top midpoint of the virtual object, or the coordinates of the bottom lower right corner of the virtual object and the top upper left corner of the virtual object. Preferably, the method of acquiring the first coordinate and the second coordinate corresponding to the virtual object in the target picture may specifically be: randomly selecting the first coordinate corresponding to any point on the virtual object in the target picture, adding the ordinate of the first coordinate to The preset height value obtains the first end point, and the ordinate of the first coordinate is subtracted from the preset height value to obtain the second end point; the second coordinate is randomly selected in the height interval formed by the first end point and the second end point, wherein the first end point is The ordinate of the two coordinates falls within the height interval. For example, the height interval can be 6 centimeters, that is, within the range of 3 centimeters above the ordinate of the first coordinate and 3 centimeters below the ordinate of the first coordinate, and the selected first and second coordinates have certain It is more convenient to determine the first coordinate and the second coordinate.
请参阅图8,图8是本发明实施例公开的一种可选的第一坐标和第二 坐标的选取示意图,如图8所示,可以在图8最左侧的目标图片中获取第 一坐标和第二坐标,如图8中间的图片所示,可以获取到第一坐标802以 及第二坐标801,其中,如图8最右侧的图片所示,获取到的第一坐标802 对应为虚拟对象底部中点坐标,获取到的第二坐标801对应虚拟对象顶部 中点坐标,并且第一坐标802和第二坐标801为虚拟对象在世界坐标系中 的坐标,例如第一坐标802为(0,0,0),第二坐标801为(0,h,0), h为该虚拟对象在世界坐标系中的高度。将第一坐标802和第二坐标801 代入上述相机成像公式可以获得平移距离t。Please refer to FIG. 8. FIG. 8 is a schematic diagram of an optional first coordinate and second coordinate selection disclosed in an embodiment of the present invention. As shown in FIG. 8, the first coordinate can be obtained from the target picture on the far left of FIG. Coordinates and second coordinates, as shown in the picture in the middle of FIG. 8 , the first coordinate 802 and the second coordinate 801 can be obtained, wherein, as shown in the picture on the far right of FIG. 8 , the obtained first coordinate 802 corresponds to The coordinates of the bottom midpoint of the virtual object, the acquired second coordinate 801 corresponds to the top midpoint coordinate of the virtual object, and the first coordinate 802 and the second coordinate 801 are the coordinates of the virtual object in the world coordinate system, for example, the first coordinate 802 is ( 0, 0, 0), the second coordinate 801 is (0, h, 0), and h is the height of the virtual object in the world coordinate system. The translation distance t can be obtained by substituting the first coordinate 802 and the second coordinate 801 into the above camera imaging formula.
可选地,如图9所示,图9是本发明实施例中公开的一种图片处理方 法,可以包括以下步骤:Optionally, as shown in Fig. 9, Fig. 9 is a kind of picture processing method disclosed in the embodiment of the present invention, can comprise the following steps:
S901,确定目标图片所对应的相机参数;S901, determine the camera parameters corresponding to the target picture;
S902,获取目标对象参数和待植入位置;S902, obtain the target object parameters and the position to be implanted;
S903,基于相机参数、目标对象参数以及待植入位置,将目标对象植 入到目标图片中。S903, implant the target object into the target picture based on the camera parameters, the target object parameters and the position to be implanted.
本发明实施例中,确定目标图像所对应的相机参数可以使用上述相机 参数确定方法来进行确定,相机参数可以包括目标相机的俯仰角、目标相 机的翻滚角以及目标相机的焦距。例如可以执行上述步骤S301至步骤 S303来确定目标相机的俯仰角、目标相机的翻滚角以及目标相机的焦距。 进一步地,目标对象参数为用于描述目标对象的特征的参数,可以包括目 标对象的尺寸以及目标对象的形状等,例如在图2中,目标对象即为待植 入商品201,目标对象的尺寸可以包括待植入商品201的高度等,目标对 象的形状可以为不规则立方体。进一步地,待植入位置为在目标图像上的 位置,在目标对象植入到目标图片的情况下,目标对象在目标图片中的所 在位置即为该待植入位置,可选的,待植入位置可以包含目标图片中的多 个坐标点集合。进一步地,基于相机参数、目标对象参数以及待植入位置 将目标对象植入到目标图片中的方式具体可以为:根据目标对象参数确定 目标对象在世界坐标系中的坐标;获取待植入位置在图片坐标系中的坐标; 利用相机参数以及坐标系转换公式对目标对象在世界坐标系中的坐标进 行变换,使得目标对象能够落入待植入位置在图片坐标系中的坐标,从而 实现将目标对象植入到目标图片中。In this embodiment of the present invention, the camera parameters corresponding to the target image can be determined using the above-mentioned camera parameter determination method, and the camera parameters can include the pitch angle of the target camera, the roll angle of the target camera, and the focal length of the target camera. For example, the above steps S301 to S303 may be performed to determine the pitch angle of the target camera, the roll angle of the target camera, and the focal length of the target camera. Further, the target object parameter is a parameter used to describe the characteristics of the target object, and may include the size of the target object and the shape of the target object. For example, in FIG. 2, the target object is the commodity to be implanted 201, and the size of the target object It may include the height of the
作为一种可选的实施方式,目标对象参数包括目标对象的尺寸,基于 相机参数、目标对象的参数以及待植入位置,将目标对象植入到目标图片 中可以包括:As an optional embodiment, the target object parameters include the size of the target object, and based on the camera parameters, the parameters of the target object and the position to be implanted, implanting the target object in the target picture may include:
确定目标对象上的预设点,使预设点与待植入位置重合,以该预设点 为基准,结合视角参数以及目标对象的尺寸,确定目标对象在目标图片中 的显示方式。Determine the preset point on the target object, make the preset point coincide with the position to be implanted, take the preset point as a benchmark, combine the viewing angle parameters and the size of the target object, determine the display mode of the target object in the target picture.
本发明实施例中,目标对象上的预设点为目标对象上用于进行坐标变 换的点,可以但不限于为目标对象底部的中心点、目标对象顶部的中心点 等,可选的,预设点可以根据目标对象的形状来确定,例如在目标对象为 圆柱形的情况下,可以将目标对象的底部中心点和顶部中心点确定为预设 点,在目标对象为球形的情况下,可以将球心确定为预设点等,本发明实 施例中不做限定。进一步地,目标对象的尺寸可以包括但不限于高度、宽 度、半径等。在确定出预设点之后,可以将预设点与待植入位置中相应的 位置点重合,再以该预设点为目标对象的基准,结合相机参数中的视角参 数和目标对象的尺寸,确定目标对象在目标图片中的显示方式,从而实现 将目标对象植入到目标图片中。In this embodiment of the present invention, the preset point on the target object is a point on the target object used for coordinate transformation, which may be, but is not limited to, the center point at the bottom of the target object, the center point at the top of the target object, etc. Optionally, the preset point The setting point can be determined according to the shape of the target object. For example, when the target object is cylindrical, the bottom center point and top center point of the target object can be determined as preset points. When the target object is spherical, it can be determined. The center of the sphere is determined as a preset point, etc., which is not limited in the embodiment of the present invention. Further, the size of the target object may include, but is not limited to, height, width, radius, and the like. After the preset point is determined, the preset point can be overlapped with the corresponding position point in the position to be implanted, and then the preset point can be used as the benchmark of the target object, combined with the viewing angle parameters in the camera parameters and the size of the target object, Determine the display mode of the target object in the target picture, so as to realize the implantation of the target object in the target picture.
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都 表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明并不受 所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其他顺序 或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实 施例均属于优选实施例,所涉及的动作和模块并不一定是本发明所必须的。It should be noted that, for the sake of simple description, the foregoing method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence. As in accordance with the present invention, certain steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
根据本发明实施例的另一个方面,还提供了一种用于实施上述相机参 数确定方法的相机参数确定装置。如图10所示,该装置包括:According to another aspect of the embodiments of the present invention, a camera parameter determination apparatus for implementing the above camera parameter determination method is also provided. As shown in Figure 10, the device includes:
第一输入单元1001,用于将目标图片输入目标识别模型中,其中,目 标识别模型为利用多个样本图片及与多个样本图片中每个样本图片分别 匹配的图片参数标签进行训练后得到的神经网络模型,目标识别模型用于 识别拍摄样本图片的相机的视角参数,视角参数包括:翻滚角、俯仰角及 视场角;The
第一获取单元1002,用于获取目标识别模型输出的识别结果,其中, 识别结果用于指示拍摄目标图片的目标相机的视角参数;The first obtaining
第一确定单元1003,用于根据目标相机的视场角确定目标相机的焦距。The first determining unit 1003 is configured to determine the focal length of the target camera according to the field of view of the target camera.
作为一种可选的实施方式,第一获取单元可以包括:As an optional implementation manner, the first obtaining unit may include:
第一获取子单元,用于利用目标识别模型识别目标图片的图片特征, 获取图片特征对应的特征值;The first acquisition subunit is used to identify the picture feature of the target picture by using the target recognition model, and obtain the feature value corresponding to the picture feature;
第二获取子单元,用于将特征值与视角参数对应的视角权重输入激活 函数,获得激活函数输出的识别结果。The second obtaining subunit is used to input the viewing angle weight corresponding to the feature value and the viewing angle parameter into the activation function, and obtain the recognition result output by the activation function.
作为一种可选的实施方式,上述装置还可以包括:As an optional implementation manner, the above-mentioned device may also include:
生成单元,用于在将目标图片输入目标识别模型中之前,利用虚拟相 机模型模拟多个样本视角参数生成多个样本图片,每一样本图片具有对应 存储的图片参数标签,图片参数标签包含样本图片对应的样本视角参数, 样本视角参数至少包括翻滚角、俯仰角以及视场角;The generating unit is used to generate a plurality of sample pictures by using the virtual camera model to simulate a plurality of sample viewing angle parameters before inputting the target picture into the target recognition model, each sample picture has a corresponding stored picture parameter label, and the picture parameter label contains the sample picture Corresponding sample viewing angle parameters, the sample viewing angle parameters include at least a roll angle, a pitch angle, and a field of view angle;
第三获取单元,用于将对应存储的样本图片和图片参数标签输入待训 练的识别模型,获得待训练的识别模型输出的训练识别结果;The third acquisition unit is used to input the corresponding stored sample picture and the picture parameter label into the recognition model to be trained, and obtain the training recognition result output by the recognition model to be trained;
第四获取单元,用于将图片参数标签中的翻滚角、俯仰角以及视场角 和训练识别结果代入误差函数进行训练,获得视角权重。The fourth acquisition unit is used for substituting the roll angle, pitch angle, field of view angle and the training recognition result in the picture parameter label into the error function for training to obtain the angle of view weight.
作为一种可选的实施方式,第四获取单元可以包括:As an optional implementation manner, the fourth obtaining unit may include:
构建子单元,用于构建翻滚角对应的第一误差函数、俯仰角对应的第 二误差函数以及视场角对应的第三误差函数,其中,第一误差函数公式如 下:A subunit is constructed for constructing the first error function corresponding to the roll angle, the second error function corresponding to the pitch angle, and the third error function corresponding to the field angle, wherein the formula of the first error function is as follows:
lossroll=||rollgt-g(Wrollx)||lossroll =||rollgt -g(Wroll x)||
其中,rollgt表示翻滚角,Wroll为翻滚角权重,x为待训练识别模型 计算出的特征值;Among them, rollgt represents the roll angle, Wroll is the roll angle weight, and x is the feature value calculated by the recognition model to be trained;
第二误差公式如下:The second error formula is as follows:
losspitch=||pitchgt-g(Wpitchx)||losspitch =||pitchgt -g(Wpitch x)||
其中,pitchgt表示俯仰角参数,Wpitch为俯仰角权重,x为待训练识 别模型计算出的特征值;Wherein, pitchgt represents the pitch angle parameter, Wpitch is the pitch angle weight, and x is the eigenvalue calculated by the recognition model to be trained;
第三误差函数公式如下:The third error function formula is as follows:
lossvfov=||vfovgt-g(Wvfovx)||lossvfov =||vfovgt -g(Wvfov x)||
其中,vfovgt表示视场角参数,Wvfov为视场角权重,x为待训练的识 别模型计算出的特征值;Among them, vfovgt represents the angle of view parameter, Wvfov is the weight of the angle of view, and x is the eigenvalue calculated by the recognition model to be trained;
确定子单元,用于将第一误差函数、第二误差函数以及第三误差函数 之和确定为第四误差函数,第四误差函数公式如下:A determination subunit for determining the sum of the first error function, the second error function and the third error function as the fourth error function, and the formula of the fourth error function is as follows:
loss=lossvfov+lossroll+losspitchloss=lossvfov +lossroll +losspitch
其中,lossroll为第一误差函数,losspitch为第二误差函数,lossvfov为 第三误差函数;Among them, lossroll is the first error function, losspitch is the second error function, and lossvfov is the third error function;
训练子单元,用于对第一误差函数、第二误差函数、第三误差函数和 第四误差函数进行训练,获得翻滚角权重、俯仰角权重以及视场角权重, 视角权重包含翻滚角权重、俯仰角权重以及视场角权重。The training subunit is used for training the first error function, the second error function, the third error function and the fourth error function, and obtains the roll angle weight, the pitch angle weight and the field angle weight, and the viewing angle weight includes the roll angle weight, Pitch angle weight and field angle weight.
作为一种可选的实施方式,第一确定单元用于根据目标相机的视场角 确定目标相机的焦距的方式具体为:As a kind of optional implementation, the mode that the first determining unit is used to determine the focal length of the target camera according to the field of view of the target camera is specifically:
确定单元,用于将目标相机的视场角代入转换公式,计算获得目标相 机的焦距,其中,转换公式如下:The determining unit is used for substituting the field of view of the target camera into the conversion formula, and calculating the focal length of the target camera, wherein the conversion formula is as follows:
其中,hfov表示水平视场角,vfov表示垂直视场角,width表示目标图 片的宽度,height表示目标图片的高度,f表示焦距。Among them, hfov represents the horizontal field of view, vfov represents the vertical field of view, width represents the width of the target image, height represents the height of the target image, and f represents the focal length.
作为一种可选的实施方式,上述装置还可以包括:As an optional implementation manner, the above-mentioned device may also include:
第五获取单元,用于在根据目标相机的视场角确定目标相机的焦距之 后,获取目标图片中的虚拟对象对应的第一坐标以及第二坐标,第一坐标 与第二坐标为世界坐标系中的坐标;The fifth obtaining unit is used to obtain the first coordinate and the second coordinate corresponding to the virtual object in the target picture after the focal length of the target camera is determined according to the field of view of the target camera, and the first coordinate and the second coordinate are the world coordinate system the coordinates in ;
求解单元,用于将第一坐标和第二坐标代入相机成像公式,求解获得 目标图片对应的平移距离,其中,相机成像公式如下:The solving unit is used for substituting the first coordinate and the second coordinate into the camera imaging formula to solve the translation distance corresponding to the obtained target image, wherein the camera imaging formula is as follows:
λ1p1=K(RP1+t)λ1 p1 =K(RP1 +t)
λ2p2=K(RP2+t)λ2 p2 =K(RP2 +t)
其中,K表示相机内参,相机内参至少包括焦距和目标图片对应的中 心点坐标,P1表示第一坐标,P2表示第二坐标,t表示平移距离,R表示翻 滚角和俯仰角,λ1为第一待求解系数,λ2为第二待求解系数。Among them, K represents the camera internal parameters, the camera internal parameters at least include the focal length and the coordinates of the center point corresponding to the target image, P1 represents the first coordinate, P2 represents the second coordinate, t represents the translation distance, R represents the roll angle and pitch angle, λ1 is the first coefficient to be solved, and λ2 is the second coefficient to be solved.
可选的,本发明实施例还提供了一种用于实施上述图片处理方法的图 片处理装置。如图11所示,该装置包括:Optionally, an embodiment of the present invention further provides a picture processing apparatus for implementing the above picture processing method. As shown in Figure 11, the device includes:
第二输入单元1101,用于将目标图片输入目标识别模型中,其中,目 标识别模型为利用多个样本图片及与多个样本图片中每个样本图片分别 匹配的图片参数标签进行训练后得到的神经网络模型,目标识别模型用于 识别拍摄样本图片的相机的视角参数,视角参数包括:翻滚角、俯仰角及 视场角;The
第二获取单元1102,用于获取目标识别模型输出的识别结果,其中, 识别结果用于指示拍摄目标图片的目标相机的视角参数;The second obtaining
第二确定单元1103,用于根据目标相机的视场角确定目标相机的焦距;The second determining
目标对象获取单元1104,用于获取待植入的目标对象参数以及待植入 位置;The target
植入单元1105,用于基于相机参数、目标对象参数以及待植入位置, 将目标对象植入到目标图片中。The implantation unit 1105 is configured to implant the target object into the target picture based on the camera parameters, the target object parameters and the position to be implanted.
作为一种可选的实施方式,目标对象参数包括目标对象的尺寸,植入 单元1105用于基于相机参数、目标对象的参数以及待植入位置,将目标 对象植入到目标图片中的方式具体可以为:As an optional implementation manner, the target object parameters include the size of the target object, and the implantation unit 1105 is configured to specifically implant the target object into the target picture based on the camera parameters, the parameters of the target object and the position to be implanted Can be:
植入单元1105,用于确定目标对象上的预设点,使预设点与待植入 位置重合,以该预设点为基准,结合视角参数以及目标对象的尺寸,确定 目标对象在目标图片中的显示方式。The implantation unit 1105 is used to determine a preset point on the target object, so that the preset point coincides with the position to be implanted, and based on the preset point, combined with the viewing angle parameter and the size of the target object, determine the target object in the target picture. display in .
根据本发明实施例的又一个方面,还提供了一种用于实施上述相机参 数确定方法的电子装置,如图12所示,该电子装置包括存储器1202和处 理器1204,该存储器1202中存储有计算机程序,该处理器1204被设置为 通过计算机程序执行上述任一项方法实施例中的步骤。According to yet another aspect of the embodiments of the present invention, an electronic device for implementing the above method for determining camera parameters is also provided. As shown in FIG. 12 , the electronic device includes a
可选地,在本实施例中,上述电子装置可以位于计算机网络的多个网 络设备中的至少一个网络设备。Optionally, in this embodiment, the above-mentioned electronic apparatus may be located in at least one network device among multiple network devices of a computer network.
可选地,在本实施例中,上述处理器可以被设置为通过计算机程序执 行以下步骤:Optionally, in this embodiment, the above-mentioned processor may be configured to execute the following steps through a computer program:
S1,将目标图片输入目标识别模型中,其中,目标识别模型为利用多 个样本图片及与多个样本图片中每个样本图片分别匹配的图片参数标签 进行训练后得到的神经网络模型,目标识别模型用于识别拍摄样本图片的 相机的视角参数,视角参数包括:翻滚角、俯仰角及视场角;S1, input the target image into the target recognition model, wherein the target recognition model is a neural network model obtained after training by using multiple sample images and image parameter labels that match each sample image in the multiple sample images. The model is used to identify the viewing angle parameters of the camera that takes the sample image, and the viewing angle parameters include: roll angle, pitch angle and field of view;
S2,获取目标识别模型输出的识别结果,其中,识别结果用于指示拍 摄目标图片的目标相机的视角参数;S2, obtain the recognition result output by the target recognition model, wherein, the recognition result is used to indicate the viewing angle parameter of the target camera of the target picture;
S3,根据目标相机的视场角确定目标相机的焦距。S3, determining the focal length of the target camera according to the field of view of the target camera.
可选地,本领域普通技术人员可以理解,图12所示的结构仅为示意, 电子装置也可以是智能手机(如Android手机、iOS手机等)、平板电脑、 掌上电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等 终端设备。图12其并不对上述电子装置的结构造成限定。例如,电子装 置还可包括比图12中所示更多或者更少的组件(如网络接口等),或者具 有与图12所示不同的配置。Optionally, those of ordinary skill in the art can understand that the structure shown in FIG. 12 is only for illustration, and the electronic device may also be a smart phone (such as an Android mobile phone, an iOS mobile phone, etc.), a tablet computer, a palmtop computer, and a mobile Internet device (Mobile Internet device). Internet Devices, MID), PAD and other terminal equipment. FIG. 12 does not limit the structure of the above electronic device. For example, the electronic device may also include more or fewer components than those shown in FIG. 12 (such as network interfaces, etc.), or have a different configuration than that shown in FIG. 12 .
其中,存储器1202可用于存储软件程序以及模块,如本发明实施例 中的相机参数确定方法和装置对应的程序指令/模块,处理器1204通过运 行存储在存储器1202内的软件程序以及模块,从而执行各种功能应用以 及数据处理,即实现上述的相机参数确定方法。存储器1202可包括高速 随机存储器,还可以包括非易失性存储器,如一个或者多个磁性存储装置、 闪存、或者其他非易失性固态存储器。在一些实例中,存储器1202可进 一步包括相对于处理器1204远程设置的存储器,这些远程存储器可以通 过网络连接至终端。上述网络的实例包括但不限于互联网、企业内部网、 局域网、移动通信网及其组合。其中,存储器1202具体可以但不限于用 于存储操作指令等信息。作为一种示例,如图12所示,上述存储器1202 中可以但不限于包括上述相机参数确定装置中的第一输入单元1001、第一 获取单元1002以及第一确定单元1003。此外,还可以包括但不限于上述 相机参数确定装置中的其他模块单元,本示例中不再赘述。The
可选地,上述的传输装置1206用于经由一个网络接收或者发送数据。 上述的网络具体实例可包括有线网络及无线网络。在一个实例中,传输装 置1206包括一个网络适配器(Network Interface Controller,NIC),其可 通过网线与其他网络设备与路由器相连从而可与互联网或局域网进行通 讯。在一个实例中,传输装置1206为射频(RadioFrequency,RF)模块, 其用于通过无线方式与互联网进行通讯。Optionally, the above-mentioned
此外,上述电子装置还包括:显示器1208,用于显示上述目标图片以 及目标识别模型输出的识别结果;和连接总线1210,用于连接上述电子装 置中的各个模块部件。In addition, the above-mentioned electronic device further includes: a
根据本发明实施例的又一个方面,还提供了一种用于实施上述图片处 理方法的电子装置,如图13所示,该电子装置包括存储器1302和处理器 1304,该存储器1302中存储有计算机程序,该处理器1304被设置为通过 计算机程序执行上述任一项方法实施例中的步骤。According to another aspect of the embodiments of the present invention, an electronic device for implementing the above picture processing method is also provided. As shown in FIG. 13 , the electronic device includes a
可选地,在本实施例中,上述电子装置可以位于计算机网络的多个网 络设备中的至少一个网络设备。Optionally, in this embodiment, the above-mentioned electronic apparatus may be located in at least one network device among multiple network devices of a computer network.
可选地,在本实施例中,上述处理器可以被设置为通过计算机程序执 行以下步骤:Optionally, in this embodiment, the above-mentioned processor may be configured to execute the following steps through a computer program:
S1,根据上述相机参数确定方法确定所述目标图像图片所对应的相机 参数;S1, determine the camera parameters corresponding to the target image picture according to the above-mentioned camera parameter determination method;
S2,获取目标对象参数和待植入位置;S2, obtain the parameters of the target object and the position to be implanted;
S3,基于所述相机参数、所述目标对象参数以及所述待植入位置,将 所述目标对象植入到所述目标图片中。S3. Based on the camera parameters, the target object parameters and the to-be-implanted position, the target object is implanted into the target picture.
可选地,本领域普通技术人员可以理解,图13所示的结构仅为示意, 电子装置也可以是智能手机(如Android手机、iOS手机等)、平板电脑、 掌上电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等 终端设备。图13其并不对上述电子装置的结构造成限定。例如,电子装 置还可包括比图13中所示更多或者更少的组件(如网络接口等),或者具 有与图13所示不同的配置。Optionally, those of ordinary skill in the art can understand that the structure shown in FIG. 13 is only for illustration, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a palmtop computer, and a mobile Internet device (Mobile Internet device). Internet Devices, MID), PAD and other terminal equipment. FIG. 13 does not limit the structure of the above electronic device. For example, the electronic device may also include more or fewer components than those shown in FIG. 13 (such as network interfaces, etc.), or have a different configuration than that shown in FIG. 13 .
其中,存储器1302可用于存储软件程序以及模块,如本发明实施例 中的图片处理方法和装置对应的程序指令/模块,处理器1304通过运行存 储在存储器1302内的软件程序以及模块,从而执行各种功能应用以及数 据处理,即实现上述的图片处理方法。存储器1302可包括高速随机存储 器,还可以包括非易失性存储器,如一个或者多个磁性存储装置、闪存、 或者其他非易失性固态存储器。在一些实例中,存储器1302可进一步包 括相对于处理器1304远程设置的存储器,这些远程存储器可以通过网络 连接至终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、 移动通信网及其组合。其中,存储器1302具体可以但不限于用于存储操 作指令等信息。作为一种示例,如图13所示,上述存储器1302中可以但 不限于包括上述图片处理装置中的第二输入单元1101、第二获取单元1102、第二确定单元1103、目标对象获取单元1104以及植入单元1105。此外, 还可以包括但不限于上述图片处理装置中的其他模块单元,本示例中不再 赘述。The
可选地,上述的传输装置1306用于经由一个网络接收或者发送数据。 上述的网络具体实例可包括有线网络及无线网络。在一个实例中,传输装 置1306包括一个网络适配器(Network Interface Controller,NIC),其可 通过网线与其他网络设备与路由器相连从而可与互联网或局域网进行通 讯。在一个实例中,传输装置1306为射频(RadioFrequency,RF)模块, 其用于通过无线方式与互联网进行通讯。Optionally, the above-mentioned transmission means 1306 is configured to receive or transmit data via a network. Specific examples of the above-mentioned networks may include wired networks and wireless networks. In one example, the
此外,上述电子装置还包括:显示器1308,用于显示上述目标图片以 及目标识别模型输出的识别结果;和连接总线1310,用于连接上述电子装 置中的各个模块部件。In addition, the above-mentioned electronic device further includes: a
根据本发明的实施例的又一方面,还提供了一种存储介质,该存储介 质中存储有计算机程序,其中,该计算机程序被设置为运行时执行上述任 一项方法实施例中的步骤。According to yet another aspect of the embodiments of the present invention, a storage medium is also provided, and a computer program is stored in the storage medium, wherein the computer program is configured to execute the steps in any one of the above method embodiments when running.
可选地,在本实施例中,上述存储介质可以被设置为存储用于执行以 下步骤的计算机程序:Optionally, in this embodiment, the above-mentioned storage medium can be configured to store a computer program for performing the following steps:
S1,将目标图片输入目标识别模型中,其中,目标识别模型为利用多 个样本图片及与多个样本图片中每个样本图片分别匹配的图片参数标签 进行训练后得到的神经网络模型,目标识别模型用于识别拍摄样本图片的 相机的视角参数,视角参数包括:翻滚角、俯仰角及视场角;S1, input the target image into the target recognition model, wherein the target recognition model is a neural network model obtained after training by using multiple sample images and image parameter labels that match each sample image in the multiple sample images. The model is used to identify the viewing angle parameters of the camera that takes the sample image, and the viewing angle parameters include: roll angle, pitch angle and field of view;
S2,获取目标识别模型输出的识别结果,其中,识别结果用于指示拍 摄目标图片的目标相机的视角参数;S2, obtain the recognition result output by the target recognition model, wherein, the recognition result is used to indicate the viewing angle parameter of the target camera of the target picture;
S3,根据目标相机的视场角确定目标相机的焦距。S3, determining the focal length of the target camera according to the field of view of the target camera.
根据本发明的实施例的又一方面,还提供了一种存储介质,该存储介 质中存储有计算机程序,其中,该计算机程序被设置为运行时执行上述任 一项方法实施例中的步骤。According to yet another aspect of the embodiments of the present invention, a storage medium is also provided, and a computer program is stored in the storage medium, wherein the computer program is configured to execute the steps in any one of the above method embodiments when running.
可选地,在本实施例中,上述存储介质可以被设置为存储用于执行以 下步骤的计算机程序:Optionally, in this embodiment, the above-mentioned storage medium can be configured to store a computer program for performing the following steps:
S1,根据上述相机参数确定方法确定所述目标图像图片所对应的相机 参数;S1, determine the camera parameters corresponding to the target image picture according to the above-mentioned camera parameter determination method;
S2,获取目标对象参数和待植入位置;S2, obtain the parameters of the target object and the position to be implanted;
S3,基于所述相机参数、所述目标对象参数以及所述待植入位置,将 所述目标对象植入到所述目标图片中。S3. Based on the camera parameters, the target object parameters and the to-be-implanted position, the target object is implanted into the target picture.
可选地,在本实施例中,本领域普通技术人员可以理解上述实施例的 各种方法中的全部或部分步骤是可以通过程序来指令终端设备相关的硬 件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包 括:闪存盘、只读存储器(Read-OnlyMemory,ROM)、随机存取器(Random Access Memory,RAM)、磁盘或光盘等。Optionally, in this embodiment, those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above-mentioned embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a In the computer-readable storage medium, the storage medium may include: a flash disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk, and the like.
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The above-mentioned serial numbers of the embodiments of the present invention are only for description, and do not represent the advantages or disadvantages of the embodiments.
上述实施例中的集成的单元如果以软件功能单元的形式实现并作为 独立的产品销售或使用时,可以存储在上述计算机可读取的存储介质中。 基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的 部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计 算机软件产品存储在存储介质中,包括若干指令用以使得一台或多台计算 机设备(可为个人计算机、服务器或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。If the integrated units in the above-mentioned embodiments are implemented in the form of software functional units and sold or used as independent products, they may be stored in the above-mentioned computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, Several instructions are included to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present invention.
在本发明的上述实施例中,对各个实施例的描述都各有侧重,某个实 施例中没有详述的部分,可以参见其他实施例的相关描述。In the above-mentioned embodiments of the present invention, the description of each embodiment has its own emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
在本申请所提供的几个实施例中,应该理解到,所揭露的客户端,可 通过其它的方式实现。其中,以上所描述的装置实施例仅仅是示意性的, 例如所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外 的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统, 或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦 合或直接耦合或通信连接可以是通过一些接口,单元或模块的间接耦合或 通信连接,可以是电性或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed client may be implemented in other manners. The device embodiments described above are only illustrative, for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units or components may be combined or Integration into another system, or some features can be ignored, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of units or modules, and may be in electrical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的, 作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地 方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的 部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元 中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在 一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软 件功能单元的形式实现。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware, and can also be implemented in the form of software functional units.
以上所述仅是本发明的优选实施方式,应当指出,对于本技术领域的 普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进 和润饰,这些改进和润饰也应视为本发明的保护范围。The above are only the preferred embodiments of the present invention. It should be pointed out that for those skilled in the art, without departing from the principles of the present invention, several improvements and modifications can be made. It should be regarded as the protection scope of the present invention.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010313129.3ACN111508033A (en) | 2020-04-20 | 2020-04-20 | Camera parameter determination method, image processing method, storage medium and electronic device |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010313129.3ACN111508033A (en) | 2020-04-20 | 2020-04-20 | Camera parameter determination method, image processing method, storage medium and electronic device |
| Publication Number | Publication Date |
|---|---|
| CN111508033Atrue CN111508033A (en) | 2020-08-07 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202010313129.3APendingCN111508033A (en) | 2020-04-20 | 2020-04-20 | Camera parameter determination method, image processing method, storage medium and electronic device |
| Country | Link |
|---|---|
| CN (1) | CN111508033A (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112070896A (en)* | 2020-09-07 | 2020-12-11 | 哈尔滨工业大学(威海) | An automatic slimming method for portraits based on 3D modeling |
| CN112132909A (en)* | 2020-09-23 | 2020-12-25 | 字节跳动有限公司 | Parameter acquisition method and device, media data processing method and storage medium |
| CN113029128A (en)* | 2021-03-25 | 2021-06-25 | 浙江商汤科技开发有限公司 | Visual navigation method and related device, mobile terminal and storage medium |
| CN113301248A (en)* | 2021-04-13 | 2021-08-24 | 中科创达软件股份有限公司 | Shooting method, shooting device, electronic equipment and computer storage medium |
| CN113658265A (en)* | 2021-07-16 | 2021-11-16 | 北京迈格威科技有限公司 | Camera calibration method and device, electronic equipment and storage medium |
| CN114266833A (en)* | 2021-11-16 | 2022-04-01 | 湖北亿咖通科技有限公司 | Parameter calibration method, device and equipment for camera |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2005308777A (en)* | 2004-04-16 | 2005-11-04 | Casio Comput Co Ltd | Imaging apparatus and program thereof |
| CN104766058A (en)* | 2015-03-31 | 2015-07-08 | 百度在线网络技术(北京)有限公司 | Method and device for obtaining lane line |
| CN106600652A (en)* | 2016-12-30 | 2017-04-26 | 南京工业大学 | Panoramic camera positioning method based on artificial neural network |
| CN106845515A (en)* | 2016-12-06 | 2017-06-13 | 上海交通大学 | Robot target identification and pose reconstructing method based on virtual sample deep learning |
| CN108509855A (en)* | 2018-03-06 | 2018-09-07 | 成都睿码科技有限责任公司 | A kind of system and method generating machine learning samples pictures by augmented reality |
| US20190019335A1 (en)* | 2017-07-12 | 2019-01-17 | NextEv USA, Inc. | Camera Pose Estimation Method for Augmented Reality Manual For Cars |
| CN109493389A (en)* | 2018-10-15 | 2019-03-19 | 同济大学 | A kind of camera calibration method and system based on deep learning |
| US20190164312A1 (en)* | 2017-11-29 | 2019-05-30 | Adobe Inc. | Neural network-based camera calibration |
| CN109842811A (en)* | 2019-04-03 | 2019-06-04 | 腾讯科技(深圳)有限公司 | A kind of method, apparatus and electronic equipment being implanted into pushed information in video |
| US20190179327A1 (en)* | 2017-12-12 | 2019-06-13 | Uber Technologies, Inc. | Systems and Methods for Object Detection at Various Ranges Using Multiple Range Imagery |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2005308777A (en)* | 2004-04-16 | 2005-11-04 | Casio Comput Co Ltd | Imaging apparatus and program thereof |
| CN104766058A (en)* | 2015-03-31 | 2015-07-08 | 百度在线网络技术(北京)有限公司 | Method and device for obtaining lane line |
| CN106845515A (en)* | 2016-12-06 | 2017-06-13 | 上海交通大学 | Robot target identification and pose reconstructing method based on virtual sample deep learning |
| CN106600652A (en)* | 2016-12-30 | 2017-04-26 | 南京工业大学 | Panoramic camera positioning method based on artificial neural network |
| US20190019335A1 (en)* | 2017-07-12 | 2019-01-17 | NextEv USA, Inc. | Camera Pose Estimation Method for Augmented Reality Manual For Cars |
| US20190164312A1 (en)* | 2017-11-29 | 2019-05-30 | Adobe Inc. | Neural network-based camera calibration |
| US20190179327A1 (en)* | 2017-12-12 | 2019-06-13 | Uber Technologies, Inc. | Systems and Methods for Object Detection at Various Ranges Using Multiple Range Imagery |
| CN108509855A (en)* | 2018-03-06 | 2018-09-07 | 成都睿码科技有限责任公司 | A kind of system and method generating machine learning samples pictures by augmented reality |
| CN109493389A (en)* | 2018-10-15 | 2019-03-19 | 同济大学 | A kind of camera calibration method and system based on deep learning |
| CN109842811A (en)* | 2019-04-03 | 2019-06-04 | 腾讯科技(深圳)有限公司 | A kind of method, apparatus and electronic equipment being implanted into pushed information in video |
| Title |
|---|
| 姜广文等: "基于可控旋转的像机高精度标定技术", 光学学报, no. 05, 15 May 2010 (2010-05-15)* |
| 徐洁磐: "《人工智能导论》", 31 July 2019, 中国铁道出版社, pages: 120* |
| 董娜等: "《安防系统工程》", 31 January 2018, 北京理工大学出版社, pages: 25* |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112070896A (en)* | 2020-09-07 | 2020-12-11 | 哈尔滨工业大学(威海) | An automatic slimming method for portraits based on 3D modeling |
| CN112070896B (en)* | 2020-09-07 | 2022-05-03 | 哈尔滨工业大学(威海) | Portrait automatic slimming method based on 3D modeling |
| CN112132909A (en)* | 2020-09-23 | 2020-12-25 | 字节跳动有限公司 | Parameter acquisition method and device, media data processing method and storage medium |
| CN112132909B (en)* | 2020-09-23 | 2023-12-22 | 字节跳动有限公司 | Parameter acquisition method and device, media data processing method and storage medium |
| CN113029128A (en)* | 2021-03-25 | 2021-06-25 | 浙江商汤科技开发有限公司 | Visual navigation method and related device, mobile terminal and storage medium |
| CN113029128B (en)* | 2021-03-25 | 2023-08-25 | 浙江商汤科技开发有限公司 | Visual navigation method and related device, mobile terminal and storage medium |
| CN113301248A (en)* | 2021-04-13 | 2021-08-24 | 中科创达软件股份有限公司 | Shooting method, shooting device, electronic equipment and computer storage medium |
| CN113301248B (en)* | 2021-04-13 | 2022-09-06 | 中科创达软件股份有限公司 | Shooting method and device, electronic equipment and computer storage medium |
| CN113658265A (en)* | 2021-07-16 | 2021-11-16 | 北京迈格威科技有限公司 | Camera calibration method and device, electronic equipment and storage medium |
| CN114266833A (en)* | 2021-11-16 | 2022-04-01 | 湖北亿咖通科技有限公司 | Parameter calibration method, device and equipment for camera |
| Publication | Publication Date | Title |
|---|---|---|
| CN111508033A (en) | Camera parameter determination method, image processing method, storage medium and electronic device | |
| CN113822982B (en) | Human body three-dimensional model construction method and device, electronic equipment and storage medium | |
| CN111208783B (en) | Action simulation method, device, terminal and computer storage medium | |
| US20200111234A1 (en) | Dual-view angle image calibration method and apparatus, storage medium and electronic device | |
| WO2021052375A1 (en) | Target image generation method, apparatus, server and storage medium | |
| CN109242961A (en) | A kind of face modeling method, apparatus, electronic equipment and computer-readable medium | |
| CN116934848B (en) | Data processing method, device, equipment and medium | |
| CN114401446B (en) | Human body posture migration method, device and system, electronic equipment and storage medium | |
| CN102171726A (en) | Information processing device, information processing method, program, and information storage medium | |
| KR20210057925A (en) | Streaming server and method for object processing in multi-view video using the same | |
| CN113066125B (en) | Augmented reality method and related equipment thereof | |
| CN110163794B (en) | Image conversion method, device, storage medium and electronic device | |
| CN117689826A (en) | Three-dimensional model construction and rendering methods, devices, equipment and media | |
| WO2022083118A1 (en) | Data processing method and related device | |
| CN115115752A (en) | Deformation prediction method and device for virtual clothing, storage medium and electronic device | |
| WO2024245228A1 (en) | Attitude estimation method and related device therefor | |
| CN111222448B (en) | Image conversion method and related products | |
| CN114550293A (en) | Motion correction method and device, storage medium, and electronic device | |
| CN116266408A (en) | Body type estimating method, body type estimating device, storage medium and electronic equipment | |
| CN115908151A (en) | A data processing method, device, computer equipment and storage medium | |
| CN111738087A (en) | Method and device for generating face model of game role | |
| CN114693872B (en) | Eyeball data processing method, device, computer equipment and storage medium | |
| CN113873175B (en) | Video playing method and device, storage medium and electronic equipment | |
| CN118071965B (en) | Augmented reality anchor point placement method and device, electronic equipment and readable storage medium | |
| CN118135156B (en) | Augmented reality anchor point placement method, device, electronic device and readable storage medium |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| TA01 | Transfer of patent application right | Effective date of registration:20221212 Address after:1402, Floor 14, Block A, Haina Baichuan Headquarters Building, No. 6, Baoxing Road, Haibin Community, Xin'an Street, Bao'an District, Shenzhen, Guangdong 518100 Applicant after:Shenzhen Yayue Technology Co.,Ltd. Address before:518000 Tencent Building, No. 1 High-tech Zone, Nanshan District, Shenzhen City, Guangdong Province, 35 Floors Applicant before:TENCENT TECHNOLOGY (SHENZHEN) Co.,Ltd. | |
| TA01 | Transfer of patent application right |