Skip to content

Instantly share code, notes, and snippets.

View chrismatthieu's full-sized avatar
🚀
Hacking on robots!

Chris Matthieu chrismatthieu

🚀
Hacking on robots!
View GitHub Profile
"I was thinking about building a new RealSense stereo camera demo project, but wanted to run it by you to see if it's practical. It might be interesting to use the RGB camera or sensor on the RealSense camera to film like a short movie, and then use the stereo depth sensors to set like the depth of the movie. Like, say, film everything one meter and closer, and then see if we can put a green screen on everything behind the one meter depth range or whatever variable we set, so that it's like filming on a green screen studio but in about in the real world. Do you think one, this is doable, and then do you think two, this is useful? I would call this a RealSense GreenScreen app"
Yes — this is very doable, and I think it could make a surprisingly compelling RealSense demo. In computer-vision terms, what you’re describing is essentially real-time depth keying: instead of chroma-keying pixels based on “is this pixel green?”, you key them based on “is this pixel farther than X meters away?”
With a RealSense stereo
You cannot set a temperature threshold on a RealSense camera via the SDK; instead, you can read the internal temperature and use the information to determine if the camera is operating within safe limits. The laser will automatically adjust power or shut off if the projector temperature exceeds a threshold (around \(60^{\circ }C\)) to protect the camera. You can access the temperature values like rs.option.asic_temperature or rs.option.projector_temperature through the SDK, for example, by using sensor.get_option() in Python. How to get the temperature Start streaming: Begin streaming from the camera using rs.pipeline() and pipeline.start().Get the sensor: Obtain the sensor object for the depth sensor using pipeline_profile.get_device().first_depth_sensor().Access the temperature option: Call sensor.get_option() with the appropriate option. For example, to get the ASIC temperature, use rs.option.asic_temperature.For D400 series: Use rs.option.projector_temperature or rs.option.asic_temperature.For L500 series
import rclpy
from rclpy.node import Node
from geometry_msgs.msg import Twist
class TwistSubscriber(Node):
def __init__(self):
super().__init__('twist_subscriber')
self.subscription = self.create_subscription(
Twist,
'cmd_vel',
import time
import json
def fibonacci_recursive(n):
"""Generate Fibonacci sequence using recursion (inefficient for large n)."""
if n <= 0:
return []
elif n == 1:
return [0]
elif n == 2:
@chrismatthieu
chrismatthieu / factorial.py
Created October 13, 2025 22:09
corebrum demo
import time
import json
def factorial(n):
"""Compute factorial of n recursively."""
if n < 0:
raise ValueError("Factorial is not defined for negative numbers")
if n == 0 or n == 1:
return 1
return n * factorial(n - 1)
#!/bin/bash
set -e # Exit immediately if a command exits with a non-zero status
# --- Helper Functions ---
# Function for timed confirmation, takes message and function name to run
timed_confirm() {
local message=$1
local function_to_run=$2
local timeout=5 # seconds
@chrismatthieu
chrismatthieu / Rules.md
Created September 9, 2025 20:08
National Coding Week (https://codingweek.org/) RealSense Developer Challenge — Rules

National Coding Week (https://codingweek.org/) RealSense Developer Challenge — Rules

Sponsor: RealSense, Inc. (the “Sponsor”).

Eligibility: Open to individuals 18 years or older. Void where prohibited. No purchase necessary.

How to Enter:

During National Coding Week, a new RealSense challenge will be posted daily on Reddit.

@chrismatthieu
chrismatthieu / gist:a721a51b3983e89fea6a31e90314856c
Created August 28, 2025 21:45
RealSense Circle with Depth Detection
import pyrealsense2 as rs
import cv2
import numpy as np
# Configure RealSense pipeline
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)
#!/usr/bin/env python3
import pyrealsense2 as rs
import numpy as np
import cv2
import torch
from ultralytics import YOLO
import rclpy
from rclpy.node import Node
from geometry_msgs.msg import Twist
@chrismatthieu
chrismatthieu / ros-twist.py
Created March 6, 2025 18:46
Copilot + RealSense Follow Me ROS
import pyrealsense2 as rs
import numpy as np
import cv2
import json # Add import for JSON
# Load YOLOv3 model
net = cv2.dnn.readNet("yolov3.weights", "yolov3.cfg")
layer_names = net.getLayerNames()
output_layers = [layer_names[i - 1] for i in net.getUnconnectedOutLayers()]