0

我正在尝试通过 keras 实现来使用人体姿势估计。我正在使用这个来源https://github.com/michalfaber/keras_Realtime_Multi-Person_Pose_Estimation。我的问题是如何生成下图的骨架视图,左侧的那个?但是,我可以在右侧生成一个。

在此处输入图像描述 ** 来源照片取自 Pexels

下面是我用来实现这一点的代码。

    # vgg normalization (subtracting mean) on input images
    model = get_testing_model()
    model.load_weights(keras_weights_file)

    # load config
    params, model_params = config_reader()

    input_image = cv2.imread(image_path)  # B,G,R order

    body_parts, all_peaks, subset, candidate = extract_parts(input_image, params, model, model_params)
    canvas = draw(input_image, all_peaks, subset, candidate)

    toc = time.time()
    print('processing time is %.5f' % (toc - tic))

    cv2.imwrite(output, canvas)

    cv2.destroyAllWindows()
4

1 回答 1

1

您需要根据您的要求绘制黑色图像而不是输入图像。下面在更新的代码中。

# vgg normalization (subtracting mean) on input images
model = get_testing_model()
model.load_weights(keras_weights_file)

# load config
params, model_params = config_reader()

input_image = cv2.imread(image_path)  # B,G,R order

body_parts, all_peaks, subset, candidate = extract_parts(input_image, params, model, model_params)
black_img = np.zeros_like(input_image, np.uint8)
canvas = draw(black_img, all_peaks, subset, candidate)

toc = time.time()
print('processing time is %.5f' % (toc - tic))

cv2.imwrite(output, canvas)

cv2.destroyAllWindows()
于 2020-05-28T15:28:37.690 回答