from scipy import linalg
import numpy as np
import matplotlib.pyplot as plt
class Camera(object):
def __init__(self, P):
self.P=P
self.K=None#标定矩阵
self.R=None#照相机旋转
self.t=None#照相机平移
self.c=None#照相机中心
def project(self,X):
x=np.dot(self.P,X)
for i in range(3):
x[i]/=x[2]
return x
def rotationMatrix(self,a):
R=np.eye(4)
R[:3,:3]=linalg.expm([[0,-a[2],a[1]],[a[2],0,-a[0]],[-a[1],a[0],0]])
return R
if __name__=="__main__":
points=np.loadtxt('C:/Users/xpp/Desktop/3D/bt.p3d')# 载入点数据
points=points.swapaxes(0,1)#交换维度以读取
points=np.vstack((points,np.ones(points.shape[1])))# 齐次坐标
P=np.hstack((np.eye(3), np.array([[0],[0],[-10]])))# 设置照相机参数
cam=Camera(P)
x=cam.project(points)
#绘制投影
plt.figure()
plt.plot(x[0],x[1],'k.',color='pink')
plt.show()
#创建变换
r=0.05*np.random.random(3)
rot=cam.rotationMatrix(r)
#旋转矩阵和投影
plt.figure()
for t in range(100):
cam.P=np.dot(cam.P,rot)
x=cam.project(points)
plt.plot(x[0],x[1],'k.',color='pink')
plt.show()
算法:旋转投影是通过照相机旋转进行投影,围绕一个随机的三维向量进行增量旋转的投影。
文献:Paumann-Page, M. , Tscheliessnig, R. , Sevcnikar, B. , Katz, R. S. , & Obinger, C. . (2019). Monomeric and homotrimeric solution structures of truncated human peroxidasin 1 variants. Biochimica et Biophysica Acta (BBA) - Proteins & Proteomics, 1868(1).
本文分享自 图像处理与模式识别研究所 微信公众号,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文参与 腾讯云自媒体同步曝光计划 ,欢迎热爱写作的你一起参与!
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有