您好,我想找到给定2 different views of an object的对象的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点算法确定对象的位置,所以我决定使用this Implementation通过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)
However I only got 1 feature keypoint instead of 8 or more
因此,在这种情况下,我显然无法使用8点算法。 但是鉴于上述限制,我没有其他想法可以解决这个问题。
即使仅给出2D点和每个摄像机的固有矩阵,甚至可以计算3D位置吗?