morphology_utils.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:Shoe-Shape-Classifier 作者: jrzaurin 项目源码 文件源码
def shape_points(img, nsteps, mirrow=False, only_upper=False):
    """
    Simple formatting the shape_df output to be passed to the ShapeContext class
    """

    if mirrow:
        im =  cv2.flip(img, 2)
    else:
        im = img.copy()

    df_y = shape_df(im, 'y', nsteps)
    df_x = shape_df(im, 'x', nsteps)

    if (not df_y.empty) and (not df_x.empty):
        y_init = [(df_y.init[i], df_y.coord[i]) for i in xrange(df_y.shape[0])]
        y_end  = [(df_y.end[i], df_y.coord[i]) for i in xrange(df_y.shape[0])]
        x_init = [(df_x.coord[i], df_x.init[i]) for i in xrange(df_x.shape[0])]
        x_end  = [(df_x.coord[i], df_x.end[i]) for i in xrange(df_x.shape[0])]

        if only_upper: return x_init

        return y_init+y_end+x_init+x_end
    else:
        return []
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号