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 / 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 / rgb-undistortion-depth-alignment.py
Last active October 23, 2023 21:20
With latest depthai, you should just use Camera node, which does undistortion by itself. Demo here: https://github.com/luxonis/depthai-python/blob/main/examples/StereoDepth/rgb_depth_aligned.py
"""
With latest depthai, you should just use Camera node, which does undistortion by itself.
Demo here: https://github.com/luxonis/depthai-python/blob/main/examples/StereoDepth/rgb_depth_aligned.py
"""
#!/usr/bin/env python3
import cv2
import numpy as np
import depthai as dai
@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 / 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
@Erol444
Erol444 / center_text_on_cv2_frame.py
Created September 4, 2022 21:19
Center text on a OpenCV frame in Python
#!/usr/bin/env python
import cv2
import numpy as np
from enum import IntEnum
class Position(IntEnum):
"""
Where on frame do we want to print text.
"""