Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] #220 calibration #324

Draft
wants to merge 95 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
9fbaca4
Initial push
ErichZimmer May 8, 2023
c422b91
Moved files to main module
ErichZimmer May 8, 2023
5b4d902
Further refinements
ErichZimmer May 8, 2023
08ec59e
Removed nesting
ErichZimmer May 8, 2023
711df0c
Further refinements and bug fixes
ErichZimmer May 8, 2023
eb5e6ae
Add marker detection
ErichZimmer May 23, 2023
9281d81
Revise calibration utils
ErichZimmer Jun 1, 2023
ad02894
Revise polynomial calibration
ErichZimmer Jun 1, 2023
f41dcb6
Revise pinhole calibration
ErichZimmer Jun 1, 2023
b1250f9
Fix example typos
ErichZimmer Jun 1, 2023
8f183e6
Fix example typos
ErichZimmer Jun 1, 2023
7118eb5
Bug fixes
ErichZimmer Jun 1, 2023
5e2af06
Revised pinhole distortion model
ErichZimmer Jun 2, 2023
8322ca2
Minor typo in error
ErichZimmer Jun 2, 2023
a8173d5
Further enhancements
ErichZimmer Jun 2, 2023
fdf0072
Code aesthetics
ErichZimmer Jun 2, 2023
7a938f5
Code readability
ErichZimmer Jun 3, 2023
12df23f
Add error for minimum points
ErichZimmer Jun 3, 2023
274eb63
New marker detector
ErichZimmer Jun 3, 2023
c7de5ac
Typos
ErichZimmer Jun 3, 2023
f98fece
Refined get_markers_local
ErichZimmer Jun 5, 2023
1fa733d
Remove unnecessary parameter
ErichZimmer Jun 5, 2023
cc4d4ee
Added preprocessing routines
ErichZimmer Jun 6, 2023
85f1158
Removed image file to upload push
ErichZimmer Jun 6, 2023
e4e4925
Major Revision
ErichZimmer Jun 16, 2023
4d50209
Add ignored test file
ErichZimmer Jun 16, 2023
bb20268
Fixed unit testing
ErichZimmer Jun 17, 2023
bddb572
Added polynomial distortion correction
ErichZimmer Jul 10, 2023
7182f8e
Unit Testing
ErichZimmer Jul 11, 2023
f48905c
ENH: Unit testing
ErichZimmer Aug 25, 2023
a243637
Revised calibration module and features
ErichZimmer Dec 9, 2023
ae5041d
Removed artifact file
ErichZimmer Dec 9, 2023
a7a5709
Merge branch 'OpenPIV:master' into #220-calibration
ErichZimmer Dec 11, 2023
3056814
Revised corner detection
ErichZimmer Dec 11, 2023
1298dce
Merge branch '#220-calibration' of https://github.com/ErichZimmer/ope…
ErichZimmer Dec 11, 2023
be8ca66
Fixed missing corner orientation
ErichZimmer Dec 11, 2023
92ce4a5
Revised marker detection
ErichZimmer Dec 14, 2023
ef2dd55
Merge branch 'OpenPIV:master' into #220-calibration
ErichZimmer May 26, 2024
07e4d32
Added tests
ErichZimmer May 26, 2024
45fd190
Revised camera models
ErichZimmer May 26, 2024
c02ef43
Revised camera module
ErichZimmer May 26, 2024
bcfa0cd
Wrong DLT algorithm
ErichZimmer May 26, 2024
2a12e3c
Revised camera models
ErichZimmer May 31, 2024
05e6094
Revised tests
ErichZimmer May 31, 2024
3dc8227
Enhanced calibration utilities
ErichZimmer Jun 5, 2024
eaa071b
More testing
ErichZimmer Jun 5, 2024
c3bc29b
Merge branch 'OpenPIV:master' into #220-calibration
ErichZimmer Jun 11, 2024
9c41a93
Revised documentation
ErichZimmer Jun 13, 2024
f1d54c0
Merge branch '#220-calibration' of https://github.com/ErichZimmer/ope…
ErichZimmer Jun 13, 2024
cef1926
More testing
ErichZimmer Jun 13, 2024
257480c
Forced push test files
ErichZimmer Jun 13, 2024
2bbbd94
Added missing image set
ErichZimmer Jun 15, 2024
2226ad8
Fixed epipolar bugs
ErichZimmer Jun 15, 2024
9157cf6
Updated marker detection
ErichZimmer Jun 16, 2024
203efa1
Bug fix
ErichZimmer Jun 17, 2024
583f385
Add Multiple Line Intersection
ErichZimmer Jun 25, 2024
d82ee0c
Add tests for multi line intersects
ErichZimmer Jun 25, 2024
c73a1c5
Update docstring
ErichZimmer Jun 25, 2024
146ca3f
Update docstring again
ErichZimmer Jun 25, 2024
a7f3c9e
Fix tests
ErichZimmer Jun 27, 2024
1ec32ca
Refactor and enhance
ErichZimmer Jun 28, 2024
1e22719
had two issues: one is some text in the __init__.py and some related …
alexlib Jun 29, 2024
09b8a5e
Re-wrote DLT camera model
ErichZimmer Jun 29, 2024
89bf998
Syntax error
ErichZimmer Jun 29, 2024
c29becb
Re-wrote functions
ErichZimmer Jun 29, 2024
3671e97
Updated docstring
ErichZimmer Jun 29, 2024
3e5266a
Bug fixes
ErichZimmer Jun 29, 2024
5e38e94
Fix DLT model
ErichZimmer Jun 29, 2024
f68d79b
Patch DLT unit tests
ErichZimmer Jun 29, 2024
ceaf859
Fix relative import
ErichZimmer Jun 29, 2024
0bbfb4a
Revised tests with MyPTV example data
ErichZimmer Jun 30, 2024
2c19162
Re-wrote pinhole camera model
ErichZimmer Jun 30, 2024
1324ef9
Updated tests
ErichZimmer Jun 30, 2024
5fb7cdf
Added more cameras for testing
ErichZimmer Jun 30, 2024
320ddbe
Removed uneeded import
ErichZimmer Jun 30, 2024
f94a012
Updated poly model
ErichZimmer Jun 30, 2024
aeb8d2c
Updated poly testing
ErichZimmer Jun 30, 2024
9bf6e4e
Revised some stuff
ErichZimmer Jun 30, 2024
e32d628
Fixed some stuff
ErichZimmer Jun 30, 2024
dc4a615
Update docstring
ErichZimmer Jun 30, 2024
e536c96
Update docstring
ErichZimmer Jun 30, 2024
39dcb13
Update conf.py
alexlib Jun 30, 2024
ad036cb
Merge branch '#220-calibration' of https://github.com/ErichZimmer/ope…
alexlib Jun 30, 2024
613d9cc
Bug fix
ErichZimmer Jul 2, 2024
e998a53
Simplified docstring
ErichZimmer Jul 2, 2024
a365979
Add MyPTV distortion algorithm
ErichZimmer Jul 2, 2024
cb463a6
Bug fix
ErichZimmer Jul 2, 2024
934ee1b
fixed the option to run pytest from the root folder
alexlib Jul 11, 2024
7230472
also polynomial test
alexlib Jul 11, 2024
cb43550
Merge branch 'OpenPIV:master' into #220-calibration
ErichZimmer Aug 20, 2024
747f21e
Bug fix point search algo
ErichZimmer Aug 21, 2024
a33010f
More testing
ErichZimmer Aug 21, 2024
36d4049
More testing
ErichZimmer Aug 21, 2024
2429d0a
Oops, wrong file
ErichZimmer Aug 21, 2024
998ba7b
Refined some tests
ErichZimmer Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions dummy
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
dummy
512 512
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0
0.0 0.0 1.0 0.0
float64
60 changes: 60 additions & 0 deletions openpiv/calibration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""
==================
Camera Calibration
==================

This submodule contains functions and routines to calibrate a camera
system.

DLT Model
=========
camera - Create an instance of a DLT camera model
calibrate_dlt - Calibrate and return DLT coefficients and fitting error
line_intersect - Using two lines, locate where those lines intersect
multi_line_intersect - Using multiple lines, approximate their intersection

Pinhole Model
=============
calibrate_intrinsics - Calculate the intrinsic parameters using Zang's algorithm
camera - Create an instance of a Pinhole camera model
calibrate_dlt - Calibrate and return DLT coefficients and fitting error
line_intersect - Using two lines, locate where those lines intersect
multi_line_intersect - Using multiple lines, approximate their intersection

Polynomial Model
================
camera - Create an instance of a Soloff camera model
multi_line_intersect - Using multiple lines, approximate their intersection

Marker Detection (Marker Grid)
==============================
detect_markers_template - Detect markers via template correlation
detect_markers_blobs - Detect markers via labeling blobs
get_circular_template - Generate a circular template
get_cross_template - Generate a cross template
preprocess_image - Preprocess calibration image

Calibration Grid
================
get_asymmetric_grid - Create an asymmetric rectangular calibration grid
get_simple_grid - Create a simple rectangular calibration grid

Match Calibration Points
========================
find_corners - Locate 4 or 6 corners of a calibration grid
find_nearest_points - Find the closest point to a cursor
get_pairs_dlt - Match marker pairs using 4 corners and the DLT algorithm
get_pairs_proj - Match marker pairs using a rough projection estimate
reorder_image_points - Reorder image points in ascending order
show_calibration_image - Plot calibration image and markers

Utils
=====
homogenize - Homogenize array by appending ones to the last axis
get_image_mapping - Calculate the mappings to rectify a 2D image
get_los_error - Calculate the RMS error of a line of sight (LOS) at a z plane
get_reprojection_error - Calculate the root mean square (RMS) error
get_rmse - Calculate the root mean square error of the residuals
plot_epipolar_line - Plot a 3D representation of epipolar lines

"""
69 changes: 69 additions & 0 deletions openpiv/calibration/_cal_doc_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from scipy._lib import doccer


__all__ = ['docfiller']


# typing the same doc string multiple times gets annoying and error prone...
_obj_coords = (
"""object_points : 2D np.ndarray
Real world coordinates stored in a ndarray structured like [X, Y, Z]'.""")

_img_coords = (
"""image_points : 2D np.ndarray
Image coordinates stored in a ndarray structured like [x, y].""")

_cam_struct = (
"""cam_struct : dict
A dictionary structure of camera parameters.""")

_project_points_func = (
"""project_points_func : function
Projection function with the following signature:
res = func(cam_struct, object_points).""")

_project_to_z_func = (
"""project_to_z_func : function
Projection function with the following signiture:
res = func(cam_struct, image_points, Z).""")

_x_lab_coord = (
"""X : 1D np.ndarray
Projected world x-coordinates.""")

_y_lab_coord = (
"""Y : 1D np.ndarray
Projected world y-coordinates.""")

_z_lab_coord = (
"""Z : 1D np.ndarray
Projected world z-coordinates.""")

_x_img_coord = (
"""x : 1D np.ndarray
Projected image x-coordinates.""")

_y_img_coord = (
"""y : 1D np.ndarray
Projected image y-coordinates.""")

_project_z = (
"""z : float
A float specifying the Z (depth) value to project to.""")

docdict = {
"object_points": _obj_coords,
"image_points": _img_coords,
"cam_struct": _cam_struct,
"project_points_func": _project_points_func,
"project_to_z_func": _project_to_z_func,
"x_lab_coord": _x_lab_coord,
"y_lab_coord": _y_lab_coord,
"z_lab_coord": _z_lab_coord,
"x_img_coord": _x_img_coord,
"y_img_coord": _y_img_coord,
"project_z": _project_z
}

# SciPy's nifty decorator (works better than my simple implementation)
docfiller = doccer.filldoc(docdict)
Loading