Skip to content

Commit

Permalink
Obtain intrinsics dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
SzabolcsGergely committed Nov 18, 2024
1 parent e6f60aa commit e33723b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion examples/ImageAlign/depth_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def getFps(self):
device = dai.Device()

calibrationHandler = device.readCalibration()
rgbIntrinsics = calibrationHandler.getCameraIntrinsics(RGB_SOCKET, int(1920 / ISP_SCALE), int(1080 / ISP_SCALE))
rgbDistortion = calibrationHandler.getDistortionCoefficients(RGB_SOCKET)
distortionModel = calibrationHandler.getDistortionModel(RGB_SOCKET)
if distortionModel != dai.CameraModel.Perspective:
Expand Down Expand Up @@ -160,6 +159,8 @@ def updateBlendWeights(percentRgb):
if frameDepth is not None:
cvFrame = frameRgb.getCvFrame()

rgbIntrinsics = calibrationHandler.getCameraIntrinsics(RGB_SOCKET, int(cvFrame.shape[1]), int(cvFrame.shape[0]))

# Undistort the rgb frame
cvFrameUndistorted = cv2.undistort(
cvFrame,
Expand Down
3 changes: 2 additions & 1 deletion examples/ImageAlign/image_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
device = dai.Device()

calibrationHandler = device.readCalibration()
rgbIntrinsics = calibrationHandler.getCameraIntrinsics(RGB_SOCKET, int(1920 / ISP_SCALE), int(1080 / ISP_SCALE))
rgbDistortion = calibrationHandler.getDistortionCoefficients(RGB_SOCKET)
distortionModel = calibrationHandler.getDistortionModel(RGB_SOCKET)
if distortionModel != dai.CameraModel.Perspective:
Expand Down Expand Up @@ -120,6 +119,8 @@ def updateDepthPlane(depth):
# Colorize the aligned depth
leftCv = leftAligned.getCvFrame()

rgbIntrinsics = calibrationHandler.getCameraIntrinsics(RGB_SOCKET, int(frameRgbCv.shape[1]), int(frameRgbCv.shape[0]))

cvFrameUndistorted = cv2.undistort(
frameRgbCv,
np.array(rgbIntrinsics),
Expand Down
3 changes: 2 additions & 1 deletion examples/ImageAlign/thermal_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def getFps(self):
device = dai.Device()

calibrationHandler = device.readCalibration()
rgbIntrinsics = calibrationHandler.getCameraIntrinsics(RGB_SOCKET, int(1920 / ISP_SCALE), int(1080 / ISP_SCALE))
rgbDistortion = calibrationHandler.getDistortionCoefficients(RGB_SOCKET)
distortionModel = calibrationHandler.getDistortionModel(RGB_SOCKET)
if distortionModel != dai.CameraModel.Perspective:
Expand Down Expand Up @@ -143,6 +142,8 @@ def updateDepthPlane(depth):
frameRgbCv = frameRgb.getCvFrame()
fpsCounter.tick()

rgbIntrinsics = calibrationHandler.getCameraIntrinsics(RGB_SOCKET, int(frameRgbCv.shape[1]), int(frameRgbCv.shape[0]))

cvFrameUndistorted = cv2.undistort(
frameRgbCv,
np.array(rgbIntrinsics),
Expand Down
2 changes: 1 addition & 1 deletion examples/ImageAlign/tof_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def getFps(self):
device = dai.Device()

calibrationHandler = device.readCalibration()
rgbIntrinsics = calibrationHandler.getCameraIntrinsics(RGB_SOCKET, int(1920 / ISP_SCALE), int(1080 / ISP_SCALE))
rgbDistortion = calibrationHandler.getDistortionCoefficients(RGB_SOCKET)
distortionModel = calibrationHandler.getDistortionModel(RGB_SOCKET)
if distortionModel != dai.CameraModel.Perspective:
Expand Down Expand Up @@ -150,6 +149,7 @@ def updateBlendWeights(percentRgb):
# Blend when both received
if frameDepth is not None:
cvFrame = frameRgb.getCvFrame()
rgbIntrinsics = calibrationHandler.getCameraIntrinsics(RGB_SOCKET, int(cvFrame.shape[1]), int(cvFrame.shape[0]))
cvFrameUndistorted = cv2.undistort(
cvFrame,
np.array(rgbIntrinsics),
Expand Down

0 comments on commit e33723b

Please sign in to comment.