Skip to content

Instantly share code, notes, and snippets.

@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 = []
@Erol444
Erol444 / get_fov.py
Created March 11, 2023 17:35
DepthAI OAK get rectified and full sensor FOV
#!/usr/bin/env python3
import depthai as dai
import numpy as np
import sys
from pathlib import Path
import math
import cv2
np.set_printoptions(suppress=True)
@Erol444
Erol444 / depthai_blend_3cam_frames.py
Created March 1, 2023 11:27
Blend 3 camera frames together
#!/usr/bin/env python3
import cv2
import numpy as np
import depthai as dai
# Optional. If set (True), the ColorCamera is downscaled from 1080p to 720p.
# Otherwise (False), the aligned depth is automatically upscaled to 1080p
downscaleColor = True
@Erol444
Erol444 / oak_deptahi_external_trigger_fsync.py
Created February 27, 2023 15:00
[DepthAI] Externally trigger FSYNC on OAK cameras
#!/usr/bin/env python3
import depthai as dai
import cv2
import time
pipeline = dai.Pipeline()
camRgb = pipeline.create(dai.node.ColorCamera)
camRgb.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB)
camRgb.setIspScale(2,3)
@Erol444
Erol444 / rgb-depth-align-12mp-depth.py
Last active May 7, 2023 20:04
DepthAI OAK Luxonis - RGB depth alignment with 12MP color stream
#!/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