Accessing camera images via frame.images
returns invalid images even though the 'Allow images' option is checked in the Leap Motion Control Panel and POLICY_IMAGES
is set in the Leap controller object
The code I'm trying to run is very similar to this. The is_valid
attribute is always False
for the images
update: It appears that the policy is not being set even after calling controller.set_policy_flag()
. Printing the policy flags shows 0, which is the default policy
update: This is happening with v2.3.1 of the API as well
resolution: turns out the v4 software was installed which didn't work with the v2/v3 API.
def run(controller):
maps_initialized = False
while(True):
frame = controller.frame()
image = frame.images[0]
if image.is_valid:
if not maps_initialized:
left_coordinates, left_coefficients = convert_distortion_maps(frame.images[0])
right_coordinates, right_coefficients = convert_distortion_maps(frame.images[1])
maps_initialized = True
undistorted_left = undistort(image, left_coordinates, left_coefficients, 400, 400)
undistorted_right = undistort(image, right_coordinates, right_coefficients, 400, 400)
#display images
cv2.imshow('Left Camera', undistorted_left)
cv2.imshow('Right Camera', undistorted_right)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
def main():
controller = Leap.Controller()
controller.set_policy_flags(Leap.Controller.POLICY_IMAGES)
try:
run(controller)
except KeyboardInterrupt:
sys.exit(0)
if __name__ == '__main__':
main()