void paintEvent( QPaintEvent * ) { QPainter p(this); drawRegions( &p ); }
static Rect set_annotations(Metadata_Simple*metadata,const vector<double>&labels,shared_ptr<ImRGBZ>&im) { // Label description: // Each line is corresponding to one image. // Each line has 16x3 numbers, which indicates (x, y, z) of 16 joint locations. Note that these are joint CENTRE locations. // Note that (x, y) are in pixels and z is in mm. // The order of 16 joints is 0:Palm, 1Thumb root, 2Thumb mid, 3Thumb tip, 4Index root, 5Index mid, 6Index tip, // 7Middle root, 8Middle mid, 9Middle tip, 10:Ring root, 11:Ring mid, 12:Ring tip, 13:Pinky root, 14:Pinky mid, 15:Pinky tip. // We used Intel Creative depth sensor. Calibration parameters can be obtained as in Page 119 of SDK Manual: Rect handBB; auto getKeypoint = [&](int index) { Point2d pt(labels[0 + index*3],labels[1 + index*3]); // compute the handBB from the keypoints. if(handBB == Rect()) handBB = Rect(pt,Size(1,1)); else handBB |= Rect(pt,Size(1,1)); return pt; }; metadata->keypoint("carpals",getKeypoint(0),true); metadata->keypoint("Z_P0",getKeypoint(0),true); metadata->keypoint("Z_P1",getKeypoint(0),true); // thumb metadata->keypoint("Z_J53",getKeypoint(1),true); metadata->keypoint("Z_J52",getKeypoint(2),true); metadata->keypoint("Z_J51",getKeypoint(3),true); // index metadata->keypoint("Z_J43",getKeypoint(4),true); metadata->keypoint("Z_J42",getKeypoint(5),true); metadata->keypoint("Z_J41",getKeypoint(6),true); // mid metadata->keypoint("Z_J33",getKeypoint(7),true); metadata->keypoint("Z_J32",getKeypoint(8),true); metadata->keypoint("Z_J31",getKeypoint(9),true); // ring metadata->keypoint("Z_J23",getKeypoint(10),true); metadata->keypoint("Z_J22",getKeypoint(11),true); metadata->keypoint("Z_J21",getKeypoint(12),true); // pinky metadata->keypoint("Z_J13",getKeypoint(13),true); metadata->keypoint("Z_J12",getKeypoint(14),true); metadata->keypoint("Z_J11",getKeypoint(15),true); // set the hand bb Mat Zeroded = imopen(im->Z,5); //cv::erode(im,result,Mat()); handBB = bbWhere(Zeroded,[](Mat&Z,int y,int x) { return goodNumber(Z.at<float>(y,x)) and Z.at<float>(y,x) < params::MAX_Z(); }); handBB = rectResize(handBB,2,2); metadata->set_HandBB(handBB); metadata->set_is_left_hand(true); // generate the segmentation if(g_params.get_value("SEGMENTATION") == "TRUE") { Mat seg = drawRegions(*metadata); metadata->setSegmentation(seg); } return handBB; }