def create_cost(center, xy, width, persitaltic, bend, bend_profiles, contour, contour_normals, length, weight_spacing = 1.0, weight_bending = 1.0, gamma = 1.0, kappa = 2.0):
c = tf.add(center, xy);
#tangent and normals
t = create_tangent(c);
tn = create_normalize_tangent(t);
ta = create_average_tangent(tn);
nl = create_normal(ta);
#bend the center
c = create_bend(center, nl, bend, bend_profiles);
#peristaltically move the center
c = create_peristaltic(c, ta, persitaltic);
#tangents
t = create_tangent(c);
tn = create_normalize_tangent(t);
ta = create_average_tangent(tn);
nl = create_normal(ta);
nr = tf.scalar_mul(-1.0, nl);
l,r = create_left_right(c,width,nl);
cost_left = create_cost_soft_min_aligned_distance(l, contour, nl, contour_normals, k = kappa, gamma = gamma);
cost_right= create_cost_soft_min_aligned_distance(r, contour, nr, contour_normals, k = kappa, gamma = gamma);
cost = tf.add(cost_left, cost_right);
#spacing and bending
if weight_spacing != 0:
cost_spacing = tf.scalar_mul(weight_spacing, create_cost_spacing(t, length));
cost = tf.add(cost, cost_spacing);
else:
cost_spacing = tf.constant(0);
if weight_bending != 0:
cost_bending = tf.scalar_mul(weight_bending, create_cost_bending(tn));
cost = tf.add(cost, cost_bending);
else:
cost_bending = tf.constant(0);
return (cost, cost_left, cost_right, cost_spacing, cost_bending, c, l, r, nl);
machine_vision_d.py 文件源码
python
阅读 42
收藏 0
点赞 0
评论 0
评论列表
文章目录