private void add_good_ori_features(ref List<Feature> features, double[] hist, int n, double magThr, Feature feat) { double bin, pi2 = Math.PI*2.0; int l, r, i; for (i = 0; i < n; i++) { l = (i == 0) ? n - 1 : i - 1; r = (i + 1)%n; if (hist[i] > hist[l] && hist[i] > hist[r] && hist[i] >= magThr) { bin = i + interp_hist_peak(hist[l], hist[i], hist[r]); bin = (bin < 0) ? n + bin : (bin >= n) ? bin - n : bin; var newFeat = (Feature) feat.Clone(); newFeat.ori = ((pi2*bin)/n) - Math.PI; features.Add(newFeat); } } }
public object Clone() { Feature feat = new Feature(); feat.a = a; feat.b = b; feat.bck_match = bck_match; feat.c = c; feat.category = category; feat.d = d; feat.descr = (double[]) descr.Clone(); feat.feature_data = (detection_data)feature_data.Clone(); feat.fwd_match = fwd_match; feat.img_pt = img_pt; feat.mdl_match = mdl_match; feat.mdl_pt = mdl_pt; feat.ori = ori; feat.scl = scl; feat.type = type; feat.x = x; feat.y = y; return feat; }
void normalize_descr(Feature feat) { double cur, len_inv, len_sq = 0.0; int i, d = feat.d; for (i = 0; i < d; i++) { cur = feat.descr[i]; len_sq += cur * cur; } len_inv = 1.0 / Math.Sqrt(len_sq); for (i = 0; i < d; i++) feat.descr[i] *= len_inv; }
Feature new_feature() { Feature feat = new Feature(); detection_data ddata = new detection_data(); feat.feature_data = ddata; feat.type = feature_type.FEATURE_LOWE; return feat; }
void hist_to_descr(float[, ,] hist, int d, int n, ref Feature feat) { int int_val, i, r, c, o, k = 0; feat.descr = new double[d * d * n]; for (r = 0; r < d; r++) for (c = 0; c < d; c++) for (o = 0; o < n; o++) feat.descr[k++] = hist[r, c, o]; feat.d = k; normalize_descr(feat); for (i = 0; i < k; i++) if (feat.descr[i] > SIFT_DESCR_MAG_THR) feat.descr[i] = SIFT_DESCR_MAG_THR; normalize_descr(feat); /* convert floating-point descriptor to integer valued descriptor */ for (i = 0; i < k; i++) { int_val = (int)(SIFT_INT_DESCR_FCTR * feat.descr[i]); feat.descr[i] = Math.Min(255, int_val); } }
public object Clone() { Feature feat = new Feature { a = a, b = b, bck_match = bck_match, c = c, category = category, d = d, descr = (double[]) descr.Clone(), feature_data = (DetectionData) feature_data.Clone(), fwd_match = fwd_match, img_pt = img_pt, mdl_match = mdl_match, mdl_pt = mdl_pt, ori = ori, scl = scl, type = type, x = x, y = y }; return feat; }