|
|
@@ -109,45 +109,39 @@ def run_openpose_for_image_side(index):
|
|
|
# plt.show()
|
|
|
|
|
|
|
|
|
-def run_openpose_for_normal(index):
|
|
|
+def run_openpose_for_normal(index,name):
|
|
|
print(index)
|
|
|
-
|
|
|
+
|
|
|
# 输入index和原来一样,就是序号,你可以更改一下输入或者输出,方便你们处理
|
|
|
|
|
|
# 判断是否是PNG格式,如果是,增添对alpha通道的处理
|
|
|
PNG_OR_NOT = True
|
|
|
# 调用的模型路径,无需更改
|
|
|
- # 原图像的位置,需要更改 !!
|
|
|
- test_image = './capture_image/capture_image{}.png'.format(index)
|
|
|
+ body_estimation = Body('model/body_pose_model.pth')
|
|
|
+ #原图像的位置,需要更改 !!
|
|
|
+ p='./capture_image/'+name
|
|
|
+ test_image = p+'/capture_image{}.png'.format(index)
|
|
|
if os.path.exists(test_image) is False:
|
|
|
PNG_OR_NOT = False
|
|
|
# 原图像的位置,需要更改 !!
|
|
|
- test_image = './capture_image/capture_image{}.jpg'.format(index)
|
|
|
+ test_image = p+'/capture_image{}.jpg'.format(index)
|
|
|
oriImg = cv2.imread(test_image) # B,G,R order
|
|
|
im = cv2.imread(test_image, cv2.IMREAD_UNCHANGED)
|
|
|
|
|
|
- # --- for openpose ---
|
|
|
- body_estimation = Body('model/body_pose_model.pth')
|
|
|
candidate, subset = body_estimation(oriImg)
|
|
|
-
|
|
|
- # --- for detectron ---
|
|
|
- # predictor = load_predictor()
|
|
|
- # candidate, subset = infer_image(oriImg, predictor)
|
|
|
-
|
|
|
# 坐标点数值保存路径,需要更改!!
|
|
|
- np.save('./capture_image/capture_image{}-1.png'.format(index), candidate)
|
|
|
- print('./capture_image/capture_image{}.png'.format(index))
|
|
|
+ np.save(p+'/capture_image{}-1.png'.format(index), candidate)
|
|
|
+ print(p+'/capture_image{}.png'.format(index))
|
|
|
|
|
|
# 处理
|
|
|
canvas = copy.deepcopy(oriImg)
|
|
|
canvas = util.draw_bodypose(canvas, candidate, subset)
|
|
|
- # if PNG_OR_NOT == True:
|
|
|
- # alpha_value_new = np.reshape(im[:,:,3],(im.shape[0],im.shape[1],1))
|
|
|
- # canvas = np.c_[canvas, alpha_value_new]
|
|
|
+ #if PNG_OR_NOT == True:
|
|
|
+ #alpha_value_new = np.reshape(im[:,:,3],(im.shape[0],im.shape[1],1))
|
|
|
+ #canvas = np.c_[canvas, alpha_value_new]
|
|
|
|
|
|
# 结果图片的保存路径,需要更改 !!
|
|
|
- cv2.imwrite('./capture_image/capture_image_result{}.png'.format(index), canvas,
|
|
|
- [int(cv2.IMWRITE_PNG_COMPRESSION), 9])
|
|
|
+ cv2.imwrite(p+'/capture_image_result{}.png'.format(index), canvas, [int(cv2.IMWRITE_PNG_COMPRESSION), 9])
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|