The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

d/ht: Fix rotation/flipping of right hands

When dealing with rotated cameras, rotate them backward
to vertical, and then flip the right hand image in
the affine transform to get correct orientation of hands
for the keypoint estimator. Before, the left hand images
were being fed in upside down.

authored by

Jan Schmidt and committed by
Moses Turner
fc3fbd60 9077261a

+27 -20
+27 -20
src/xrt/tracking/hand/mercury/hg_model.cpp
··· 637 637 out_src_tri[2] = top_right; //{center - go_down + go_right}; 638 638 } break; 639 639 case CAMERA_ORIENTATION_90: { 640 + // Need to rotate the view back by -90° 641 + // top left (becomes top right) 642 + out_src_tri[0] = top_right; 640 643 641 - // top left (becomes bottom left) 642 - out_src_tri[0] = bottom_left; //{center + go_down - go_right}; 643 - 644 - // bottom left (becomes bottom right) 645 - out_src_tri[1] = bottom_right; //{center + go_down + go_right}; 644 + // bottom left (becomes top left) 645 + out_src_tri[1] = top_left; 646 646 647 - // top right (becomes top left) 648 - out_src_tri[2] = top_left; //{center - go_down - go_right}; 647 + // top right (becomes bottom right) 648 + out_src_tri[2] = bottom_right; 649 649 } break; 650 + 650 651 case CAMERA_ORIENTATION_180: { 651 652 // top left (becomes bottom right) 652 653 out_src_tri[0] = bottom_right; ··· 658 659 out_src_tri[2] = bottom_left; 659 660 } break; 660 661 case CAMERA_ORIENTATION_270: { 661 - // top left (becomes top right) 662 - out_src_tri[0] = top_right; 662 + // Need to rotate the view clockwise 90° 663 + // top left (becomes bottom left) 664 + out_src_tri[0] = bottom_left; //{center + go_down - go_right}; 663 665 664 - // bottom left (becomes top left) 665 - out_src_tri[1] = top_left; 666 + // bottom left (becomes bottom right) 667 + out_src_tri[1] = bottom_right; //{center + go_down + go_right}; 666 668 667 - // top right (becomes bottom right) 668 - out_src_tri[2] = bottom_right; 669 + // top right (becomes top left) 670 + out_src_tri[2] = top_left; //{center - go_down - go_right}; 669 671 } break; 670 672 default: assert(false); 671 673 } ··· 713 715 cv::Point2f go_right = {output->size_px / 2, 0}; 714 716 cv::Point2f go_down = {0, output->size_px / 2}; 715 717 718 + calc_src_tri(center, go_right, go_down, info->view->camera_info.camera_orientation, src_tri); 719 + 720 + /* For the right hand, flip the result horizontally since 721 + * the model is trained on left hands. 722 + * Top left, bottom left, top right */ 716 723 if (info->hand_idx == 1) { 717 - go_right *= -1; 724 + dst_tri[0] = {128, 0}; 725 + dst_tri[1] = {128, 128}; 726 + dst_tri[2] = {0, 0}; 727 + } else { 728 + dst_tri[0] = {0, 0}; 729 + dst_tri[1] = {0, 128}; 730 + dst_tri[2] = {128, 0}; 718 731 } 719 - 720 - calc_src_tri(center, go_right, go_down, info->view->camera_info.camera_orientation, src_tri); 721 - 722 - dst_tri[0] = {0, 0}; 723 - dst_tri[1] = {0, 128}; 724 - dst_tri[2] = {128, 0}; 725 732 726 733 cv::Matx23f go_there = getAffineTransform(src_tri, dst_tri); 727 734 cv::Matx23f go_back = getAffineTransform(dst_tri, src_tri);