OpenCV -Fehler beim Versuch, Frames mithilfe einer Pyrealsense -Kamera zu erfassenPython

Python-Programme
Anonymous
 OpenCV -Fehler beim Versuch, Frames mithilfe einer Pyrealsense -Kamera zu erfassen

Post by Anonymous »

Ich erhalte diesen Fehler in meinem Terminal, wenn ich versuche, Streams von einer Pyrealsense-Kamera zu erhalten.

Code: Select all

Error capturing frames: OpenCV(4.11.0)
D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\colormap.cpp:736:
error: (-5:Bad argument) cv::ColorMap only supports source images of type
CV_8UC1 or CV_8UC3 in function 'cv::colormap::ColorMap::operator ()'
< /code>
Der Code ist wie folgt < /p>
def get_frames(self):
"""Get frames from the camera"""
try:
self.log.debug("Waiting for frames...")
self.frames = self.pipeline.wait_for_frames()
depth_frame = self.frames.get_depth_frame()
color_frame = self.frames.get_color_frame()

# Check for valid frames
if not depth_frame or not color_frame:
return None, None, None

#Convert images to numpy arrays for input to OpenCV
depth_image = np.asanyarray(depth_frame.get_data())
color_image = np.asanyarray(color_frame.get_data())

# Apply colormap on depth image
depth_colormap = cv2.normalize(depth_image, None, 0, 255, cv2.NORM_MINMAX)
depth_colormap = np.uint8(depth_colormap)
depth_colormap = cv2.applyColorMap(depth_colormap, cv2.COLORMAP_JET)

combined_image = np.hstack((color_image, depth_colormap))
return depth_image, color_image, combined_image

except Exception as e:
self.log.error(f"Error capturing frames: {e}")
return None, None, None

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post