//! \example tutorial-detection-object-mbt2.cpp #include #include #include #include #include #include #include #include #if (VISP_HAVE_OPENCV_VERSION >= 0x020400) void learnCube(const vpImage &I, vpMbGenericTracker &tracker, vpKeyPoint &keypoint_learning, int id) { //! [Keypoints reference detection] std::vector trainKeyPoints; double elapsedTime; keypoint_learning.detect(I, trainKeyPoints, elapsedTime); //! [Keypoints reference detection] //! [Keypoints selection on faces] std::vector polygons; std::vector > roisPt; std::pair, std::vector > > pair = tracker.getPolygonFaces(); polygons = pair.first; roisPt = pair.second; std::vector points3f; vpHomogeneousMatrix cMo; tracker.getPose(cMo); vpCameraParameters cam; tracker.getCameraParameters(cam); vpKeyPoint::compute3DForPointsInPolygons(cMo, cam, trainKeyPoints, polygons, roisPt, points3f); //! [Keypoints selection on faces] //! [Keypoints build reference] keypoint_learning.buildReference(I, trainKeyPoints, points3f, true, id); //! [Keypoints build reference] //! [Display reference keypoints] for (std::vector::const_iterator it = trainKeyPoints.begin(); it != trainKeyPoints.end(); ++it) { vpDisplay::displayCross(I, (int)it->pt.y, (int)it->pt.x, 4, vpColor::red); } //! [Display reference keypoints] } #endif int main(int argc, char **argv) { #if (VISP_HAVE_OPENCV_VERSION >= 0x020400) //! [MBT code] try { std::string videoname = "book.mpeg"; std::string videoname2 = "book2.mpeg"; for (int i = 0; i < argc; i++) { if (std::string(argv[i]) == "--name") videoname = std::string(argv[i + 1]); else if (std::string(argv[i]) == "--help") { std::cout << "\nUsage: " << argv[0] << " [--name