get depth value of pixel
Hi, I made a depth image from pointcloud and with OpenCV Hough Transform found some circles. I get the center pixel and radius of circle. Now I want find depth values(Z values) from my original depth image inside this circle. My question is how I access to depth values of pixels. Sorry for bad English
` XYZ = o3d.geometry.PointCloud() XYZ.points = o3d.utility.Vector3dVector(xyz)
visZ = o3d.visualization.Visualizer()
visZ.create_window()
visZ.add_geometry(XYZ)
visZ.run()
image = visZ.capture_depth_float_buffer()
print(np.asarray(image))
fotka = np.asarray(image)
plt.imsave("testov.png",
np.asarray(image), dpi=1)
plt.imshow(np.asarray(image))
plt.close()
plt.show()
visZ.destroy_window()
img = cv2.imread('testov.png',0) img = cv2.medianBlur(img,5) cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1.5,100, param1=50,param2=20,minRadius=0,maxRadius=50) print(circles)
circles = np.around(circles) for i in circles[0,:]: # draw the outer circle cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2) # draw the center of the circle cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)
cv2.imshow('detected circles',cimg) cv2.waitKey(0) cv2.destroyAllWindows() `
If you keep the original image that contains the depth values you can access them via np.asarray(image)[h, w] where h and w are your height and width coordinates.