Python Face Landmark ExampleΒΆ

Initialize face landmark model

from oneML import faceAPI as api
landmark_detector = api.FaceLandmarkDetector()

Initialize face landmark model with licensing

from oneML import faceAPI as api
license_manager = api.LicenseManager()
license_manager.set_key("LICENSE_KEY_VALUE_HERE")
license_manager.activate_key()
landmark_detector = api.FaceLandmarkDetector(license_manager)

Read input as numpy array

img = np.array(cv2.cvtColor(cv2.imread(image_path), cv2.COLOR_BGR2RGB), dtype=np.uint8)
imgs = np.expand_dims(img, axis=0)

Run the model

results = landmark_detector.detect_batch(imgs) # for 4 dimension numpy array (N, H, W, C)

or

result = landmark_detector.detect(img) # for 3 dimension numpy array (H, W, C)

And get the output

landmarks = result.get_landmarks()
status = output.get_return_status()