Skip to content

Commit e2e651a

Browse files
committed
remove bugs
1 parent c66ed65 commit e2e651a

File tree

1 file changed

+5
-4
lines changed
  • models/pose_estimation_mediapipe

1 file changed

+5
-4
lines changed

models/pose_estimation_mediapipe/demo.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ class MPPose {
236236
// pad to square
237237
int top = personBox.at<int>(1, 0) - fullBox.at<float>(1, 0);
238238
int left = personBox.at<int>(0, 0) - fullBox.at<float>(0, 0);
239-
int right = fullBox.at<float>(1, 1) - personBox.at<int>(1, 1);
240-
int bottom = fullBox.at<float>(0, 1) - personBox.at<int>(0, 1);
239+
int bottom = fullBox.at<float>(1, 1) - personBox.at<int>(1, 1);
240+
int right = fullBox.at<float>(0, 1) - personBox.at<int>(0, 1);
241241
copyMakeBorder(image, image, top, bottom, left, right, BORDER_CONSTANT, Scalar(0, 0, 0));
242242
padBias = Point(padBias) + Point(personBox.col(0)) - Point(left, top);
243243
// compute rotation
@@ -315,16 +315,17 @@ class MPPose {
315315
scaleFactor.col(1) /= this->inputSize.height;
316316
landmarks.col(0) = (landmarks.col(0) - this->inputSize.width / 2) * scaleFactor.at<float>(0);
317317
landmarks.col(1) = (landmarks.col(1) - this->inputSize.height / 2) * scaleFactor.at<float>(1);
318+
landmarks.col(2) = landmarks.col(2) * max(scaleFactor.at<float>(1), scaleFactor.at<float>(0));
318319
Mat coordsRotationMatrix;
319320
getRotationMatrix2D(Point(0, 0), angle, 1.0).convertTo(coordsRotationMatrix, CV_32F);
320321
Mat rotatedLandmarks = landmarks.colRange(0, 2) * coordsRotationMatrix.colRange(0, 2);
321322
hconcat(rotatedLandmarks, landmarks.colRange(2, landmarks.cols), rotatedLandmarks);
322323
Mat rotatedLandmarksWorld = landmarksWorld.colRange(0, 2) * coordsRotationMatrix.colRange(0, 2);
323324
hconcat(rotatedLandmarksWorld, landmarksWorld.col(2), rotatedLandmarksWorld);
324325
// invert rotation
325-
Mat rotationComponent = rotationMatrix(Rect(0, 0, 2, 2)).clone();
326+
Mat rotationComponent = (Mat_<double>(2, 2) <<rotationMatrix.at<double>(0,0), rotationMatrix.at<double>(1, 0), rotationMatrix.at<double>(0, 1), rotationMatrix.at<double>(1, 1));
326327
Mat translationComponent = rotationMatrix(Rect(2, 0, 1, 2)).clone();
327-
Mat invertedTranslation = rotationComponent * translationComponent;
328+
Mat invertedTranslation = -rotationComponent * translationComponent;
328329
Mat inverseRotationMatrix;
329330
hconcat(rotationComponent, invertedTranslation, inverseRotationMatrix);
330331
Mat center, rc;

0 commit comments

Comments
 (0)