mirror of
https://github.com/gosticks/openpose.git
synced 2026-08-12 20:30:20 +00:00
@@ -50,18 +50,22 @@ for i in range(0, len(args[1])):
|
||||
# op.init_argv(args[1])
|
||||
# oppython = op.OpenposePython()
|
||||
|
||||
# Starting OpenPose
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
try:
|
||||
# Starting OpenPose
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
|
||||
# Process Image
|
||||
datum = op.Datum()
|
||||
imageToProcess = cv2.imread(args[0].image_path)
|
||||
datum.cvInputData = imageToProcess
|
||||
opWrapper.emplaceAndPop([datum])
|
||||
# Process Image
|
||||
datum = op.Datum()
|
||||
imageToProcess = cv2.imread(args[0].image_path)
|
||||
datum.cvInputData = imageToProcess
|
||||
opWrapper.emplaceAndPop([datum])
|
||||
|
||||
# Display Image
|
||||
print("Body keypoints: \n" + str(datum.poseKeypoints))
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData)
|
||||
cv2.waitKey(0)
|
||||
# Display Image
|
||||
print("Body keypoints: \n" + str(datum.poseKeypoints))
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData)
|
||||
cv2.waitKey(0)
|
||||
except Exception as e:
|
||||
# print(e)
|
||||
sys.exit(-1)
|
||||
|
||||
@@ -52,21 +52,25 @@ for i in range(0, len(args[1])):
|
||||
# op.init_argv(args[1])
|
||||
# oppython = op.OpenposePython()
|
||||
|
||||
# Starting OpenPose
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
try:
|
||||
# Starting OpenPose
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
|
||||
# Process Image
|
||||
datum = op.Datum()
|
||||
imageToProcess = cv2.imread(args[0].image_path)
|
||||
datum.cvInputData = imageToProcess
|
||||
opWrapper.emplaceAndPop([datum])
|
||||
# Process Image
|
||||
datum = op.Datum()
|
||||
imageToProcess = cv2.imread(args[0].image_path)
|
||||
datum.cvInputData = imageToProcess
|
||||
opWrapper.emplaceAndPop([datum])
|
||||
|
||||
# Display Image
|
||||
print("Body keypoints: \n" + str(datum.poseKeypoints))
|
||||
print("Face keypoints: \n" + str(datum.faceKeypoints))
|
||||
print("Left hand keypoints: \n" + str(datum.handKeypoints[0]))
|
||||
print("Right hand keypoints: \n" + str(datum.handKeypoints[1]))
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData)
|
||||
cv2.waitKey(0)
|
||||
# Display Image
|
||||
print("Body keypoints: \n" + str(datum.poseKeypoints))
|
||||
print("Face keypoints: \n" + str(datum.faceKeypoints))
|
||||
print("Left hand keypoints: \n" + str(datum.handKeypoints[0]))
|
||||
print("Right hand keypoints: \n" + str(datum.handKeypoints[1]))
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData)
|
||||
cv2.waitKey(0)
|
||||
except Exception as e:
|
||||
# print(e)
|
||||
sys.exit(-1)
|
||||
|
||||
@@ -52,28 +52,32 @@ for i in range(0, len(args[1])):
|
||||
# op.init_argv(args[1])
|
||||
# oppython = op.OpenposePython()
|
||||
|
||||
# Starting OpenPose
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
try:
|
||||
# Starting OpenPose
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
|
||||
# Read frames on directory
|
||||
imagePaths = op.get_images_on_directory(args[0].image_dir);
|
||||
start = time.time()
|
||||
# Read frames on directory
|
||||
imagePaths = op.get_images_on_directory(args[0].image_dir);
|
||||
start = time.time()
|
||||
|
||||
# Process and display images
|
||||
for imagePath in imagePaths:
|
||||
datum = op.Datum()
|
||||
imageToProcess = cv2.imread(imagePath)
|
||||
datum.cvInputData = imageToProcess
|
||||
opWrapper.emplaceAndPop([datum])
|
||||
# Process and display images
|
||||
for imagePath in imagePaths:
|
||||
datum = op.Datum()
|
||||
imageToProcess = cv2.imread(imagePath)
|
||||
datum.cvInputData = imageToProcess
|
||||
opWrapper.emplaceAndPop([datum])
|
||||
|
||||
print("Body keypoints: \n" + str(datum.poseKeypoints))
|
||||
print("Body keypoints: \n" + str(datum.poseKeypoints))
|
||||
|
||||
if not args[0].no_display:
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData)
|
||||
key = cv2.waitKey(15)
|
||||
if key == 27: break
|
||||
if not args[0].no_display:
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData)
|
||||
key = cv2.waitKey(15)
|
||||
if key == 27: break
|
||||
|
||||
end = time.time()
|
||||
print("OpenPose demo successfully finished. Total time: " + str(end - start) + " seconds")
|
||||
end = time.time()
|
||||
print("OpenPose demo successfully finished. Total time: " + str(end - start) + " seconds")
|
||||
except Exception as e:
|
||||
# print(e)
|
||||
sys.exit(-1)
|
||||
|
||||
@@ -30,11 +30,14 @@ except ImportError as e:
|
||||
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])):
|
||||
@@ -52,52 +55,56 @@ for i in range(0, len(args[1])):
|
||||
# op.init_argv(args[1])
|
||||
# oppython = op.OpenposePython()
|
||||
|
||||
# Starting OpenPose
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
try:
|
||||
# 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 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()
|
||||
# Read number of GPUs in your system
|
||||
start = time.time()
|
||||
|
||||
# Process and display images
|
||||
for imageBaseId in range(0, len(imagePaths), numberGPUs):
|
||||
# Process and display images
|
||||
for imageBaseId in range(0, len(imagePaths), numberGPUs):
|
||||
|
||||
# Create datums
|
||||
datums = []
|
||||
# Create datums
|
||||
datums = []
|
||||
images = []
|
||||
|
||||
# Read and push images into OpenPose wrapper
|
||||
for gpuId in range(0, numberGPUs):
|
||||
# Read and push images into OpenPose wrapper
|
||||
for gpuId in range(0, numberGPUs):
|
||||
|
||||
imageId = imageBaseId+gpuId
|
||||
if imageId < len(imagePaths):
|
||||
imageId = imageBaseId+gpuId
|
||||
if imageId < len(imagePaths):
|
||||
|
||||
imagePath = imagePaths[imageBaseId+gpuId]
|
||||
datum = op.Datum()
|
||||
imageToProcess = cv2.imread(imagePath)
|
||||
datum.cvInputData = imageToProcess
|
||||
datums.append(datum)
|
||||
opWrapper.waitAndEmplace([datums[-1]])
|
||||
imagePath = imagePaths[imageBaseId+gpuId]
|
||||
datum = op.Datum()
|
||||
images.append(cv2.imread(imagePath))
|
||||
datum.cvInputData = images[-1]
|
||||
datums.append(datum)
|
||||
opWrapper.waitAndEmplace([datums[-1]])
|
||||
|
||||
# Retrieve processed results from OpenPose wrapper
|
||||
for gpuId in range(0, numberGPUs):
|
||||
# Retrieve processed results from OpenPose wrapper
|
||||
for gpuId in range(0, numberGPUs):
|
||||
|
||||
imageId = imageBaseId+gpuId
|
||||
if imageId < len(imagePaths):
|
||||
imageId = imageBaseId+gpuId
|
||||
if imageId < len(imagePaths):
|
||||
|
||||
datum = datums[gpuId]
|
||||
opWrapper.waitAndPop([datum])
|
||||
datum = datums[gpuId]
|
||||
opWrapper.waitAndPop([datum])
|
||||
|
||||
print("Body keypoints: \n" + str(datum.poseKeypoints))
|
||||
print("Body keypoints: \n" + str(datum.poseKeypoints))
|
||||
|
||||
if not args[0].no_display:
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData)
|
||||
key = cv2.waitKey(15)
|
||||
if key == 27: break
|
||||
if not args[0].no_display:
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData)
|
||||
key = cv2.waitKey(15)
|
||||
if key == 27: break
|
||||
|
||||
end = time.time()
|
||||
print("OpenPose demo successfully finished. Total time: " + str(end - start) + " seconds")
|
||||
end = time.time()
|
||||
print("OpenPose demo successfully finished. Total time: " + str(end - start) + " seconds")
|
||||
except Exception as e:
|
||||
# print(e)
|
||||
sys.exit(-1)
|
||||
|
||||
@@ -54,26 +54,30 @@ for i in range(0, len(args[1])):
|
||||
# op.init_argv(args[1])
|
||||
# oppython = op.OpenposePython()
|
||||
|
||||
# Starting OpenPose
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
try:
|
||||
# Starting OpenPose
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
|
||||
# Read image and face rectangle locations
|
||||
imageToProcess = cv2.imread(args[0].image_path)
|
||||
faceRectangles = [
|
||||
op.Rectangle(330.119385, 277.532715, 48.717274, 48.717274),
|
||||
op.Rectangle(24.036991, 267.918793, 65.175171, 65.175171),
|
||||
op.Rectangle(151.803436, 32.477852, 108.295761, 108.295761),
|
||||
]
|
||||
# Read image and face rectangle locations
|
||||
imageToProcess = cv2.imread(args[0].image_path)
|
||||
faceRectangles = [
|
||||
op.Rectangle(330.119385, 277.532715, 48.717274, 48.717274),
|
||||
op.Rectangle(24.036991, 267.918793, 65.175171, 65.175171),
|
||||
op.Rectangle(151.803436, 32.477852, 108.295761, 108.295761),
|
||||
]
|
||||
|
||||
# Create new datum
|
||||
datum = op.Datum()
|
||||
datum.cvInputData = imageToProcess
|
||||
datum.faceRectangles = faceRectangles
|
||||
# Create new datum
|
||||
datum = op.Datum()
|
||||
datum.cvInputData = imageToProcess
|
||||
datum.faceRectangles = faceRectangles
|
||||
|
||||
# Process and display image
|
||||
opWrapper.emplaceAndPop([datum])
|
||||
print("Face keypoints: \n" + str(datum.faceKeypoints))
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData)
|
||||
cv2.waitKey(0)
|
||||
# Process and display image
|
||||
opWrapper.emplaceAndPop([datum])
|
||||
print("Face keypoints: \n" + str(datum.faceKeypoints))
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData)
|
||||
cv2.waitKey(0)
|
||||
except Exception as e:
|
||||
# print(e)
|
||||
sys.exit(-1)
|
||||
|
||||
@@ -54,39 +54,43 @@ for i in range(0, len(args[1])):
|
||||
# op.init_argv(args[1])
|
||||
# oppython = op.OpenposePython()
|
||||
|
||||
# Starting OpenPose
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
try:
|
||||
# Starting OpenPose
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
|
||||
# Read image and face rectangle locations
|
||||
imageToProcess = cv2.imread(args[0].image_path)
|
||||
handRectangles = [
|
||||
# Left/Right hands person 0
|
||||
[
|
||||
op.Rectangle(320.035889, 377.675049, 69.300949, 69.300949),
|
||||
op.Rectangle(0., 0., 0., 0.),
|
||||
],
|
||||
# Left/Right hands person 1
|
||||
[
|
||||
op.Rectangle(80.155792, 407.673492, 80.812706, 80.812706),
|
||||
op.Rectangle(46.449715, 404.559753, 98.898178, 98.898178),
|
||||
],
|
||||
# Left/Right hands person 2
|
||||
[
|
||||
op.Rectangle(185.692673, 303.112244, 157.587555, 157.587555),
|
||||
op.Rectangle(88.984360, 268.866547, 117.818230, 117.818230),
|
||||
# Read image and face rectangle locations
|
||||
imageToProcess = cv2.imread(args[0].image_path)
|
||||
handRectangles = [
|
||||
# Left/Right hands person 0
|
||||
[
|
||||
op.Rectangle(320.035889, 377.675049, 69.300949, 69.300949),
|
||||
op.Rectangle(0., 0., 0., 0.),
|
||||
],
|
||||
# Left/Right hands person 1
|
||||
[
|
||||
op.Rectangle(80.155792, 407.673492, 80.812706, 80.812706),
|
||||
op.Rectangle(46.449715, 404.559753, 98.898178, 98.898178),
|
||||
],
|
||||
# Left/Right hands person 2
|
||||
[
|
||||
op.Rectangle(185.692673, 303.112244, 157.587555, 157.587555),
|
||||
op.Rectangle(88.984360, 268.866547, 117.818230, 117.818230),
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
# Create new datum
|
||||
datum = op.Datum()
|
||||
datum.cvInputData = imageToProcess
|
||||
datum.handRectangles = handRectangles
|
||||
# Create new datum
|
||||
datum = op.Datum()
|
||||
datum.cvInputData = imageToProcess
|
||||
datum.handRectangles = handRectangles
|
||||
|
||||
# Process and display image
|
||||
opWrapper.emplaceAndPop([datum])
|
||||
print("Left hand keypoints: \n" + str(datum.handKeypoints[0]))
|
||||
print("Right hand keypoints: \n" + str(datum.handKeypoints[1]))
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData)
|
||||
cv2.waitKey(0)
|
||||
# Process and display image
|
||||
opWrapper.emplaceAndPop([datum])
|
||||
print("Left hand keypoints: \n" + str(datum.handKeypoints[0]))
|
||||
print("Right hand keypoints: \n" + str(datum.handKeypoints[1]))
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData)
|
||||
cv2.waitKey(0)
|
||||
except Exception as e:
|
||||
# print(e)
|
||||
sys.exit(-1)
|
||||
|
||||
@@ -54,34 +54,38 @@ for i in range(0, len(args[1])):
|
||||
# op.init_argv(args[1])
|
||||
# oppython = op.OpenposePython()
|
||||
|
||||
# Starting OpenPose
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
try:
|
||||
# Starting OpenPose
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
|
||||
# Process Image
|
||||
datum = op.Datum()
|
||||
imageToProcess = cv2.imread(args[0].image_path)
|
||||
datum.cvInputData = imageToProcess
|
||||
opWrapper.emplaceAndPop([datum])
|
||||
# Process Image
|
||||
datum = op.Datum()
|
||||
imageToProcess = cv2.imread(args[0].image_path)
|
||||
datum.cvInputData = imageToProcess
|
||||
opWrapper.emplaceAndPop([datum])
|
||||
|
||||
# Process outputs
|
||||
outputImageF = (datum.inputNetData[0].copy())[0,:,:,:] + 0.5
|
||||
outputImageF = cv2.merge([outputImageF[0,:,:], outputImageF[1,:,:], outputImageF[2,:,:]])
|
||||
outputImageF = (outputImageF*255.).astype(dtype='uint8')
|
||||
heatmaps = datum.poseHeatMaps.copy()
|
||||
heatmaps = (heatmaps).astype(dtype='uint8')
|
||||
# Process outputs
|
||||
outputImageF = (datum.inputNetData[0].copy())[0,:,:,:] + 0.5
|
||||
outputImageF = cv2.merge([outputImageF[0,:,:], outputImageF[1,:,:], outputImageF[2,:,:]])
|
||||
outputImageF = (outputImageF*255.).astype(dtype='uint8')
|
||||
heatmaps = datum.poseHeatMaps.copy()
|
||||
heatmaps = (heatmaps).astype(dtype='uint8')
|
||||
|
||||
# Display Image
|
||||
counter = 0
|
||||
while 1:
|
||||
num_maps = heatmaps.shape[0]
|
||||
heatmap = heatmaps[counter, :, :].copy()
|
||||
heatmap = cv2.applyColorMap(heatmap, cv2.COLORMAP_JET)
|
||||
combined = cv2.addWeighted(outputImageF, 0.5, heatmap, 0.5, 0)
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", combined)
|
||||
key = cv2.waitKey(-1)
|
||||
if key == 27:
|
||||
break
|
||||
counter += 1
|
||||
counter = counter % num_maps
|
||||
# Display Image
|
||||
counter = 0
|
||||
while 1:
|
||||
num_maps = heatmaps.shape[0]
|
||||
heatmap = heatmaps[counter, :, :].copy()
|
||||
heatmap = cv2.applyColorMap(heatmap, cv2.COLORMAP_JET)
|
||||
combined = cv2.addWeighted(outputImageF, 0.5, heatmap, 0.5, 0)
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", combined)
|
||||
key = cv2.waitKey(-1)
|
||||
if key == 27:
|
||||
break
|
||||
counter += 1
|
||||
counter = counter % num_maps
|
||||
except Exception as e:
|
||||
# print(e)
|
||||
sys.exit(-1)
|
||||
@@ -35,6 +35,7 @@ args = parser.parse_known_args()
|
||||
imageToProcess = cv2.imread(args[0].image_path)
|
||||
|
||||
def get_sample_heatmaps():
|
||||
# These parameters are globally set. You need to unset variables set here if you have a new OpenPose object. See *
|
||||
params = dict()
|
||||
params["model_folder"] = "../../../models/"
|
||||
params["heatmaps_add_parts"] = True
|
||||
@@ -59,24 +60,29 @@ def get_sample_heatmaps():
|
||||
|
||||
return poseHeatMaps
|
||||
|
||||
# Get Heatmap
|
||||
poseHeatMaps = get_sample_heatmaps()
|
||||
try:
|
||||
# Get Heatmap
|
||||
poseHeatMaps = get_sample_heatmaps()
|
||||
|
||||
# Starting OpenPose
|
||||
params = dict()
|
||||
params["model_folder"] = "../../../models/"
|
||||
params["body"] = 2 # Disable OP Network
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
# Starting OpenPose
|
||||
params = dict()
|
||||
params["model_folder"] = "../../../models/"
|
||||
params["body"] = 2 # Disable OP Network
|
||||
params["upsampling_ratio"] = 0 # * Unset this variable
|
||||
opWrapper = op.WrapperPython()
|
||||
opWrapper.configure(params)
|
||||
opWrapper.start()
|
||||
|
||||
# Pass Heatmap and Run OP
|
||||
datum = op.Datum()
|
||||
datum.cvInputData = imageToProcess
|
||||
datum.poseNetOutput = poseHeatMaps
|
||||
opWrapper.emplaceAndPop([datum])
|
||||
# Pass Heatmap and Run OP
|
||||
datum = op.Datum()
|
||||
datum.cvInputData = imageToProcess
|
||||
datum.poseNetOutput = poseHeatMaps
|
||||
opWrapper.emplaceAndPop([datum])
|
||||
|
||||
# Display Image
|
||||
print("Body keypoints: \n" + str(datum.poseKeypoints))
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData)
|
||||
cv2.waitKey(0)
|
||||
# Display Image
|
||||
print("Body keypoints: \n" + str(datum.poseKeypoints))
|
||||
cv2.imshow("OpenPose 1.4.0 - Tutorial Python API", datum.cvOutputData)
|
||||
cv2.waitKey(0)
|
||||
except Exception as e:
|
||||
# print(e)
|
||||
sys.exit(-1)
|
||||
Reference in New Issue
Block a user