vector<SiftMatch *> Frame::computeRelativeTransform(Frame *next, float *Rt) { fprintf(stderr, "Computing relative transform for frame: %d\n", index); for (int i = 0; i < numDevices; i++) { Pair *curr_pair = pairs[i]; Pair *next_pair = next->pairs[i]; vector<SiftMatch *> currMatches = MatchSiftData(curr_pair->siftData, next_pair->siftData, MatchSiftDistanceL2, 999.0f); matches.insert(matches.end(), currMatches.begin(), currMatches.end()); fprintf(stderr, "\tNumber filtered matched points: %lu\n", currMatches.size()); // We won't delete the point cloud of the last frame until that pair is // deleted. Oh well. // curr_pair->deletePointCloud(); } // std::ostringstream matchPath; // matchPath << "../result/match/match"; // matchPath << index + 1; // ReadMATLABMatchData(curr_match, next_match, matchPath.str().c_str()); int numMatches[1]; int numLoops = 1024; numLoops = ceil(numLoops / 128) * 128; if (matches.size() < 3) { cerr << matches.size() << endl; exit(-1); } EstimateRigidTransform(matches, Rt, numMatches, numLoops, 0.05, RigidTransformType2D); // std::ostringstream RtPath; // RtPath << "../result/Rt/Rt"; // RtPath << index + 1; // ReadMATLABRt(Rt, RtPath.str().c_str()); // cv::Mat imRresult = PrintMatchData(curr_pair->siftData, next_pair->siftData, curr_pair->gray, next_pair->gray); // printf("write image\n"); // std::ostringstream imresult_path; // imresult_path << "../result/imRresult_beforeransac_"; // imresult_path << index; // imresult_path << ".jpg"; // cv::imwrite(imresult_path.str().c_str(), imRresult); // imRresult.release(); return matches; }
void Frame::computeRelativeTransform(Frame *next) { fprintf(stderr, "Computing relative transform for frame: %d\n", index); Pair *curr_pair = pairs[0]; Pair *next_pair = next->pairs[0]; // Container for sift match points cv::Mat curr_match(0, 3, cv::DataType<float>::type); cv::Mat next_match(0, 3, cv::DataType<float>::type); int numMatchedPoints = curr_pair->getMatched3DPoints(next_pair, curr_match, next_match); fprintf(stderr, "Number matched points: %d\n", numMatchedPoints); // std::ostringstream matchPath; // matchPath << "../result/match/match"; // matchPath << index + 1; // ReadMATLABMatchData(curr_match, next_match, matchPath.str().c_str()); int numMatches[1]; int numLoops = 1024; numLoops = ceil(numLoops / 128) * 128; EstimateRigidTransform(curr_match, next_match, Rt_relative, numMatches, numLoops, 0.05); // std::ostringstream RtPath; // RtPath << "../result/Rt/Rt"; // RtPath << index + 1; // ReadMATLABRt(Rt_relative, RtPath.str().c_str()); // cv::Mat imRresult = PrintMatchData(curr_pair->siftData, next_pair->siftData, curr_pair->gray, next_pair->gray); // printf("write image\n"); // std::ostringstream imresult_path; // imresult_path << "../result/imRresult_beforeransac_"; // imresult_path << index; // imresult_path << ".jpg"; // cv::imwrite(imresult_path.str().c_str(), imRresult); // imRresult.release(); curr_match.release(); next_match.release(); }