我們先看一下c++ 中的參數(shù)解釋
第一個(gè)輸入的點(diǎn)是一個(gè), (N, 3) 維的 三維坐標(biāo)系中的點(diǎn), xyz
第二個(gè)是旋轉(zhuǎn)向量,
第三個(gè)是平移向量.
第四個(gè)是相機(jī)內(nèi)參,
第五個(gè)是相機(jī)的畸變系數(shù), 如果輸入是4個(gè)時(shí), 就是[k1, k2, p1, p2], 輸入5個(gè)時(shí)就是 [k1, k2, p1, p2, k3], 也可以是更多, [k1, k2, p1, p2, k3, k4, k5, k6]
實(shí)戰(zhàn)在python里面, 我用lidar的點(diǎn)往圖像上投影的時(shí)候是這么用的(lidar上的3d框, 即8個(gè)點(diǎn).)文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-739026.html
rotation = lidar2camera_pose[:3, :3]
translation = lidar2camera_pose[:3, 3]
dist = np.array(camera_disinfo)
imagePoints, _ = cv2.projectPoints(lidar_points, rotation, translation, camera_K, dist)
imagePoints = np.reshape(imagePoints, (8, 2))
maxrect = cv2.boundingRect(imagePoints.astype(int))
但是這樣做無(wú)法把相機(jī)后面的點(diǎn)給排除掉, 所以可以這樣改文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-739026.html
lidar_points = np.dot(lidar2camera_pose[:3, :3], lidar_points.T).T + lidar2camera_pose[:3, [3]].reshape(1, 3)
lidar_points = lidar_points[lidar_points[:, 2]>0]
if len(lidar_points) < 8:
return None
rotation = np.eye(3)
translation = np.zeros((3, 1))
dist = np.array(camera_disinfo)
imagePoints, flag = cv2.projectPoints(lidar_points, rotation, translation, camera_K, dist)
imagePoints = np.reshape(imagePoints, (8, 2))
maxrect = cv2.boundingRect(imagePoints.astype(int))
到了這里,關(guān)于python中cv2.projectPoints的用法的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!