【问题标题】:TypeError: mat data type = 17 is not supported, show IR data with realsense d435TypeError: mat data type = 17 is not supported, show IR data with realsense d435
【发布时间】:2019-05-13 01:10:22
【问题描述】:

我目前正在使用 d435,我想按照我的代码显示 IR 图像(左右,但暂时只关注一个):

import pyrealsense2 as rs
import numpy as np
import cv2

# We want the points object to be persistent so we can display the 
#last cloud when a frame drops
points = rs.points()

# Create a pipeline
pipeline = rs.pipeline()
#Create a config and configure the pipeline to stream
config = rs.config()
config.enable_stream(rs.stream.infrared, 1, 1280, 720, rs.format.y8, 30)
# Start streaming
profile = pipeline.start(config)

# Streaming loop
try:
    while True:
        # Get frameset of color and depth
        frames = pipeline.wait_for_frames()
        ir1_frame = frames.get_infrared_frame(1) # Left IR Camera, it allows 1, 2 or no input
        image = np.asanyarray(ir1_frame)
        cv2.namedWindow('IR Example', cv2.WINDOW_AUTOSIZE)
        cv2.imshow('IR Example', image)
        key = cv2.waitKey(1)
        # Press esc or 'q' to close the image window
        if key & 0xFF == ord('q') or key == 27:
            cv2.destroyAllWindows()
            break
finally:
    pipeline.stop()

一切正常,直到上线:

cv2.imshow('IR Example', image)

我得到错误:

TypeError: mat data type = 17 is not supported

我找到了这个链接: TypeError: src data type = 17 is not supported

但我仍然不知道如何显示我的图像。 有人有什么想法吗?请分享,我是opencv的新手。

image.shape = ()
image.dtype = dtype('O')

干杯

【问题讨论】:

  • 您可以尝试将 dtype 从“object”更改为应有的值,可能是 image.astype(numpy.float32) 或类似的东西...
  • 我认为问题在于您的图像类型为np.int8,但需要为np.uint8

标签: python numpy opencv realsense


【解决方案1】:

您需要调用get_data() 从框架中获取图像。

image = np.asanyarray(ir1_frame.get_data())

【讨论】:

  • 忘记这么简单的事情感觉自己像个白痴!^^
  • 不要!如您所说,搜索错误并没有显示相关结果。
猜你喜欢
  • 2021-06-01
  • 2021-05-24
  • 2023-03-30
  • 1970-01-01
  • 2016-03-26
  • 2020-04-25
  • 1970-01-01
  • 2020-12-22
  • 1970-01-01
相关资源
最近更新 更多