Initial Commit
This commit is contained in:
35
tests/test_camera.py
Normal file
35
tests/test_camera.py
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Test camera processing."""
|
||||
|
||||
import pytest
|
||||
import numpy as np
|
||||
import cv2
|
||||
|
||||
|
||||
def test_image_processing():
|
||||
img = np.random.randint(0, 255, (480, 640, 3), dtype=np.uint8)
|
||||
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||
assert gray.shape == (480, 640)
|
||||
|
||||
|
||||
def test_clahe():
|
||||
gray = np.random.randint(0, 255, (480, 640), dtype=np.uint8)
|
||||
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))
|
||||
enhanced = clahe.apply(gray)
|
||||
assert enhanced.shape == gray.shape
|
||||
|
||||
|
||||
def test_undistort_maps():
|
||||
K = np.array([[500, 0, 320], [0, 500, 240], [0, 0, 1]], dtype=np.float64)
|
||||
dist = np.zeros(5)
|
||||
size = (640, 480)
|
||||
|
||||
new_K, roi = cv2.getOptimalNewCameraMatrix(K, dist, size, alpha=0)
|
||||
map1, map2 = cv2.initUndistortRectifyMap(K, dist, None, new_K, size, cv2.CV_16SC2)
|
||||
|
||||
assert map1 is not None
|
||||
assert map2 is not None
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pytest.main([__file__, '-v'])
|
||||
Reference in New Issue
Block a user