depth.py 文件源码

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

项目:depth-estimation-plane-detection 作者: honey0920 项目源码 文件源码
def get_depth(imagename):       
    caffe.set_mode_cpu()
    netFile = 'model/net_deploy.prototxt'
    modelFile = 'model/model_norm_abs_100k.caffemodel'
    net = caffe.Net(netFile, modelFile, caffe.TEST)
    input_image = cv2.imread(imagename)
    res_input=cv2.resize(input_image,(420,320),interpolation=cv2.INTER_CUBIC)
    input = loadImage(imagename, 3, WIDTH, HEIGHT)
    input *= 255
    input -= 127
    output = testNet(net, input)
    outWidth = OUT_WIDTH
    outHeight = OUT_HEIGHT
    scaleW = float(GT_WIDTH) / float(OUT_WIDTH)
    scaleH = float(GT_HEIGHT) / float(OUT_HEIGHT)
    output = scipy.ndimage.zoom(output, (1,1,scaleH,scaleW), order=3)
    outWidth *= scaleW
    outHeight *= scaleH
    #input += 127
    #input = input / 255.0
    #input = np.transpose(input, (0,2,3,1))
    #input = input[:,:,:,(2,1,0)]
    output = ProcessToOutput(output)
    path1 = DIR+'img.png'
    path2 = DIR+'depth.png'
    cv2.imwrite(path1, res_input)
    printImage(output, path2, 1, int(outWidth), int(outHeight))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号