奥比中光相机Gemini pro使用

前言:使用python获取深度图和颜色图

一、环境准备

安装python3 opencv numpy等环境:
pip3 install opencv-python` `pip3 install numpy

二、拷贝库文件

将所需的库文件放至main程序路径下。

2.1 拷贝lib/python_lib/*.pyd和/lib/c_lib/*.dll到Samples目录
2.2 在Samples目录执行python HelloOrbbec.py等测试例子
2.3 Samples目录SyncAlignViewer.py测试例子,按D键开关对齐

关于配置文件:

​ 如果需要修改配置文件,操作如下
​ Samples/OrbbecSDKConfig_v1.0.xml,可以按照格式修改配置文件内容
​ 执行测试程序,程序会读取配置文件

python3.8代码:

#导入模块
from ObTypes import *
from Property import *
import Pipeline
import StreamProfile
from Error import ObException
import cv2
import numpy as np
import sys
import mathq = 113
ESC = 27try:# 创建管道Pipeline,它是整个高级 API 的入口点,可以通过管道轻松打开和关闭多种类型的流并获取一组帧数据pipe = Pipeline.Pipeline(None, None)# 通过创建配置来配置要在管道中启用或禁用的流config = Pipeline.Config()#窗口宽度和高度初始化,设为0windowsWidth = 0windowsHeight = 0windowsWidth2 = 0windowsHeight2 = 0try:# 获取深度摄像头的所有流配置,包括流分辨率、帧速率和帧格式depthprofiles = pipe.getStreamProfileList(OB_PY_SENSOR_DEPTH)colorprofiles = pipe.getStreamProfileList(OB_PY_SENSOR_COLOR)depthvideoProfile = NonecolorvideoProfile = Nonetry:#选择默认分辨率打开流,可以通过配置文件配置默认分辨率depthvideoProfile = depthprofiles.getProfile(0)colorvideoProfile = colorprofiles.getProfile(0)except ObException as e:print("function: %s\nargs: %s\nmessage: %s\ntype: %d\nstatus: %d" %(e.getName(), e.getArgs(), e.getMessage(), e.getExceptionType(), e.getStatus()))#深度图及窗口配置  depthProfile = depthvideoProfile.toConcreteStreamProfile(OB_PY_STREAM_VIDEO)windowsWidth = depthProfile.width()windowsHeight = depthProfile.height()config.enableStream(depthProfile)#颜色图及窗口配置colorProfile = colorvideoProfile.toConcreteStreamProfile(OB_PY_STREAM_VIDEO)windowsWidth2 = colorProfile.width()windowsHeight2 = colorProfile.height()config.enableStream(colorProfile)#输出错误信息except ObException as e:print("function: %s\nargs: %s\nmessage: %s\ntype: %d\nstatus: %d" %(e.getName(), e.getArgs(), e.getMessage(), e.getExceptionType(), e.getStatus()))print("Current device is not support depth sensor!")sys.exit()#启动 Config 中配置的流,如果没有传递任何参数,它将启动默认配置启动流。pipe.start(config, None)# 获取镜像属性是否具有可写权限if pipe.getDevice().isPropertySupported(OB_PY_PROP_DEPTH_MIRROR_BOOL, OB_PY_PERMISSION_WRITE):# 设置镜像pipe.getDevice().setBoolProperty(OB_PY_PROP_DEPTH_MIRROR_BOOL, True)if pipe.getDevice().isPropertySupported(OB_PY_PROP_COLOR_MIRROR_BOOL, OB_PY_PERMISSION_WRITE):pipe.getDevice().setBoolProperty(OB_PY_PROP_COLOR_MIRROR_BOOL, True)while True:# 以阻塞方式等待数据帧,数据帧是包含配置中启用的所有流的帧数据的复合帧,并将帧等待超时设置为 100msframeSet = pipe.waitForFrames(100)if frameSet == None:continueelse:# 在窗口中渲染两组帧,深度帧、颜色帧depthFrame = frameSet.depthFrame()colorFrame = frameSet.colorFrame()if depthFrame != None:depthsize = depthFrame.dataSize()depthdata = depthFrame.data()if depthsize != 0:# 将帧数据的大小调整为(高度,宽度,2)data = np.resize(depthdata,(windowsHeight, windowsWidth, 2))# 将帧数据从 8 位转换为 16 位newData = data[:,:,0]+data[:,:,1]*256          # 将帧数据转换为 1mm 单位newData = (newData * depthFrame.getValueScale()).astype('uint16')# 渲染显示newData = (newData / 32).astype('uint8')# 将帧数据灰色转换为 RGBnewData = cv2.cvtColor(newData, cv2.COLOR_GRAY2RGB)cv2.namedWindow("DepthViewer", cv2.WINDOW_NORMAL)cv2.imshow("DepthViewer", newData)key = cv2.waitKey(1)if colorFrame != None:# 要获取帧的大小和数据,请执行以下操作:colorsize = colorFrame.dataSize()colordata = colorFrame.data()if colorsize != 0:newData = colordataif colorFrame.format() == OB_PY_FORMAT_MJPG:newData = cv2.imdecode(newData, 1)if newData is not None:newData = np.resize(newData, (windowsHeight2, windowsWidth2, 3))elif colorFrame.format() == OB_PY_FORMAT_RGB888:newData = np.resize(newData, (windowsHeight2, windowsWidth2, 3))newData = cv2.cvtColor(newData, cv2.COLOR_RGB2BGR)elif colorFrame.format() == OB_PY_FORMAT_YUYV:newData = np.resize(newData, (windowsHeight2, windowsWidth2, 2))newData = cv2.cvtColor(newData, cv2.COLOR_YUV2BGR_YUYV)elif colorFrame.format() == OB_PY_FORMAT_UYVY:newData = np.resize(newData, (windowsHeight2, windowsWidth2, 2))newData = cv2.cvtColor(newData, cv2.COLOR_YUV2BGR_UYVY)elif colorFrame.format() == OB_PY_FORMAT_I420:newData = newData.reshape((windowsHeight2 * 3 // 2, windowsWidth2))newData = cv2.cvtColor(newData, cv2.COLOR_YUV2BGR_I420)newData = cv2.resize(newData, (windowsWidth2, windowsHeight2))#显示窗口cv2.namedWindow("ColorViewer", cv2.WINDOW_NORMAL)if newData is not None:cv2.imshow("ColorViewer", newData)#输入ESC或者q销毁所以窗口if key == ESC or key == q:cv2.destroyAllWindows()breakpipe.stop()except ObException as e:print("function: %s\nargs: %s\nmessage: %s\ntype: %d\nstatus: %d" %(e.getName(), e.getArgs(), e.getMessage(), e.getExceptionType(), e.getStatus()))

奥比中光相机Gemini pro使用相关推荐

  1. 奥比中光深度摄像头_ros与深度相机入门教程-在ROS使用奥比中光Orbbec Astra Pro

    ros与深度相机入门教程-在ROS使用奥比中光Orbbec Astra Pro 说明: 介绍如何在ros安装和使用奥比中光Orbbec Astra Pro OrbbecAstra介绍 astra_ca ...

  2. ROS中使用乐视 奥比中光(Astra Pro)深度相机显示彩色和深度图像

    环境 Ubuntu ROS Kinect or Melodic 奥比中光ROS驱动包安装地址:https://github.com/orbbec/ros_astra_camera 1.安装ROS 2. ...

  3. 奥比中光Orbbec Astra Pro体感摄像头“标定全过程”

    1.前期准备工作 在ROS中配置奥比中光Orbbec Astra Pro,保证可以正常显示RGB.深度.IR.彩色图像. 2.安装标定功能包 终端中输入命令 sudo apt install ros- ...

  4. 在ROS使用奥比中光Orbbec Astra Pro

    一.相机驱动的安装 1.安装依赖 $ sudo apt-get install build-essential freeglut3 freeglut3-dev 2.检查udev版本,需要libudev ...

  5. 全网最详细 Opencv + OpenNi + 奥比中光(Orbbec) Astra Pro /乐视三合一体感摄像头LeTMC-520 + linux 环境搭建

    本文参考 Using Orbbec Astra 3D cameras C++20学习:基于Ubuntu系统编译gcc10.2.0 linux下编译安装opencv生成opencv.pc 摄像头方案 / ...

  6. 最全“乐视三合一奥比中光Orbbec Astra Pro体感摄像头”标定全过程(1)

    1.前期准备工作 在ROS中配置乐视三合一奥比中光Orbbec Astra Pro,保证可以正常显示RGB.深度.IR.彩色图像. 2.安装标定功能包 终端中输入命令 sudo apt install ...

  7. 使用奥比中光Orbbec Astra Pro在ROS下跑orb_slam2

    使用奥比中光Orbbec Astra Pro在ROS下跑orb_slam2 一.奥比中光摄像头驱动 1. Install ROS 1) Create a ROS Workspace(if you do ...

  8. ros安装过后怎么找不到安装文件_ros配置乐视奥比中光相机

    要点: 1.要下载官方git代码 git clone https://github.com/orbbec/ros_astra_launch.git git clone orbbec/ros_astra ...

  9. 奥比中光相机的python采集代码

    奥比中光相机的python采集代码 前言 一.驱动安装 二.配置openni 三.采集代码 前言 在Windows系统下,使用python语言,采集奥比中光相机的拍摄的图像. 一.驱动安装 在奥比中光 ...

最新文章

  1. android 网络编程--URL获取数据/图片
  2. 题目1144:Freckles
  3. (JAVA学习笔记) 关于数据类型的一些扩展-面试时经常问到的问题
  4. svn 413 Request Entity Too Large 错误的解决方法
  5. 依赖注入在 dotnet core 中实现与使用:2 使用 Extensions DependencyInjection
  6. 别让for循环毁了你的程序(二)
  7. 红旗linux挂载硬盘命令,红旗6sp1修改默认挂载的硬盘分区
  8. linux脚本能轮循吗,通过Linux定时任务实现定时轮询数据库及发送Http请求
  9. 【Paddle】实践作业——建立模型并测试100张图片
  10. 20160504课堂作业
  11. TCP实现原理(三次握手与四次挥手)
  12. plsql 排序_在PLSQL中怎么能取到表中按ID降序排列的前十条记录???
  13. inav向STM32F401CCU开发板定制的过程(二)
  14. 聊聊 CITA 节点的那点事
  15. 关于lower_bound( )和upper_bound( )的常见用法
  16. 冷战与战后东亚国际秩序:影响及后果
  17. 下雨打雷效果(动态)html
  18. Not allowed to access normals on mesh ‘Combined Mesh (root: scene)‘ (isReadable is false...报错解决方法
  19. eNSP静态路由配置及其拓展配置
  20. Vue:如何制作表格数据分页查询

热门文章

  1. Java History 001 概论
  2. 世界编程语言与大学_学习新世界语言的最佳免费在线大学课程
  3. 面向对象的案例表格的排序
  4. python数据分析天气预报论文_Python定时发送天气预报邮件
  5. 时间单位+流量单位换算
  6. 离散型随机变量 连续型随机变量汇总
  7. 基于springboot+vue的便捷网住宿预约系统
  8. telnet端口连接失败怎么办 telnet端口连接失败解决方法
  9. 关于Cocos2D-X 3.10在android平台上使用外接键盘无法响应的问题
  10. 出现The import javax.servlet cannot be resolved 的解决方法