class RoboticArm:
def __init__(self, product, configuration, inference_url):
self.product = product
self.configuration = configuration
self.inference_url = inference_url
self.K = np.reshape(np.array(self.product['camera']['intrinsics']), (3, 3), 'F')
self.pcl = None
def capture_depth_image(self):
return np.random.rand(480, 640) * 1000
def backproject(self, depth_image):
h, w = depth_image.shape
u, v = np.meshgrid(np.arange(w), np.arange(h), indexing='xy')
x = (u - self.K[0, 2]) * depth_image / self.K[0, 0]
y = (v - self.K[1, 2]) * depth_image / self.K[1, 1]
z = depth_image
return np.stack((x, y, z), axis=-1)
def detect_object(self, image_path):
files = {'files': open(image_path, 'rb')}
values = {
'product': json.dumps(self.product),
'configuration': json.dumps(self.configuration)
}
...