python - 在给定 2 张图像的情况下查找对象的 3D 位置
问题描述
您好,我想在给定对象的2 个不同视图的情况下找到对象的 3D 位置。
我可以在这里提供的东西是:
- 我可以计算每个相机的内在矩阵。
- 我也知道对象的 2D 坐标,请参见此处。
- 提供对象的边界框
我在这里不能提供的东西是:
- 2 个摄像机的 3D 位置或相对位置。
- 对象的 3D 位置。
- 物体的测量。
这些是我可以用来获得与相机和内在参数相对应的中心坐标的方法。
# This function uses a custom trained fasterrcnn model to detect the object and
# the center of the objects is being calculated using the bounding boxes.
# For simplicity the centers are being hardcoded, since the object won't move
def calculateCenterAndBoundingBox(image):
...
boundingBox1 = [(715.329, 383.64413), (746.09143, 402.87524)]
boudingBox2 = [(303.78778, 391.57953), (339.4821, 412.69092)]
if image == 1:
return (730.7102, 393.2597), boundingBox1
else
return (321.63495, 402.13522), boudingBox2
#for simplicity reasons, both intrinsic cameras are the same
def calculateIntrinsic():
...
return [[512, 0.0, 512],
[0.0, 483.0443151, 364],
[0.0, 0.0, 1.0]]
我试图用 8 点算法确定我的对象的位置,所以我决定使用这个实现用 SIFT 创建一些特征关键点。
%matplotlib inline
import matplotlib.pylab as plt
import numpy as np
import pysift
import math
import cv2
def myPlot(img):
plt.figure(figsize=(15,20)) # display the output image
plt.imshow(img)
plt.xticks([])
plt.yticks([])
plt.show()
pathToImage1 = "testImage1.png"
c1, bb1 = calculateCenterAndBoundingBox(1)
originalImage1 = cv2.imread(pathToImage1)
img1 = cv2.imread(pathToImage1, 0)
originalImage1 = originalImage[math.floor(bb1[0][1]): math.floor(bb1[1][1]), math.floor(bb1[0][0]):math.floor(bb1[1][0])]
img1 = img1[math.floor(bb1[0][1]): math.floor(bb1[1][1]), math.floor(bb1[0][0]):math.floor(bb1[1][0])]
keypoints, descriptors = pysift.computeKeypointsAndDescriptors(img1)
img1=cv2.drawKeypoints(img1,keypoints,originalImage1)
myplot(img1)
pathToImage2 = "testImage2.png"
c2, bb2 = calculateCenterAndBoundingBox(2)
originalImage2 = cv2.imread(pathToImage2)
img2 = cv2.imread(pathToImage2 , 0)
originalImage2 = originalImage2[math.floor(bb2 [0][1]): math.floor(bb2 [1][1]), math.floor(bb2 [0][0]):math.floor(bb2 [1][0])]
img2 = img2[math.floor(bb2 [0][1]): math.floor(bb2 [1][1]), math.floor(bb2 [0][0]):math.floor(bb2 [1][0])]
keypoints, descriptors = pysift.computeKeypointsAndDescriptors(img2)
img2=cv2.drawKeypoints(img2,keypoints,originalImage2)
myPlot(img2)
所以在这种情况下,我显然不能使用 8 点算法。但我没有其他想法如何解决这个问题,给出上述约束。
是否可以仅给定每个相机的 2D 点和固有矩阵来计算 3D 位置?
解决方案
推荐阅读
- javascript - div点击时多选改变
- javascript - 如何监视数据库表中的特定数据?
- firebase - 无法在“特定区域”部署 Firebase 云功能?
- javascript - 更改 HTML 选项选择为图标样式
- android - 我想用从firebase数据库收到的搜索栏数据搜索数据到recyclerview
- jenkins - 我有一个 groovy utils 文件,其中包含一些方法,一种方法如何调用另一种方法
- php - codeigniter 登录 2 用户
- spring - 无法通过 Kubernetes 入口访问 websocket
- java - 如何将 30 分钟添加到我的输入时间并循环播放,直到我的输入结束时间为 12 小时格式(上午/下午)
- rest - 当前 REST API 的 GRPC 设计