intel realsense获取8位对齐深度图

  • 实例代码
  • Mac环境配置看这里

实例代码

import png
import pyrealsense2 as rs
import logging
logging.basicConfig(level=logging.INFO)
import numpy as np
import cv2
import osdef make_directories():if not os.path.exists("JPEGImages/"):os.makedirs("JPEGImages/")if not os.path.exists("depth/"):os.makedirs("depth/")if not os.path.exists("8bit_depth/"):os.makedirs("8bit_depth/")if __name__ == "__main__":make_directories()pipeline = rs.pipeline()config = rs.config()config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)profile = pipeline.start(config)frames = pipeline.wait_for_frames()color_frame = frames.get_color_frame()intr = color_frame.profile.as_video_stream_profile().intrinsicsalign_to = rs.stream.coloralign = rs.align(align_to)number = 0while True:filecad = "JPEGImages/%s.jpg" % numberfiledepth = "depth/%s.png" % numberfiledepth_8b = "8bit_depth/%s.png" % numberframes = pipeline.wait_for_frames()aligned_frames = align.process(frames)aligned_depth_frame = aligned_frames.get_depth_frame()color_frame = aligned_frames.get_color_frame()if not aligned_depth_frame or not color_frame:continued = np.asanyarray(aligned_depth_frame.get_data())d8 = cv2.convertScaleAbs(d, alpha=0.3)pos = np.where(d8 == 0)d8[pos] = 255c = np.asanyarray(color_frame.get_data())cv2.imshow('COLOR IMAGE', c)if cv2.waitKey(1) & 0xFF == ord('q'):cv2.imwrite(filecad, c)writer16 = png.Writer(width=d.shape[1], height=d.shape[0],bitdepth=16, greyscale=True)writer8 = png.Writer(width=d.shape[1], height=d.shape[0],bitdepth=8, greyscale=True)with open(filedepth, 'wb') as f:zgray2list = d.tolist()writer16.write(f, zgray2list)with open(filedepth_8b, 'wb') as f2:zgray2list_b8 = d8.tolist()writer8.write(f2, zgray2list_b8)number += 1cv2.destroyAllWindows()

Mac环境配置看这里

Mac编译安装pyrealsense

intel realsense获取8位深度图相关推荐

  1. intel realsense保存16位深度图与rgb图程序

    IntelRealsense库安装 pip install pyrealsense2 代码解释 import pyrealsense2 as rs import numpy as np import ...

  2. Intel realsense SR300深度图获取点云和点云投影至图像全流程

    从深度图获取点云 之前用的方法一直都是利用深度图的像素坐标(x,y)和像素值z自行计算点云,代码如下 for (int m = 0; m < depth.rows; m++){for (int ...

  3. python opencv 4.1.0 cv2.convertScaleAbs()函数 (通过线性变换将数据转换成8位[uint8])(用于Intel Realsense D435显示depth图像)

    文章目录 API文档 代码示例:Intel Realsense图像的两种对齐方式 验证猜想 完整示例代码 API文档 def convertScaleAbs(src, dst=None, alpha= ...

  4. python opencv cv.applyColorMap()函数(颜色映射)ColormapTypes【将Intel Realsense D435深度图的黑白图映射为彩色图】

    文章目录 API ColormapTypes 完整应用代码[将深度图的黑白图映射为彩色图] map原理 能否map CV_24UC3的? API def applyColorMap(src, colo ...

  5. Intel Realsense d435 使用python对深度图进行预处理

    Intel Realsense d435 使用python对深度图进行预处理 本文中主要翻译一下一篇关于深度图预处理过滤器的内容,后面还会有关于距离测量的. 原文中的图像显示,是使用matplotli ...

  6. Intel Realsense D435 pyrealsense2 get_option_description() rs.option中获取参数描述

    通过get_option_description()函数能够打印rs.option中的参数描述,如: sensor = pipeline.get_active_profile().get_device ...

  7. Intel Realsense D435 通过识别目标的像素坐标和深度值(使用内参intrinsics)获取目标点的真实坐标

    Intel Realsense D435 通过识别目标的像素坐标和深度值(使用内参intrinsics)获取目标点的真实坐标 图原理 基本获取内参`intrinsics`代码 实操代码1(在`tens ...

  8. win10 打开 Intel Realsense R200获取深度和彩色视频流 ,并测试python opencv 获取

    一:win10打开 Intel Realsense  R200 1.python 需3.6或以上,我的是3.7 2.去官网下载https://github.com/IntelRealSense/lib ...

  9. Intel Realsense D435 python 如何获取(打印)所有摄像头序列号信息?

    import pyrealsense2 as rsctx = rs.context() if len(ctx.devices) > 0:for d in ctx.devices:print('F ...

最新文章

  1. 这三篇论文开源了!何恺明等人的PointRend,Hinton组的SimCLR和谷歌大脑的EfficientDet...
  2. 解析xml数据存入bean映射到数据库的 需求解决过程
  3. 如何写一个好的方法-读Clean Code 有感
  4. LLE(局部线性嵌入)matlab代码实现
  5. Node.js安装及环境配置(windows)
  6. node中events实现原理
  7. (转)比特币核心钱包(Bitcoin Core)入门使用教程
  8. 优学派看视频显示连接服务器,为何优学派WiFi连起了却进不去腾讯网
  9. WT588D语音芯片 语音模块组
  10. [Scala]正则表达式——去除特殊字符,只保留中英文和数字以及下划线
  11. Windows Azure Virtual Network (12) 虚拟网络之间点对点连接VNet Peering
  12. 计算机鼠标双击怎么,鼠标双击变成属性怎么办 鼠标双击变成属性解决办法【详解】...
  13. 2021年12月电子学会图形化四级编程题解析含答案:聪明的小猫
  14. 逻辑回归原理与sklearn实现
  15. 适合面向手机设备开发的库
  16. 扫描格式的pdf文件怎样进行识别
  17. python2B 之 DataFrame 选取多列并进行赋值
  18. Epic 客户端安装在非 C 盘(系统盘)时安装在线服务失败的解决方法
  19. 华为交换机 以太网链路捆绑实验
  20. Pod创建多个容器并访问指定容器

热门文章

  1. Java 编程问题:二、对象、不变性和`switch`表达式
  2. 获取Mac地址getMacAddress
  3. 一个普通计算机培训学校学生的迷茫。
  4. fiddler CSFF安全漏洞-重点讲解refer字段、token字段
  5. python markdown2 样式_Python markdown2.markdown方法代碼示例
  6. C++类外写构造函数实现编译报错:definition of implicitly-decleared ‘函数名’
  7. 《音视频开发》系列-总览
  8. 在JDBC中实现SQL语句的模糊查询
  9. php实用教程第3版郑阿奇课后答案_PHP实用教程(第3版)
  10. JavaScript 原型链总结(一)