Beispiel #1
0
// Transforms the given coords all the way back to source image space using
// the full transformation sequence defined by this and its predecesors
// recursively, shallowest first, and finally any block re_rotation.
void DENORM::DenormTransform(const TPOINT& pt, TPOINT* original) const {
  FCOORD src_pt(pt.x, pt.y);
  FCOORD float_result;
  DenormTransform(src_pt, &float_result);
  original->x = IntCastRounded(float_result.x());
  original->y = IntCastRounded(float_result.y());
}
Beispiel #2
0
// Transforms the given coords forward to normalized space using the
// full transformation sequence defined by the block rotation, the
// predecessors, deepest first, and finally this.
void DENORM::NormTransform(const TPOINT& pt, TPOINT* transformed) const {
  FCOORD src_pt(pt.x, pt.y);
  FCOORD float_result;
  NormTransform(src_pt, &float_result);
  transformed->x = IntCastRounded(float_result.x());
  transformed->y = IntCastRounded(float_result.y());
}
Beispiel #3
0
void DENORM::NormTransform(const FCOORD& pt, FCOORD* transformed) const {
  FCOORD src_pt(pt);
  if (predecessor_ != NULL) {
    predecessor_->NormTransform(pt, &src_pt);
  } else if (block_ != NULL) {
    FCOORD fwd_rotation(block_->re_rotation().x(), -block_->re_rotation().y());
    src_pt.rotate(fwd_rotation);
  }
  LocalNormTransform(src_pt, transformed);
}
Beispiel #4
0
void CvxImgMatch::SIFTMatching(const cv::Mat & srcImg, const cv::Mat & dstImg,
                               const SIFTMatchingParameter & param,
                               vector<cv::Point2d> & srcPts, vector<cv::Point2d> & dstPts)
{
    const double ratio_threshold = 0.7;
    double feature_distance_threshold = 0.5;

    vl_feat_sift_parameter sift_param;
    sift_param.edge_thresh = 10;
    sift_param.dim = 128;
    sift_param.nlevels = 3;

    vector<std::shared_ptr<sift_keypoint> > src_keypoints;
    vector<std::shared_ptr<sift_keypoint> > dst_keypoints;
    EigenVLFeatSIFT::extractSIFTKeypoint(srcImg, sift_param, src_keypoints, false);
    EigenVLFeatSIFT::extractSIFTKeypoint(dstImg, sift_param, dst_keypoints, false);

    Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> src_descriptors;
    Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> dst_descriptors;


    EigenVLFeatSIFT::descriptorToMatrix(src_keypoints, src_descriptors);
    EigenVLFeatSIFT::descriptorToMatrix(dst_keypoints, dst_descriptors);

    EigenFlann32F flann32;
    flann32.setData(dst_descriptors);

    vector<vector<int> >  indices;       // index of src descriptors
    vector<vector<float> > dists;
    flann32.search(src_descriptors, indices, dists, 2);

    for (int i = 0; i<src_keypoints.size(); i++) {
        double dis1 = dists[i][0];
        double dis2 = dists[i][1];
        if (dis1 < feature_distance_threshold && dis1 < dis2 * ratio_threshold) {
            int dst_index = indices[i][0];
            cv::Point2d src_pt(src_keypoints[i]->location_x(), src_keypoints[i]->location_y());
            cv::Point2d dst_pt(dst_keypoints[dst_index]->location_x(), dst_keypoints[dst_index]->location_y());
            srcPts.push_back(src_pt);
            dstPts.push_back(dst_pt);
        }
    }
    assert(srcPts.size() == dstPts.size());
}