def set_params(face=False, body=1, hand=True, hand_detector=0, hand_opti=False, write_json="", nb_people_max=1, num_gpu=0, model_folder='/home/conte/openpose/models', tracking=-1): """ face : bool, calcul des keypoints du visage body : int, calcul des keypoints du corps hand : bool, calcul des keypoints des mains hand_detector : int, Select 0 to select OpenPose body detector (most accurate one and fastest one if body is enabled), 2 to indicate that it will be provided by the user, 3 to also apply hand tracking (only for hand) hand_opti : bool, paramètres optimaux pour l'efficacité, perte de rapidité write_json : str, endroit où enregistrer fichiers JSON des keypoints, "" pour ne pas enregistrer nb_people_max : int, nombre de personne max à chercher sur la frame/photo num_gpu : int, si l'on souhaite travailler manuellement sur les gpu, 0 pour ne pas s'en préoccuper """ params = dict() params["model_folder"] = model_folder # Noyau plante si face = True params["face"] = face params["hand"] = hand params["hand_detector"] = hand_detector params["body"] = body # On fixe le nombre de personne params["number_people_max"] = nb_people_max # Best results found with 6 scales # --hand_scale_number 6 --hand_scale_range 0.4 if hand_opti: params["hand_scale_number"] = 6 #params["hand_scale_range"] = float(0.4) # Save results in JSON format if write_json: params["write_json"] = write_json if num_gpu: params["num_gpu"] = int(op.get_gpu_number()) params["tracking"] = tracking # Pour calcul multi-GPU : # https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/examples/tutorial_api_python/05_keypoints_from_images_multi_gpu.py return params
) raise e # Flags parser = argparse.ArgumentParser() parser.add_argument( "--image_dir", default="../examples/media/", help= "Process a directory of images. Read all standard formats (jpg, png, bmp, etc.)." ) parser.add_argument("--no_display", default=False, help="Enable to disable the visual display.") parser.add_argument("--num_gpu", default=op.get_gpu_number(), help="Number of GPUs.") args = parser.parse_known_args() # Custom Params (refer to include/openpose/flags.hpp for more parameters) params = dict() params["model_folder"] = "../models/" params["num_gpu"] = int(vars(args[0])["num_gpu"]) numberGPUs = int(params["num_gpu"]) # Add others in path? for i in range(0, len(args[1])): curr_item = args[1][i] if i != len(args[1]) - 1: next_item = args[1][i + 1] else: next_item = "1" if "--" in curr_item and "--" in next_item:
if key not in params: params[key] = next_item # Construct it from system arguments # op.init_argv(args[1]) # oppython = op.OpenposePython() # Starting OpenPose opWrapper = op.WrapperPython() opWrapper.configure(params) opWrapper.start() # Read frames on directory imagePaths = op.get_images_on_directory(args[0].image_dir) # Read number of GPUs in your system numberGPUs = op.get_gpu_number() start = time.time() # Process and display images for imageBaseId in range(0, len(imagePaths), numberGPUs): # Create datums datums = [] # Read and push images into OpenPose wrapper for gpuId in range(0, numberGPUs): imageId = imageBaseId + gpuId if imageId < len(imagePaths): imagePath = imagePaths[imageBaseId + gpuId]
def num_gpus(self): """Return the number of GPUs.""" return pyopenpose.get_gpu_number()
import pyopenpose as op else: # Change these variables to point to the correct folder (Release/x64 etc.) sys.path.append('../../python'); # If you run `make install` (default path is `/usr/local/python` for Ubuntu), you can also access the OpenPose/python module from there. This will install OpenPose and the python library at your desired installation path. Ensure that this is in your python path in order to use it. # sys.path.append('/usr/local/python') from openpose import pyopenpose as op except ImportError as e: print('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?') raise e # Flags parser = argparse.ArgumentParser() parser.add_argument("--image_dir", default="../../../examples/media/", help="Process a directory of images. Read all standard formats (jpg, png, bmp, etc.).") parser.add_argument("--no_display", default=False, help="Enable to disable the visual display.") parser.add_argument("--num_gpu", default=op.get_gpu_number(), help="Number of GPUs.") args = parser.parse_known_args() # Custom Params (refer to include/openpose/flags.hpp for more parameters) params = dict() params["model_folder"] = "../../../models/" params["num_gpu"] = int(vars(args[0])["num_gpu"]) numberGPUs = int(params["num_gpu"]) # Add others in path? for i in range(0, len(args[1])): curr_item = args[1][i] if i != len(args[1])-1: next_item = args[1][i+1] else: next_item = "1" if "--" in curr_item and "--" in next_item: key = curr_item.replace('-','')