Skip to content

Commit

Permalink
Improved the chessboard detection
Browse files Browse the repository at this point in the history
commit-id:6662bc18
  • Loading branch information
integraledelebesgue committed Jan 27, 2025
1 parent 972769e commit 5e5bdd7
Show file tree
Hide file tree
Showing 3 changed files with 564 additions and 57 deletions.
2 changes: 1 addition & 1 deletion child_lab_framework/_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def calibrate(
calibration = calibration_procedure.run(
video_input,
video_output,
chessboard.Properties(square_size, *inner_board_corners),
chessboard.BoardProperties(square_size, *inner_board_corners),
skip,
)

Expand Down
13 changes: 8 additions & 5 deletions child_lab_framework/_procedure/calibrate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import typing
from pathlib import Path
from typing import Literal

import cv2
import numpy as np
Expand All @@ -9,15 +10,15 @@
from ..core.video import Format, Input, Reader, Writer
from ..task.camera.detection import chessboard
from ..task.visualization import Configuration, Visualizer
from ..typing.array import FloatArray1, FloatArray2, FloatArray3
from ..typing.array import FloatArray1, FloatArray2


# TODO: Implement procedures as classes with `Iterable` protocol
# to make them both usable with tqdm and exportable as purely programistic library elements
def run(
video_source: Path,
annotated_video_destination: Path,
board_properties: chessboard.Properties,
board_properties: chessboard.BoardProperties,
skip: int,
) -> Calibration:
reader = Reader(
Expand All @@ -40,8 +41,8 @@ def run(

detector = chessboard.Detector(board_properties)

inner_corners_per_row = board_properties.inner_corners_per_row
inner_corners_per_column = board_properties.inner_corners_per_column
inner_corners_per_row = board_properties.inner_columns
inner_corners_per_column = board_properties.inner_rows
square_size = board_properties.square_size

# Prepare object points, like (0,0,0), (1,0,0), (2,0,0). ...,(6,5,0)
Expand All @@ -56,7 +57,9 @@ def run(
)

object_points: list[FloatArray2] = []
image_points: list[FloatArray3] = []
image_points: list[
np.ndarray[tuple[int, Literal[1], Literal[2]], np.dtype[np.float32]]
] = []

for _ in trange(1, video_properties.length, skip, desc='Processing video'):
frame = reader.read_skipping(skip)
Expand Down
Loading

0 comments on commit 5e5bdd7

Please sign in to comment.