Skip to content

Instantly share code, notes, and snippets.

@Erol444
Erol444 / oak_deptahi_script_trigger_fsync.py
Created November 21, 2022 10:34
Luxonis OAK camera trigger FSYNC pin via Script node for DM9098 board (OAK-D S2/Pro/W/Pro W)
#!/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 / colorcam_still_capture.py
Created November 12, 2022 03:22
DepthAI OAK ColorCamera still capture
#!/usr/bin/env python3
import depthai as dai
import cv2
import time
pipeline = dai.Pipeline()
# Define sources and outputs
camRgb = pipeline.create(dai.node.ColorCamera)
@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 / multi-device-mjpeg.py
Created October 13, 2022 09:03
Luxonis depthai multiple devices 4k MJPEG streaming threaded
import depthai as dai
import threading
import contextlib
import cv2
import time
from queue import Queue
run = True
# This can be customized to pass multiple parameters
def getPipeline(stereo):
@Erol444
Erol444 / script_jpeg_to_emmc.py
Created September 13, 2022 09:36
script_jpeg_to_emmc.py
#!/usr/bin/env python3
import cv2
import depthai as dai
# Create pipeline
pipeline = dai.Pipeline()
cfg = dai.BoardConfig()
cfg.emmc = True
@Erol444
Erol444 / script_save_frames_emmc.py
Created September 9, 2022 15:06
DepthAI OAK POE save frames on eMMC every few frames
#!/usr/bin/env python3
import depthai as dai
# Create pipeline
pipeline = dai.Pipeline()
cfg = dai.BoardConfig()
cfg.emmc = True
cfg.logPath = '/media/mmcsd-0-0/depthai_log_file.txt'
@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.
"""
@Erol444
Erol444 / rgb_preview_capture.py
Created August 2, 2022 14:00
DepthAI rgb preview modified to capture the 300x300 frames when 'c' is pressed
#!/usr/bin/env python3
import cv2
import depthai as dai
import time
# Create pipeline
pipeline = dai.Pipeline()
# Define source and output
@Erol444
Erol444 / oak-low-latency.py
Created July 25, 2022 18:28
DepthAI OAK low latency evaluation script
import depthai as dai
from depthai_sdk import FPSHandler as FPS
# Create pipeline
pipeline = dai.Pipeline()
pipeline.setXLinkChunkSize(0)
# Define source and output
camRgb = pipeline.create(dai.node.ColorCamera)
camRgb.setFps(30)
@Erol444
Erol444 / isp_video_preview.py
Created July 23, 2022 12:13
OAK ColorCamera ISP vs Video vs Preview - For Full FOV tutorial
#!/usr/bin/env python3
import cv2
import depthai as dai
import math
class BoundingBox:
xmin: float
ymin: float
xmax: float