// Need a better value for pi // Used by Extract eyebrow feat to calculate L1, L2, L3, L4, A1, A2 std::vector<float> frame::get_feats(std::vector<point> const &lndmarks) { std::vector<float> feat_point; feat_point.push_back( dist_between(lndmarks[5], lndmarks[0]) ); feat_point.push_back( dist_between(lndmarks[8], lndmarks[4]) ); float a1 = atan( (lndmarks[0].y - lndmarks[5].y)/ (lndmarks[0].x - lndmarks[5].x) ) *180/3.14; if (a1 < 0) a1 += 180; feat_point.push_back(a1); float a2 = atan( (lndmarks[4].y - lndmarks[8].y)/ (lndmarks[4].x - lndmarks[8].x) )*180/3.14; if (a2 < 0) a2 += 180; feat_point.push_back(a2); feat_point.push_back( dist_between(lndmarks[5], lndmarks[8]) ); // Calculate L4 float x_avg, y_avg; x_avg = pow( ((lndmarks[9].x + lndmarks[10].x)/2 - (lndmarks[6].x + lndmarks[7].x)/2), 2); y_avg = pow( ((lndmarks[9].y + lndmarks[10].y)/2 - (lndmarks[6].y + lndmarks[7].y)/2), 2); feat_point.push_back( sqrt(x_avg + y_avg) ); return feat_point; }
int astar(start, goal) { int k, min, ind, m; Fscore = g_score(start) + Hcost(start, goal) //Estimated total cost from start to goal. openset[i] = start; i++; m=i; neighbor[4] = {0,0,0,0}; while(m != -1) { min = F_score[m-1] for(k=m-2; k>=0; k--) { if(min > F_score[k]) { min = F_score[k]; ind = k; } } current = openset[ind]; if(current == goal) return reconstruct_path(goal); i--; closedset[l] = current; l++; neighbor[0] = neighbor[1] = neighbor[2] = neighbor[3] = alpha for(k=0; k<alpha; k++) { tentative_g_score = g_score(current) + dist_between(current, neighbor); tentative_f_score = tentative_g_score + Hcost(neighbor, goal) neighbor_f_score = g_score(neighbor[i]) + Hcost(neighbor[i], goal); if((search(closedset, neighbor[i]) == 1) && (tentative_f_score >= neighbor_f_score)) continue; if((search(openset,neighbor[i],) == 0) || (tentative_f_score < neighbor_f_score)) { came_from[] = current; if(search(openset, neighbor[i]) == 0) openset[] = neighbor[i]; } } } return 0; }