Skip to content

Instantly share code, notes, and snippets.

@Erol444
Erol444 / demo.py
Last active April 13, 2021 09:51
DepthAI mono camera schedule
#!/usr/bin/env python3
import time
from pathlib import Path
import cv2
import depthai as dai
import schedule
import time
@Erol444
Erol444 / multiple-devices-nn.py
Last active May 7, 2021 14:42
DepthAI multiple devices NN
from pathlib import Path
import cv2
import depthai as dai
import contextlib
import numpy as np
import time
import argparse
nnPathDefault = str((Path(__file__).parent / Path('models/mobilenet-ssd_openvino_2021.2_6shave.blob')).resolve().absolute())
parser = argparse.ArgumentParser()
@Erol444
Erol444 / depthai_imagemanip_rotate.py
Last active August 2, 2021 22:24
DepthAI ImageManip rotate frames
import cv2
import depthai as dai
# Create pipeline
pipeline = dai.Pipeline()
# Define sources and outputs
monoLeft = pipeline.createMonoCamera()
monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P)
monoLeft.setBoardSocket(dai.CameraBoardSocket.LEFT)
@Erol444
Erol444 / depthai_tiling.py
Created August 3, 2021 08:38
DepthAI frame tiling
#!/usr/bin/env python3
import cv2
import depthai as dai
# Create pipeline
pipeline = dai.Pipeline()
# Define source and output
camRgb = pipeline.createColorCamera()
@Erol444
Erol444 / fatigue-detection-mono.py
Created December 28, 2021 11:42
DepthAI Fatigue detection with mono camera
import blobconverter
import cv2
import depthai as dai
import face_landmarks
openvinoVersion = "2020.3"
pipeline = dai.Pipeline()
# Define sources and outputs
monoRight = pipeline.create(dai.node.MonoCamera)
@Erol444
Erol444 / pointcloud.py
Created February 7, 2022 23:38
DepthAI OAK pointcloud
#!/usr/bin/env python3
import cv2
import numpy as np
import depthai as dai
out_depth = False # Disparity by default
out_rectified = True # Output and display rectified streams
lrcheck = True # Better handling for occlusions
extended = False # Closer-in minimum depth, disparity range is doubled
@Erol444
Erol444 / depthai_vehicle_speed_estimation.py
Created February 28, 2022 08:42
DepthAI vehicle speed estimation on OAK - Luxonis
#!/usr/bin/env python3
import argparse
import cv2
import depthai as dai
import blobconverter
import numpy as np
from libraries.depthai_replay import Replay
import time
from time import monotonic
import math
@Erol444
Erol444 / video_tracking.py
Created March 3, 2022 12:31
DepthAI feature tracking from video file
#!/usr/bin/env python3
import cv2
import depthai as dai
from collections import deque
import numpy as np
# Add path here!
cap = cv2.VideoCapture("/path/to/video.mp4")
@Erol444
Erol444 / age-gender-from-video.py
Created June 6, 2022 11:17
DepthAI running age-gender demo from video
from MultiMsgSync import TwoStageHostSeqSync
import blobconverter
import cv2
import depthai as dai
import numpy as np
def frame_norm(frame, bbox):
normVals = np.full(len(bbox), frame.shape[0])
normVals[::2] = frame.shape[1]
return (np.clip(np.array(bbox), 0, 1) * normVals).astype(int)
@Erol444
Erol444 / lite-120fps-400p.py
Created June 17, 2022 10:44
DepthAI OAK-D-Lite 120FPS 2x400P mono frames
#!/usr/bin/env python3
import cv2
import depthai as dai
from depthai_sdk import FPSHandler
# Create pipeline
pipeline = dai.Pipeline()
pipeline.setXLinkChunkSize(0)
# Define sources and outputs
monoLeft = pipeline.create(dai.node.MonoCamera)