Skip to content

Instantly share code, notes, and snippets.

@alex-luxonis
alex-luxonis / to_dng.py
Last active December 23, 2022 23:07
RAW headerless image to DNG format converter
# Note: install requirement: python3 -m pip install pidng
# If you get: SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
# for now you may need to use python older than 3.10, so for example:
# python3.9 -m pip install pidng
# python3.9 to_dng.py capture_raw_1920x1080_93_10bit.bw -rot
from pidng.core import RAW2DNG, DNGTags, Tag
from pidng.defs import *
import numpy as np
@alex-luxonis
alex-luxonis / OAK-D-Lite_HDR.py
Last active January 14, 2022 17:02 — forked from saching13/OAK-D-Lite_HDR.py
Add default 13MP resolution, optionally (if 0:) can be changed to 4K downscaled to 1080p. Save to disk
import depthai as dai
import numpy as np
import cv2
import queue
# Create pipeline
pipeline = dai.Pipeline()
from datetime import datetime, timedelta
import cv2
import depthai as dai
try:
from loguru import logger
except ImportError:
import logging as logger
@alex-luxonis
alex-luxonis / epipolar_lines.py
Created August 20, 2021 13:38
Draw horizontal epipolar lines - rectification check
import sys
import cv2
import numpy as np
if len(sys.argv) < 3:
raise RuntimeError('Please provide left and right image files as params')
print('Use left-click, `w` and `s` to move line drawn')
img1 = cv2.imread(sys.argv[1])
img2 = cv2.imread(sys.argv[2])
stacked = np.concatenate((img1, img2), axis=1)
@alex-luxonis
alex-luxonis / pretty.py
Created August 13, 2021 02:14
Run and prettify output of scripts that print raw strings
'''
Pretty-prints the raw-strings output of scripts.
Usage:
Place this script in the same directory as your main script,
say that's named `file.py`, then provide the script name
as parameter, but omitting the `.py` extension:
python3 pretty.py file
'''
@alex-luxonis
alex-luxonis / flash.py
Last active August 2, 2021 00:34 — forked from lucasmediaflow/flash.py
Trying to synchronize camera exposure with external flash
''' Current output:
6: fps: 1.420, latency: 0.062988 s, next exposure will start in 0.541045 s
7: fps: 1.420, latency: 0.062930 s, next exposure will start in 0.541103 s
8: fps: 1.420, latency: 0.063203 s, next exposure will start in 0.54083 s
Sent capture-still command. Last preview frame sequence number was: 8
Waiting before trigger (+1 extra frame): 1.2446962702088058
trigger flash
9: fps: 1.420, latency: 0.720992 s, next exposure will start in -0.116959 s
10: fps: 1.420, latency: 0.089930 s, next exposure will start in 0.514103 s
11: fps: 1.420, latency: 0.063053 s, next exposure will start in 0.540981 s
@alex-luxonis
alex-luxonis / uvc_test.py
Created May 19, 2021 00:31
Generic UVC camera preview and FPS measure
#!/usr/bin/env python3
# Key controls:
# q - quit
# c - capture
import cv2
import numpy as np
import time
@alex-luxonis
alex-luxonis / gen2_depth.py
Last active May 27, 2021 04:38
Gen2 StereoDepth example - absolute depth output
#!/usr/bin/env python3
import cv2
import depthai as dai
import numpy as np
pipeline = dai.Pipeline()
left = pipeline.createMonoCamera()
left.setBoardSocket(dai.CameraBoardSocket.LEFT)