Я внедряю программное обеспечение, которое должно анализировать, делает ли человек позу, похожую на позу предыдущей модели. Я использую следующий код, чтобы получить человеческие позы PoseEstimaForMobile
Хорошо, у меня уже есть точки тела модели и нового изображения в двух расположениях. Как я могу их сравнить и сказать, похожи они или нет?
В своем исследовании я наткнулся на статью https://becominghuman.ai/single-pose-comparison-a-fun-application-using-human-pose-estimation-part-2-4fd16a8bf0d3,
но он основан на python и использует такие библиотеки, как numpy, которые недоступны для Android. Я думаю, что есть вызов nd4j, наиболее похожий на numpy.
В статье по сравнению положения они показывают следующий код, который я хотел бы перевести на Java.
# Shout out to https://stackoverflow.com/a/20555267/8770351
# 2D array containing the 18 corresponding feature points
model_features = [[x1,y2],[x2,y2],...]
input_features = [[x1,y2],[x2,y2],...]
# In order to solve the augmented matrix (incl translation),
# it's required all vectors are augmented with a "1" at the end
# -> Pad the features with ones, so that our transformation can do translations too
pad = lambda x: np.hstack([x, np.ones((x.shape[0], 1))])
unpad = lambda x: x[:, :-1]
# Pad to [[ x y 1] , [x y 1]]
Y = pad(model_features)
X = pad(input_features)
# Solve the least squares problem X * A = Y
# and find the affine transformation matrix A.
A, res, rank, s = np.linalg.lstsq(X, Y)
A[np.abs(A) < 1e-10] = 0 # set really small values to zero
# Now we have found the augmented matrix A
# we can display the input on the model = X'
transform = lambda x: unpad(np.dot(pad(x), A))
#Image of input pose onto model pose
input_transform = transform(input_features)
После этого кода я мог бы использовать нечто подобное
# Split features in three parts
(model_face, model_torso, model_legs) = split_in_face_legs_torso(model_features)
(input_face, input_torso, input_legs) = split_in_face_legs_torso(input_features)
# 3x3 the same; not the best code design I know ...
# But the illustrative factor prevails here
# Solve the least-sqaures problem and find the transformation matrix
# and the corresponding image of input
(input_transformed_face, A_face) = affine_transformation(model_face,input_face)
(input_transformed_torso, A_torso) = affine_transformation(model_torso,input_torso)
(input_transformed_legs, A_legs) = affine_transformation(model_legs,input_legs)
(max_distance_face, rotation_face) = max_distance_and_rotation(model_face, input_transformed_face, A_face)
(max_distance_torso, rotation_torso) = max_distance_and_rotation(model_torso, input_transformed_torso, A_torso)
(max_distance_legs, rotation_legs) = max_distance_and_rotation(model_legs, input_transformed_legs, A_legs)
# Evaluate thresholds: euclidean distance & rotation
result_face = decide_face(max_distance_face, rotation_face)
result_torso = decide_torso(max_distance_torso, rotation_torso)
result_legs = decide_legs(max_distance_legs, rotation_legs)
return result_face and result_torso and result_legs
Мне нужно преобразовать эти два кода в Android Java.