Skip to content

Commit

Permalink
Merge branch 'main' of github.com:UT-Austin-RobIn/robot_learning_ws i…
Browse files Browse the repository at this point in the history
…nto main
  • Loading branch information
babbatem committed Apr 18, 2024
2 parents bd9133c + 989e7ea commit 1b5d2a0
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/fri_demo/ColorImage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This is the ColorImage class

import pyrealsense2 as rs
import numpy as np
import cv2

# Matplotlib testing code dependencies
from PIL import Image
import matplotlib
import tkinter as tk
matplotlib.use('TkAgg') # or 'Qt5Agg' or any other GUI backend
import matplotlib.pyplot as plt


class RealSenseCamera:
def __init__(self):
self.pipeline = rs.pipeline()
self.config = rs.config()

# Configure the pipeline
self._configure_pipeline()

def _configure_pipeline(self):
self.config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)
self.profile = self.pipeline.start(self.config)

def get_frame(self):
frames = self.pipeline.wait_for_frames()
color_frame = frames.get_color_frame()
color_image = np.asanyarray(color_frame.get_data())
color_image_rgb = cv2.cvtColor(color_image, cv2.COLOR_BGR2RGB)
return color_image_rgb

if __name__ == "__main__":
camera = RealSenseCamera()
imgplot = plt.imshow(camera.get_frame())
plt.show()

0 comments on commit 1b5d2a0

Please sign in to comment.