Skip to content

Instantly share code, notes, and snippets.

@Erol444
Erol444 / tractor-visualization-rerun.py
Created June 13, 2024 14:52
OAK-D Long Range Tractor pointcloud visualization with native Rerun (non-colorized pointclouds?)
from depthai_sdk import OakCamera
import cv2
import depthai as dai
import rerun as rr
# Run & initialize ReRun viewer
rr.init('Rerun Oak-D-LR', spawn=True)
# Download and run the tractor recording
with OakCamera(replay="tractor-oak-d-lr") as oak:
@Erol444
Erol444 / openai_parse_pdf_output_json.py
Created June 13, 2024 09:09
openai_parse_pdf_output_json.py
from openai import OpenAI
from openai.types.beta.threads.message_create_params import Attachment, AttachmentToolFileSearch
import os
from dotenv import load_dotenv
load_dotenv()
import json
# Add your OpenAI API key
client = OpenAI(api_key=os.getenv("OPENAI_KEY"))
@Erol444
Erol444 / ndvi.py
Created June 7, 2024 12:08
NDVI camera - switchable IR filter with Luxonis' OAK-FFC-4P and Arducam's IMX477
#!/usr/bin/env python3
import depthai as dai
import cv2
pipeline = dai.Pipeline()
camA = pipeline.createColorCamera()
camA.setBoardSocket(dai.CameraBoardSocket.CAM_A)
camA.setResolution(dai.ColorCameraProperties.SensorResolution.THE_12_MP)
@Erol444
Erol444 / 32mp_cam_control.py
Created June 1, 2024 10:32
OAK-1-MAX 32MP still and video stream
#!/usr/bin/env python3
import depthai as dai
import cv2
pipeline = dai.Pipeline()
# Define a source - color camera
cam = pipeline.create(dai.node.ColorCamera)
cam.setResolution(dai.ColorCameraProperties.SensorResolution.THE_5312X6000) # 32MP for still images
@Erol444
Erol444 / oak-reconnect.py
Created February 26, 2024 17:55
DepthAI auto-reconnect
#!/usr/bin/env python3
import cv2
import depthai as dai
import numpy as np
import time
import blobconverter
# MobilenetSSD label texts
@Erol444
Erol444 / depthai_pause_continue_streaming.py
Created October 2, 2023 17:45
DepthAI OAK stop/start video streaming from ColorCamera node
#!/usr/bin/env python3
import depthai as dai
import cv2
# Create pipeline
pipeline = dai.Pipeline()
# Define sources and outputs
camRgb = pipeline.create(dai.node.ColorCamera)
@Erol444
Erol444 / lens_position_during_calib.py
Created September 6, 2023 12:14
DepthAI read lens position at calibration for all camera sensors
import depthai as dai
# Connect Device
with dai.Device() as device:
calibData = device.readCalibration()
for cam in device.getConnectedCameraFeatures():
print(f'{cam.name} lens position during calibration: {calibData.getLensPosition(cam.socket)}')
@Erol444
Erol444 / rgb-depth-align-alpha1.py
Created July 4, 2023 14:09
oak-d-w-97 alpha=1 align rgb with depth frame
#!/usr/bin/env python3
import cv2
import numpy as np
import depthai as dai
# Weights to use when blending depth/rgb image (should equal 1.0)
rgbWeight = 0.4
depthWeight = 0.6
@Erol444
Erol444 / wide-fov-depth-alignment.py
Created June 23, 2023 12:24
DepthAI Wide FOV depth align to color stream
import cv2
import numpy as np
import depthai as dai
# Weights to use when blending depth/rgb image (should equal 1.0)
rgbWeight = 0.4
depthWeight = 0.6
msgs = dict()
@Erol444
Erol444 / generate_random_colors.py
Created May 14, 2023 18:35
Comparing distinctipy method vs new method. Distinctipy need more than 2 sec to generate 64 colors.
import numpy as np
import colorsys
import cv2
import math
import time
def generate_colors(number_of_colors, pastel=0.5):
colors = []