日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Intel Realsense D435 如何通过摄像头序列号获取指定摄像头的帧集对?

發(fā)布時(shí)間:2025/3/19 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Intel Realsense D435 如何通过摄像头序列号获取指定摄像头的帧集对? 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

需要先創(chuàng)建上下文管理器對象,通過該對象去獲取已連接攝像頭設(shè)備的序列號。
當(dāng)然也可以直接指定攝像頭的序列號,通過config.enable_device(ds5_serial)即可啟動(dòng)它。
如果不指定,則默認(rèn)啟動(dòng)下標(biāo)為[0]的那個(gè)攝像頭。

使用序列號啟動(dòng)單個(gè)攝像頭

# -*- encoding: utf-8 -*- """ @File : test_191125_根據(jù)攝像頭序列號調(diào)用指定攝像頭.py @Time : 2019/11/25 8:53 @Author : Dontla @Email : sxana@qq.com @Software: PyCharm """ import pyrealsense2 as rs import numpy as np import cv2 as cvpipeline = rs.pipeline() config = rs.config()ctx = rs.context()# if len(ctx.devices) > 0: # for d in ctx.devices: # print('Found device: ', # d.get_info(rs.camera_info.name), ' ', # d.get_info(rs.camera_info.serial_number)) # else: # print("No Intel Device connected")# 通過程序去獲取已連接攝像頭序列號 # ds5_serial = ctx.devices[0].get_info(rs.camera_info.serial_number) # 直接指定攝像頭序列號 ds5_serial = '827312070790'print('啟動(dòng)的攝像頭序列號:{}'.format(ds5_serial))config.enable_device(ds5_serial) config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30) config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)# Start streaming pipeline.start(config) try:while True:frames = pipeline.wait_for_frames()color_frame = frames.get_color_frame()depth_frame = frames.get_depth_frame()if not depth_frame or not color_frame:continuecolor_image = np.asanyarray(color_frame.get_data())depth_image = np.asanyarray(depth_frame.get_data())window = cv.namedWindow('window', cv.WINDOW_AUTOSIZE)cv.imshow('window', color_image)cv.waitKey(1) finally:pipeline.stop()

使用攝像頭序列號同時(shí)啟動(dòng)兩個(gè)攝像頭

# -*- encoding: utf-8 -*- """ @File : test_191125_嘗試不使用多線程而使用序列號同時(shí)調(diào)用多個(gè)攝像頭.py @Time : 2019/11/25 14:03 @Author : Dontla @Email : sxana@qq.com @Software: PyCharm """ import pyrealsense2 as rs import numpy as np import cv2 as cvpipeline_0 = rs.pipeline() pipeline_1 = rs.pipeline()config_0 = rs.config() config_1 = rs.config()ctx = rs.context()# 通過程序去獲取已連接攝像頭序列號 serial_0 = ctx.devices[0].get_info(rs.camera_info.serial_number) serial_1 = ctx.devices[1].get_info(rs.camera_info.serial_number) # 直接指定攝像頭序列號 # ds5_serial = '827312070790'# print('啟動(dòng)的攝像頭序列號:{}'.format(ds5_serial))config_0.enable_device(serial_0) config_1.enable_device(serial_1) config_0.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30) config_0.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30) config_1.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30) config_1.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)# Start streaming pipeline_0.start(config_0) pipeline_1.start(config_1) try:while True:frames_0 = pipeline_0.wait_for_frames()frames_1 = pipeline_1.wait_for_frames()color_frame_0 = frames_0.get_color_frame()depth_frame_0 = frames_0.get_depth_frame()color_frame_1 = frames_1.get_color_frame()depth_frame_1 = frames_1.get_depth_frame()# if not depth_frame or not color_frame:# continuecolor_image_0 = np.asanyarray(color_frame_0.get_data())depth_image_0 = np.asanyarray(depth_frame_0.get_data())color_image_1 = np.asanyarray(color_frame_1.get_data())depth_image_1 = np.asanyarray(depth_frame_1.get_data())# window = cv.namedWindow('window', cv.WINDOW_AUTOSIZE)cv.imshow('window_0', color_image_0)cv.imshow('window_1', color_image_1)cv.waitKey(1) finally:pipeline_0.stop()pipeline_1.stop()


參考文章:Which function in python wrapper can I use to operate specific camera with its serial number? #4968

總結(jié)

以上是生活随笔為你收集整理的Intel Realsense D435 如何通过摄像头序列号获取指定摄像头的帧集对?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。