我是计算机视觉的新手。 我正在尝试从立体声网络摄像头计算深度。 我执行了以下步骤:
我没有固定值。球越远,深度越小。
我不理解3D重构给出的(x,y,z)
这是我的代码。
请帮助
while(True): 如果不是(left.grab()和right.grab()): 打印(“没有更多帧”) 打破 _,leftFrame = left.retrieve() _,rightFrame = right.retrieve() leftFrame = cv2.remap(leftFrame,leftMapX,leftMapY,cv2.INTER_LINEAR) rightFrame = cv2.remap(rightFrame,rightMapX,rightMapY,cv2.INTER_LINEAR)
displ = left_matcher.compute(rightFrame,leftFrame).astype(np.float32)/16
dispr = right_matcher.compute(leftFrame ,rightFrame ).astype(np.float32)/16
displ = np.int16(displ)
dispr = np.int16(dispr)
filteredImg=None
filteredImg = wls_filter.filter(displ, rightFrame, None, dispr) # important to put "imgL" here!!!
filteredImg = cv2.normalize(src=filteredImg, dst=filteredImg, beta=0, alpha=255, norm_type=cv2.NORM_MINMAX);
filteredImg = np.uint8(filteredImg)
cv2.imshow('disparity', filteredImg)
center=bd.ball_detection(rightFrame)
points_3D = cv2.reprojectImageTo3D(filteredImg, Q)
if center!= None:
x= points_3D[center][0]
y= points_3D[center][1]
z= points_3D[center][2]
print("1",triangulation_constant/filteredImg[center])
print("2",x,y,z)