TypeError:不支持Mat数据类型= 17,使用realsense d435显示IR数据

时间:2018-12-12 00:29:00

标签: python numpy opencv realsense

我目前正在使用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数据类型= 17

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

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

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

欢呼

1 个答案:

答案 0 :(得分:2)

您需要调用public class BusRoutes { public static void main(String[] args) { String[][] routeDetails = getBusRoutesFromUser(); determineNextAction(routeDetails); } public static void getBusRoutesFromUser() { Scanner sc = new Scanner(System.in); System.out.println("How many bus routes are there"); int routes = sc.nextInt(); String[][] routeDetails = new String[routes][4]; for (int i = 0; i < routes; i++) { System.out.println("Please enter the bus route"); System.out.println("What is the bus route"); routeDetails[i][0] = sc.nextLine(); System.out.println("Start Location"); routeDetails[i][1] = sc.nextLine(); System.out.println("End Location"); routeDetails[i][2] = sc.nextLine(); System.out.println("Who is the driver for bus route " + routeDetails[i][0]); routeDetails[i][3] = sc.nextLine(); } return routeDetails; } public static void determineNextAction(String[][] routeDetails) { // Use routeDetails array here... } } 才能从框架中获取图像。

get_data()