网上看到这个

MAXIEYE周圣砚:欲靠单目视觉挑战激光雷达

搜了一下,感觉应该就是这个工程,https://github.com/ialhashim/DenseDepth

宣传的检测效果

我网上搜一张图片,运行一下效果大致如下:

检测的准不准,自己判断了,我进行了一点点修改,只是把数据源从单张图片改为了从摄像头获取,

新建camera_test.py

import os
import glob
import argparse
import matplotlib
import cv2
import numpy as np
import matplotlib.pyplot as plt# Keras / TensorFlow
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '5'
from keras.models import load_model
from layers import BilinearUpSampling2D
from utils import predict, load_images, display_images, color_rescale
from matplotlib import pyplot as plt# Argument Parser
parser = argparse.ArgumentParser(description='High Quality Monocular Depth Estimation via Transfer Learning')
parser.add_argument('--model', default='nyu.h5', type=str, help='Trained Keras model file.')
args = parser.parse_args()# Custom object needed for inference and training
custom_objects = {'BilinearUpSampling2D': BilinearUpSampling2D, 'depth_loss_function': None}print('Loading model...')# Load model into GPU / CPU
model = load_model(args.model, custom_objects=custom_objects, compile=False)print('\nModel loaded ({0}).'.format(args.model))cap = cv2.VideoCapture(0)while True:# frame = cv2.imread("examples/626_image.png")ret, frame = cap.read()cv2.imshow("test", frame)frame = np.clip(np.asarray(frame[...,::-1], dtype=float) / 255, 0, 1)# Compute resultsoutputs = predict(model, frame[np.newaxis, :])cv2.imshow("depth", color_rescale(outputs[0]))if cv2.waitKey(1) & 0xFF == ord('q'):break

修改utils.py

import numpy as np
from PIL import Image
import cv2
import matplotlib.pyplot as plt
plasma = plt.get_cmap('plasma')def DepthNorm(x, maxDepth):return maxDepth / xdef predict(model, images, minDepth=10, maxDepth=1000, batch_size=2):# Support multiple RGBs, one RGB image, even grayscale if len(images.shape) < 3: images = np.stack((images,images,images), axis=2)if len(images.shape) < 4: images = images.reshape((1, images.shape[0], images.shape[1], images.shape[2]))# Compute predictionspredictions = model.predict(images, batch_size=batch_size)# Put in expected rangereturn np.clip(DepthNorm(predictions, maxDepth=maxDepth), minDepth, maxDepth) / maxDepthdef scale_up(scale, images):from skimage.transform import resizescaled = []for i in range(len(images)):img = images[i]output_shape = (scale * img.shape[0], scale * img.shape[1])scaled.append( resize(img, output_shape, order=1, preserve_range=True, mode='reflect', anti_aliasing=True ) )return np.stack(scaled)def load_images(image_files):loaded_images = []for file in image_files:x = np.clip(np.asarray(Image.open( file ), dtype=float) / 255, 0, 1)loaded_images.append(x)return np.stack(loaded_images, axis=0)def to_multichannel(i):if i.shape[2] == 3:return ii = i[:,:,0]print(i.shape)return np.stack((i,i,i), axis=2)def color_rescale(img):rescaled = img[:,:,0]print(np.min(rescaled))rescaled = rescaled - np.min(rescaled)print(np.max(rescaled))rescaled = rescaled / np.max(rescaled)return plasma(rescaled)[:,:,:3]def display_images(outputs, inputs=None, gt=None, is_colormap=True, is_rescale=True):import skimagefrom skimage.transform import resizeshape = (outputs[0].shape[0], outputs[0].shape[1], 3)all_images = []for i in range(outputs.shape[0]):imgs = []if isinstance(inputs, (list, tuple, np.ndarray)):x = to_multichannel(inputs[i])x = resize(x, shape, preserve_range=True, mode='reflect', anti_aliasing=True )imgs.append(x)if isinstance(gt, (list, tuple, np.ndarray)):x = to_multichannel(gt[i])x = resize(x, shape, preserve_range=True, mode='reflect', anti_aliasing=True )imgs.append(x)if is_colormap:imgs.append(color_rescale(outputs[i]))else:imgs.append(to_multichannel(outputs[i]))img_set = np.hstack(imgs)all_images.append(img_set)all_images = np.stack(all_images)return skimage.util.montage(all_images, multichannel=True, fill=(0,0,0))def save_images(filename, outputs, inputs=None, gt=None, is_colormap=True, is_rescale=False):montage =  display_images(outputs, inputs, is_colormap, is_rescale)im = Image.fromarray(np.uint8(montage*255))im.save(filename)def load_test_data(test_data_zip_file='nyu_test.zip'):print('Loading test data...', end='')import numpy as npfrom data import extract_zipdata = extract_zip(test_data_zip_file)from io import BytesIOrgb = np.load(BytesIO(data['eigen_test_rgb.npy']))depth = np.load(BytesIO(data['eigen_test_depth.npy']))crop = np.load(BytesIO(data['eigen_test_crop.npy']))print('Test data loaded.\n')return {'rgb':rgb, 'depth':depth, 'crop':crop}def compute_errors(gt, pred):thresh = np.maximum((gt / pred), (pred / gt))a1 = (thresh < 1.25   ).mean()a2 = (thresh < 1.25 ** 2).mean()a3 = (thresh < 1.25 ** 3).mean()abs_rel = np.mean(np.abs(gt - pred) / gt)rmse = (gt - pred) ** 2rmse = np.sqrt(rmse.mean())log_10 = (np.abs(np.log10(gt)-np.log10(pred))).mean()return a1, a2, a3, abs_rel, rmse, log_10def evaluate(model, rgb, depth, crop, batch_size=6, verbose=False):N = len(rgb)bs = batch_sizepredictions = []testSetDepths = []for i in range(N//bs):    x = rgb[(i)*bs:(i+1)*bs,:,:,:]# Compute resultstrue_y = depth[(i)*bs:(i+1)*bs,:,:]pred_y = scale_up(2, predict(model, x/255, minDepth=10, maxDepth=1000, batch_size=bs)[:,:,:,0]) * 10.0# Test time augmentation: mirror image estimatepred_y_flip = scale_up(2, predict(model, x[...,::-1,:]/255, minDepth=10, maxDepth=1000, batch_size=bs)[:,:,:,0]) * 10.0# Crop based on Eigen et al. croptrue_y = true_y[:,crop[0]:crop[1]+1, crop[2]:crop[3]+1]pred_y = pred_y[:,crop[0]:crop[1]+1, crop[2]:crop[3]+1]pred_y_flip = pred_y_flip[:,crop[0]:crop[1]+1, crop[2]:crop[3]+1]# Compute errors per image in batchfor j in range(len(true_y)):predictions.append(   (0.5 * pred_y[j]) + (0.5 * np.fliplr(pred_y_flip[j]))   )testSetDepths.append(   true_y[j]   )predictions = np.stack(predictions, axis=0)testSetDepths = np.stack(testSetDepths, axis=0)e = compute_errors(predictions, testSetDepths)if verbose:print("{:>10}, {:>10}, {:>10}, {:>10}, {:>10}, {:>10}".format('a1', 'a2', 'a3', 'rel', 'rms', 'log_10'))print("{:10.4f}, {:10.4f}, {:10.4f}, {:10.4f}, {:10.4f}, {:10.4f}".format(e[0],e[1],e[2],e[3],e[4],e[5]))return e

DenthDepth:深度估计(三维场景构建)——单目视觉挑战激光雷达相关推荐

  1. 单目深度估计方法:现状与前瞻

    今天为大家推荐的是<中国图象图形学报>2019年第12期论文<单目深度估计技术进展综述>,该文由中国图象图形学学会成像探测与感知专委会组织,北京理工大学刘越教授等学者撰写,对国 ...

  2. 鱼眼深度估计!环视近场感知系列之几何预测

    作者 | 王杰  编辑 | 汽车人 原文链接:https://zhuanlan.zhihu.com/p/584827087 点击下方卡片,关注"自动驾驶之心"公众号 ADAS巨卷干 ...

  3. 基于分段平面性的单目深度估计 P3Depth: Monocular Depth Estimation with a Piecewise Planarity Prior

    P3Depth: Monocular Depth Estimation with a Piecewise Planarity Prior 面向可解释深度网络的单目深度估计 0 Abstract   单 ...

  4. 深度学习之单目深度估计:无监督学习篇

    点击上方"3D视觉工坊",选择"星标" 干货第一时间送达 作者:桔子毛 https://zhuanlan.zhihu.com/p/29968267 本文仅做学术 ...

  5. 纯视觉3D目标检测新SOTA!STS:基于Camera的深度估计新方法

    点击下方卡片,关注"自动驾驶之心"公众号 ADAS巨卷干货,即可获取 点击进入→自动驾驶之心技术交流群 后台回复[领域综述]获取自动驾驶全栈近80篇综述论文! 论文链接:https ...

  6. MyDLNote-360Camera:全景图像深度估计,结合 equirectangular 和 cubemap 两种映射 (2020CVPR BiFuse)

    BiFuse: Monocular 360◦ Depth Estimation via Bi-Projection Fusion [paper] [github] [project] Fig. 1. ...

  7. 【研究报告】从单目深度估计到单目三维场景重建-沈春华老师-VALSE Webinar 22-13(总第279期)

    从单目深度估计到单目三维场景重建-沈春华老师-VALSE Webinar 22-13(总第279期) 报告总结 & 相关论文 论文代码 相关术语 前言 研究问题 单目深度估计 单目三维场景重建 ...

  8. 基于单目视觉深度估计的论文研究

    单目视觉 From Big to Small: Multi-Scale Local Planar Guidance for Monocular Depth Estimation 作者:Jin Han ...

  9. 三维感知,这些干货足够了!(自动驾驶/三维重建/SLAM/点云/标定/深度估计/3D检测)...

    人工智能渗入到越来越多领域,以计算机视觉为主的相关应用更是呈现爆发性增长,国内外资本对AI视觉兴趣只增不减,自动驾驶.工业视觉.AR/VR.测量测绘.移动机器人等领域涌现了大量独角兽公司,相关产品受到 ...

最新文章

  1. MongoDB聚合运算之group和aggregate聚集框架简单聚合(10)
  2. Springboot集成Shiro+Redis后,@Transactional注解不起作用
  3. 米农分享:浅谈好域名应具备的10大特点
  4. Linux之yum安装lamp环境
  5. FreeRTOS及其应用,万字长文,基础入门
  6. matlab实现非线性规划
  7. python如何实现小车行走_[详细推导]基于EKF的小车运动模型的python编程实现
  8. 硅谷VC想对CIO说这些
  9. 系统架构师学习笔记_第六章(下)_连载
  10. Python编程基础 一张图认识Python
  11. ubuntu 16.04 蓝牙鼠标 (可连接但是无法使用)
  12. 复旦大学《高等代数学(第三版)》教材习题答案
  13. java sao_JavaScript 的一些SAO操作
  14. 一看就懂的Android APP开发入门教程
  15. [EXP]CVE-2019-0604 Microsoft SharePoint RCE Exploit
  16. matlab增加一行ones,MATLAB repmat()、ones()、zeros()、prod()函数的使用
  17. 我如何把薪水从 50人民币/天 提升到 100美元/小时的 (3)
  18. 如何使用Matlab合并Excel表格
  19. SpringBoot2基础篇
  20. 失眠患者的功能连通性改变

热门文章

  1. RelativeLayout布局,不希望文本盖住其他组件
  2. css中的display属性之li元素
  3. window系统mysql无法输入和无法显示中文的处理配置
  4. 51nod 1617 奇偶数组
  5. Matlab-bp神经网络
  6. WebSocket的几个模块(node.js)(未完)
  7. 学习动力之“学习金字塔 (爱德加•戴尔)”理论
  8. 常用的CSS(收集)
  9. 数据挖掘的一些经典算法
  10. 用Windows Media Player截图的方法