def drawBox(self, img):
axis = np.float32([[0,0,0], [0,1,0], [1,1,0], [1,0,0],
[0,0,-1],[0,1,-1],[1,1,-1],[1,0,-1] ])
imgpts, jac = cv2.projectPoints(axis, self.RVEC, self.TVEC, self.MTX, self.DIST)
imgpts = np.int32(imgpts).reshape(-1,2)
# draw pillars in blue color
for i,j in zip(range(4),range(4,8)):
img2 = cv2.line(img, tuple(imgpts[i]), tuple(imgpts[j]),(255,0,0),3)
# draw top layer in red color
outImg = cv2.drawContours(img2, [imgpts[4:]],-1,(0,0,255),3)
return outImg
# Debug Code.
评论列表
文章目录