def run_all_samples(): for _, section_name_name, ispkg in pkgutil.walk_packages( samples.sdk.__path__): section_package_name = "samples.sdk." + section_name_name section_package = importlib.import_module(section_package_name) sample_module = importlib.import_module(section_package_name) subkey_env_name = getattr(sample_module, "SUBSCRIPTION_KEY", None) if not subkey_env_name: continue print("Executing sample from ", section_name_name) try: tools.execute_samples(sample_module.__dict__, subkey_env_name) except tools.SubscriptionKeyError as err: print("{}\n".format(err))
print("Searched for Query \" Xbox \"") # WebPages if image_results.value: # find the first web page first_image_result = image_results.value[0] if first_image_result: print("Image result count: {}".format(len( image_results.value))) print("First image insights token: {}".format( first_image_result.image_insights_token)) print("First image thumbnail url: {}".format( first_image_result.thumbnail_url)) print("First image content url: {}".format( first_image_result.content_url)) else: print("Couldn't find image results!") else: print("Couldn't find image results!") except Exception as e: print("encountered exception. " + str(e)) if __name__ == "__main__": import sys import os.path sys.path.append(os.path.abspath(os.path.join(__file__, "..", ".."))) from tools import execute_samples execute_samples(globals(), SUBSCRIPTION_KEY)
# Delete the person group. print("Delete the large person group {}.\n".format(large_person_group_id)) face_client.large_person_group.delete( large_person_group_id=large_person_group_id) def _detect_faces_helper(face_client, image_url): """Detect Faces Helper. This will detect the faces found in the image with url image_url using the provided FaceClient instance and return the faces identified in an image. """ detected_faces = face_client.face.detect_with_url(url=image_url) if not detected_faces: raise Exception('No face detected from image {}'.format(image_url)) print("{} faces detected from image {}".format(len(detected_faces), image_url)) if not detected_faces[0]: raise Exception( "Parameter return_face_id of detect_with_stream or detect_with_url must be set to true (by default) for recognition purpose." ) return detected_faces if __name__ == "__main__": import sys, os.path sys.path.append(os.path.abspath(os.path.join(__file__, "..", ".."))) from tools import execute_samples execute_samples(globals(), SUBSCRIPTION_KEY_ENV_NAME)