问题描述
这是我拍摄的原始图像:https://i.stack.imgur.com/MCp9B.jpg
我将图像设置为阈值:https://i.stack.imgur.com/hvSND.png
hsv_img = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
frame_threshed = cv2.inRange(hsv_img,lower_limit,upper_limit)
并搜索矩形:https://i.stack.imgur.com/1yJXq.png
#return a list of all the detected shapes in the image
contours,_ = cv2.findContours(thresholded_img,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
#list of all the detected rectangles:
detected_shapes = []
#for every detected shape
for cnt in contours :
approx = cv2.approxpolyDP(cnt,0.009 * cv2.arcLength(cnt,True),True)
#if the polygon have 4 sides and smaller then the image
if(len(approx) == sides_num) and (detected_shapes_img.shape[0]-1)
(detected_shapes_img.shape[1]-1)> cv2.contourArea(cnt):
detected_shapes.append(approx)
现在,我要提取相对于相机3D方向和位置的3D方向和位置。就像这个exempale中一样。只要记住我感兴趣的不是那个特定的图像。是要创建一个脚本,该脚本可以拍摄具有三角形形状的图像并估算形状的位置和方向。 我知道的唯一做到这一点的功能是cv2.solvePnP()。但是该功能需要相机矩阵和失真系数,而且我不知道如何获取此数据。因此,如果您知道我可以获取这些参数,或者有另一种解决方案,那么它将非常有帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)