arcjetCV 1.1.0.dev2__tar.gz → 1.1.0.dev4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. arcjetcv-1.1.0.dev4/MANIFEST.in +1 -0
  2. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/PKG-INFO +18 -8
  3. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/README.md +3 -3
  4. arcjetcv-1.1.0.dev4/README_pypi.md +135 -0
  5. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/calibration/calibration_controller.py +89 -85
  6. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/calibration/calibration_view.py +10 -8
  7. arcjetcv-1.1.0.dev4/arcjetCV/calibration/test.py +57 -0
  8. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/gui/main_window.py +5 -4
  9. {arcjetcv-1.1.0.dev2/arcjetCV.egg-info → arcjetcv-1.1.0.dev4/arcjetcv.egg-info}/PKG-INFO +18 -8
  10. {arcjetcv-1.1.0.dev2/arcjetCV.egg-info → arcjetcv-1.1.0.dev4/arcjetcv.egg-info}/SOURCES.txt +9 -6
  11. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/setup.py +2 -2
  12. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/tests/test_gui.py +12 -12
  13. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/LICENSE +0 -0
  14. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/__init__.py +0 -0
  15. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/calibration/__init__.py +0 -0
  16. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/calibration/calibrate_video.py +0 -0
  17. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/calibration/calibration_main.py +0 -0
  18. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/calibration/calibration_model.py +0 -0
  19. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/calibration/chessboard_pattern.png +0 -0
  20. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/calibration/detetct_example.py +0 -0
  21. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/calibration/rotated_pattern.png +0 -0
  22. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/chessboard_pattern.png +0 -0
  23. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/gui/__init__.py +0 -0
  24. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/gui/_arcjetCV_gui.py +0 -0
  25. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/gui/arcjetCV_gui.py +0 -0
  26. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/gui/custom_classes.py +0 -0
  27. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/gui/logo/arcjetCV_logo.icns +0 -0
  28. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/gui/logo/arcjetCV_logo.ico +0 -0
  29. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/gui/logo/arcjetCV_logo_.png +0 -0
  30. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/gui/logo/arcjetCV_logo_white.png +0 -0
  31. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/gui/main.py +0 -0
  32. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/segmentation/__init__.py +0 -0
  33. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/segmentation/contour/__init__.py +0 -0
  34. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/segmentation/contour/cnn.py +0 -0
  35. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/segmentation/contour/contour.py +0 -0
  36. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/segmentation/time/__init__.py +0 -0
  37. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/segmentation/time/time_segmentation.py +0 -0
  38. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/utils/__init__.py +0 -0
  39. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/utils/logger.py +0 -0
  40. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/utils/output.py +0 -0
  41. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/utils/processor.py +0 -0
  42. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/utils/utils.py +0 -0
  43. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/arcjetCV/utils/video.py +0 -0
  44. {arcjetcv-1.1.0.dev2/arcjetCV.egg-info → arcjetcv-1.1.0.dev4/arcjetcv.egg-info}/dependency_links.txt +0 -0
  45. {arcjetcv-1.1.0.dev2/arcjetCV.egg-info → arcjetcv-1.1.0.dev4/arcjetcv.egg-info}/entry_points.txt +0 -0
  46. {arcjetcv-1.1.0.dev2/arcjetCV.egg-info → arcjetcv-1.1.0.dev4/arcjetcv.egg-info}/requires.txt +0 -0
  47. {arcjetcv-1.1.0.dev2/arcjetCV.egg-info → arcjetcv-1.1.0.dev4/arcjetcv.egg-info}/top_level.txt +0 -0
  48. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/setup.cfg +0 -0
  49. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/tests/README.md +0 -0
  50. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/tests/__init__.py +0 -0
  51. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/tests/test_calibration_functions.py +0 -0
  52. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/tests/test_calibration_gui.py +0 -0
  53. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/tests/test_functions.py +0 -0
  54. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/tests/test_obj_models.py +0 -0
  55. {arcjetcv-1.1.0.dev2 → arcjetcv-1.1.0.dev4}/tests/test_segmentation.py +0 -0
@@ -0,0 +1 @@
1
+ include README_pypi.md
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
2
- Name: arcjetCV
3
- Version: 1.1.0.dev2
1
+ Metadata-Version: 2.4
2
+ Name: arcjetcv
3
+ Version: 1.1.0.dev4
4
4
  Summary: Package to process arcjet videos and segment the edge of the shock and of the sample
5
5
  Home-page: https://github.com/magnus-haw/arcjetCV
6
6
  Author: arcjetCV team
@@ -26,11 +26,23 @@ Requires-Dist: scikit-learn
26
26
  Requires-Dist: segmentation-models-pytorch
27
27
  Requires-Dist: torch
28
28
  Requires-Dist: torchvision
29
-
30
- [![Documentation Status](https://readthedocs.org/projects/arcjetcv/badge/?version=latest)](https://arcjetcv.readthedocs.io/en/latest/?badge=latest)
31
- [![Anaconda-Server Badge](https://anaconda.org/conda-forge/arcjetcv/badges/version.svg)](https://anaconda.org/conda-forge/arcjetcv)
29
+ Dynamic: author
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: description-content-type
33
+ Dynamic: home-page
34
+ Dynamic: license-file
35
+ Dynamic: platform
36
+ Dynamic: project-url
37
+ Dynamic: requires-dist
38
+ Dynamic: summary
39
+
40
+ [![GitHub Docs](https://img.shields.io/badge/docs-GitHub%20Pages-blue)](https://magnus-haw.github.io/arcjetCV/)
41
+ [![PyPI version](https://badge.fury.io/py/arcjetcv.svg)](https://pypi.org/project/arcjetcv/)
42
+ [![Downloads](https://pepy.tech/badge/arcjetcv)](https://pepy.tech/project/arcjetcv)
32
43
  [![tutorial](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/magnus-haw/arcjetCV/blob/main/tutorial.ipynb)
33
44
 
45
+
34
46
  -----
35
47
 
36
48
  <div align="center">
@@ -42,8 +54,6 @@ Requires-Dist: torchvision
42
54
 
43
55
  Package to process arcjet videos and segment the edge of the shock and of the sample.
44
56
 
45
- ![arcjetCV Functionality](https://i.imgur.com/YOUR_IMAGE_ID.gif)
46
-
47
57
  ## Installation
48
58
 
49
59
  ### PyPi Installation (Universal)
@@ -1,7 +1,7 @@
1
- [![Documentation Status](https://readthedocs.org/projects/arcjetcv/badge/?version=latest)](https://arcjetcv.readthedocs.io/en/latest/?badge=latest)
2
- [![Anaconda-Server Badge](https://anaconda.org/conda-forge/arcjetcv/badges/version.svg)](https://anaconda.org/conda-forge/arcjetcv)
1
+ [![GitHub Docs](https://img.shields.io/badge/docs-GitHub%20Pages-blue)](https://magnus-haw.github.io/arcjetCV/)
2
+ [![PyPI version](https://badge.fury.io/py/arcjetcv.svg)](https://pypi.org/project/arcjetcv/)
3
3
  [![tutorial](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/magnus-haw/arcjetCV/blob/main/tutorial.ipynb)
4
-
4
+ [![Downloads](https://pepy.tech/badge/arcjetcv)](https://pepy.tech/project/arcjetcv)
5
5
  -----
6
6
 
7
7
  <div align="center">
@@ -0,0 +1,135 @@
1
+ [![GitHub Docs](https://img.shields.io/badge/docs-GitHub%20Pages-blue)](https://magnus-haw.github.io/arcjetCV/)
2
+ [![PyPI version](https://badge.fury.io/py/arcjetcv.svg)](https://pypi.org/project/arcjetcv/)
3
+ [![Downloads](https://pepy.tech/badge/arcjetcv)](https://pepy.tech/project/arcjetcv)
4
+ [![tutorial](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/magnus-haw/arcjetCV/blob/main/tutorial.ipynb)
5
+
6
+
7
+ -----
8
+
9
+ <div align="center">
10
+ <img src="https://raw.githubusercontent.com/magnus-haw/arcjetCV/main/arcjetCV/gui/logo/arcjetCV_logo_.png" alt="arcjetCV Logo" width="30%">
11
+
12
+ </div>
13
+
14
+ # arcjetCV
15
+
16
+ Package to process arcjet videos and segment the edge of the shock and of the sample.
17
+
18
+ ## Installation
19
+
20
+ ### PyPi Installation (Universal)
21
+
22
+ #### Prerequisites:
23
+ - Ensure you have **Python 3.8** or higher installed.
24
+
25
+ To install **arcjetCV** via **pip** from **PyPi**, run:
26
+
27
+ ```bash
28
+ pip install arcjetCV
29
+ ```
30
+
31
+ This will install **arcjetCV** along with its dependencies.
32
+
33
+ #### Note for macOS Users:
34
+ You might need to install Xcode Command Line Tools:
35
+
36
+ ```bash
37
+ xcode-select --install
38
+ ```
39
+
40
+ #### Note for Linux Users:
41
+
42
+ You may need to install **libxcb-cursor**. Use your package manager to install it:
43
+
44
+ For **Ubuntu/Debian**-based distributions:
45
+ ```bash
46
+ sudo apt-get install libxcb-cursor0
47
+ ```
48
+
49
+ For **Fedora**:
50
+ ```bash
51
+ sudo dnf install libxcb-cursor
52
+ ```
53
+
54
+ For **Arch Linux**:
55
+ ```bash
56
+ sudo pacman -S libxcb
57
+ ```
58
+
59
+ ### Developer Installation
60
+
61
+ #### Prerequisites:
62
+ - A valid **git** installation.
63
+ - **Miniconda** or **Anaconda** for environment and package management:
64
+ - [Miniconda](https://docs.anaconda.com/free/miniconda/miniconda-install/)
65
+ - [Anaconda](https://docs.anaconda.com/free/anaconda/install/index.html)
66
+ - For **macOS** users make sure the Xcode Command Line Tools are installed:
67
+ ```bash
68
+ xcode-select --install
69
+ ```
70
+
71
+ To install **arcjetCV** for development puropse, follow these steps:
72
+
73
+ 1. Install `git-lfs`:
74
+
75
+ Download and install it from [here](https://git-lfs.github.com/).
76
+
77
+ 2. Clone the repository and install the package:
78
+
79
+ ```bash
80
+ git clone https://github.com/magnus-haw/arcjetCV.git
81
+ cd arcjetCV
82
+ conda env create -f env/arcjetCV_env_[cpu/gpu].yml
83
+ conda activate arcjetcv
84
+ python -m pip install -e .
85
+ ```
86
+
87
+ The `-e` flag stands for 'editable' and means that any changes to the local source code will immediately affect the **arcjetCV** package and GUI.
88
+
89
+
90
+ ## How to Run
91
+
92
+ You can now launch the GUI by running:
93
+
94
+ ```bash
95
+ conda activate arcjetcv # (if using conda)
96
+ arcjetCV
97
+ ```
98
+
99
+ Alternatively, you can use **arcjetCV's Python API** inside a Python script, e.g., `test.py`:
100
+
101
+ ```python
102
+ import arcjetCV as arcv
103
+ video = arcv.Video("tests/arcjet_test.mp4")
104
+ ```
105
+
106
+ Run the script with:
107
+
108
+ ```bash
109
+ conda activate arcjetcv # (if using conda)
110
+ python test.py
111
+ ```
112
+
113
+
114
+
115
+ ## Citing
116
+
117
+ If you use arcjetCV in your research, please use the following BibTeX entry to cite [our paper](https://arxiv.org/abs/2404.11492):
118
+
119
+ ```BibTeX
120
+ @article{arcjetCV,
121
+ title={arcjetCV: an open-source software to analyze material ablation},
122
+ author={Quintart, Alexandre and Haw, Magnus and Semeraro, Federico},
123
+ journal={arXiv preprint arXiv:2404.11492},
124
+ year={2024}
125
+ }
126
+ ```
127
+
128
+ ## Legal / License
129
+ Copyright © 2024 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. All Rights Reserved.
130
+
131
+ Disclaimers
132
+
133
+ No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER, CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE. FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT "AS IS."
134
+
135
+ Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES, EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT.
@@ -48,79 +48,31 @@ class CalibrationController:
48
48
  else:
49
49
  self.view.image_label.setText("No images loaded")
50
50
 
51
- def detect_pattern(self, img, pattern_size):
51
+ def _generate_object_points(self, pattern_size, pattern_type, spacing=1.0):
52
52
  """
53
- Detect whether the image contains a chessboard or a circles grid.
54
-
55
- Args:
56
- img (numpy.ndarray): The grayscale image to analyze.
57
- pattern_size (tuple): Chessboard pattern size (columns, rows).
58
- pattern_size (tuple): Circles grid pattern size (columns, rows).
59
-
60
- Returns:
61
- tuple: (str, object_points, image_points)
62
- str: "chessboard", "circles_grid", or None.
63
- object_points: 3D points in real-world space.
64
- image_points: 2D points in the image plane.
65
- """
66
- # Prepare 3D object points for chessboard and circles grid
67
- chessboard_obj_points = np.zeros(
68
- (pattern_size[0] * pattern_size[1], 3), np.float32
69
- )
70
- chessboard_obj_points[:, :2] = np.mgrid[
71
- 0 : pattern_size[0], 0 : pattern_size[1]
72
- ].T.reshape(-1, 2)
73
-
74
- circles_obj_points = np.zeros(
75
- (pattern_size[0] * pattern_size[1], 3), np.float32
76
- )
77
- circles_obj_points[:, :2] = np.mgrid[
78
- 0 : pattern_size[0], 0 : pattern_size[1]
79
- ].T.reshape(-1, 2)
80
-
81
- # Try detecting chessboard pattern
82
- ret_chessboard, corners_chessboard = cv2.findChessboardCorners(
83
- img, pattern_size
84
- )
85
- if ret_chessboard:
86
- return "chessboard", chessboard_obj_points, corners_chessboard
87
-
88
- # Try detecting circles grid pattern
89
- ret_circles_grid, centers_circles_grid = cv2.findCirclesGrid(
90
- img, pattern_size, flags=cv2.CALIB_CB_SYMMETRIC_GRID
91
- )
92
- if ret_circles_grid:
93
- return "circles_grid", circles_obj_points, centers_circles_grid
94
-
95
- # No pattern detected
96
- return None, None, None
97
-
98
- def _generate_object_points(self, pattern_size, pattern_type):
99
- """
100
- Generates 3D object points for a given pattern.
53
+ Generates 3D object points for a given pattern with real-world spacing.
101
54
 
102
55
  Args:
103
56
  pattern_size (tuple): The pattern size (columns, rows).
104
- pattern_type (str): Type of pattern ("chessboard", "circles_grid", "asymmetric_circles_grid").
57
+ pattern_type (str): Type of pattern.
58
+ spacing (float): Real-world spacing between points in meters (default: 1.0)
105
59
 
106
60
  Returns:
107
61
  numpy.ndarray: 3D object points.
108
62
  """
109
- obj_points = np.zeros((pattern_size[0] * pattern_size[1], 3), np.float32)
110
-
111
- if pattern_type == "chessboard" or pattern_type == "circles_grid":
112
- obj_points[:, :2] = np.mgrid[
113
- 0 : pattern_size[0], 0 : pattern_size[1]
114
- ].T.reshape(-1, 2)
115
-
63
+ cols, rows = pattern_size
64
+ if pattern_type in ["chessboard", "circles_grid"]:
65
+ obj_points = np.zeros((rows * cols, 3), np.float32)
66
+ obj_points[:, :2] = np.mgrid[0:cols, 0:rows].T.reshape(-1, 2)
67
+ obj_points *= spacing
116
68
  elif pattern_type == "asymmetric_circles_grid":
117
- obj_points[:, :2] = np.array(
118
- [
119
- [(x, y + 0.5 * (x % 2)) for x in range(pattern_size[0])]
120
- for y in range(pattern_size[1])
121
- ]
122
- ).reshape(-1, 2)
123
-
69
+ obj_points = []
70
+ for i in range(rows):
71
+ for j in range(cols):
72
+ x = (2 * j + i % 2) * spacing / 2.0
73
+ y = i * spacing
74
+ obj_points.append([x, y, 0])
75
+ obj_points = np.array(obj_points, dtype=np.float32).reshape(-1, 1, 3)
124
76
  return obj_points
125
77
 
126
78
  def detect_pattern(self, img, pattern_size):
@@ -179,8 +131,6 @@ class CalibrationController:
179
131
 
180
132
  # 4️⃣ Custom asymmetric pattern detection - Second Attempt
181
133
  return self.found_asym_pattern_2(img, pattern_size, 500, 3000)
182
- # ❌ No pattern detected
183
- # return None, None, None
184
134
 
185
135
  def asym_obj_points(self, rows, cols):
186
136
  circles_obj_points = np.zeros((rows * cols, 3), np.float32)
@@ -343,7 +293,7 @@ class CalibrationController:
343
293
 
344
294
  return rotation_matrix, tvec, (theta_x, theta_y, theta_z)
345
295
 
346
- def calculate_2d_affine_matrix(self, obj_points, img_points):
296
+ def calculate_2d_affine_matrix(self, img, obj_points, img_points):
347
297
  """
348
298
  Computes an affine transformation matrix for 2D correction.
349
299
 
@@ -352,18 +302,50 @@ class CalibrationController:
352
302
  img_points (numpy.ndarray): 2D detected points in the image.
353
303
 
354
304
  Returns:
355
- numpy.ndarray: 2D affine transformation matrix (if successful).
305
+ numpy.ndarray: 2D affine transformation matrix (if successful), else None.
356
306
  """
357
- if len(obj_points) < 3 or len(img_points) < 3:
307
+ obj_points = np.asarray(obj_points, dtype=np.float32).reshape(-1, 2)
308
+ img_points = np.asarray(img_points, dtype=np.float32).reshape(-1, 2)
309
+ obj_points = np.asarray(obj_points, dtype=np.float32).reshape(-1, 2).copy()
310
+ img_points = np.asarray(img_points, dtype=np.float32).reshape(-1, 2).copy()
311
+
312
+ if obj_points.shape != img_points.shape:
313
+ print(
314
+ f"❌ Mismatch in point shapes: obj={obj_points.shape}, img={img_points.shape}"
315
+ )
316
+ return None
317
+
318
+ if len(obj_points) < 3:
358
319
  print("❌ ERROR: At least 3 points are required for affine transformation.")
359
320
  return None
360
321
 
361
- # Compute affine transformation
362
- affine_matrix, _ = cv2.estimateAffinePartial2D(obj_points, img_points)
322
+ # Check for duplicate points
323
+ unique_obj = len(np.unique(obj_points, axis=0))
324
+ unique_img = len(np.unique(img_points, axis=0))
325
+ print(
326
+ f"🔎 Unique object points: {unique_obj}, Unique image points: {unique_img}"
327
+ )
363
328
 
364
- if affine_matrix is None:
365
- print("❌ ERROR: Affine transformation failed.")
366
- return affine_matrix
329
+ try:
330
+ affine_matrix, _ = cv2.estimateAffinePartial2D(obj_points, img_points)
331
+ if affine_matrix is None:
332
+ raise ValueError("estimateAffinePartial2D returned None")
333
+ print("✅ Affine matrix (partial) computed successfully.")
334
+ return affine_matrix
335
+ except Exception as e:
336
+ print(f"⚠️ Partial affine estimation failed: {e}")
337
+ print("🔁 Trying full affine estimation...")
338
+
339
+ try:
340
+ affine_matrix, _ = cv2.estimateAffine2D(obj_points, img_points)
341
+ if affine_matrix is None:
342
+ print("❌ Full affine estimation also failed.")
343
+ return None
344
+ print("✅ Affine matrix (full) computed as fallback.")
345
+ return affine_matrix
346
+ except Exception as ee:
347
+ print(f"❌ Full affine estimation crashed: {ee}")
348
+ return None
367
349
 
368
350
  def calibrate_camera(self):
369
351
  """Perform full 3D camera calibration and save results."""
@@ -374,9 +356,11 @@ class CalibrationController:
374
356
  return
375
357
 
376
358
  pattern_size = (
377
- self.view.grid_cols_input.value(),
378
- self.view.grid_rows_input.value(),
359
+ self.view.grid_cols_input_1.value(),
360
+ self.view.grid_rows_input_1.value(),
379
361
  )
362
+ spacing = 1.0 # Use unit spacing; real-world scaling comes later
363
+
380
364
  obj_points = []
381
365
  img_points = []
382
366
 
@@ -389,10 +373,12 @@ class CalibrationController:
389
373
  return
390
374
 
391
375
  # Detect pattern
392
- pattern_type, obj_p, img_p = self.detect_pattern(
393
- img, pattern_size, pattern_size
394
- )
376
+ pattern_type, _, img_p = self.detect_pattern(img, pattern_size)
377
+ print(pattern_type)
395
378
  if pattern_type:
379
+ obj_p = self._generate_object_points(
380
+ pattern_size, pattern_type, spacing
381
+ )
396
382
  obj_points.append(obj_p)
397
383
  img_points.append(img_p)
398
384
  else:
@@ -405,6 +391,7 @@ class CalibrationController:
405
391
  ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(
406
392
  obj_points, img_points, img.shape[::-1], None, None
407
393
  )
394
+ print(f"Calibration RMS error: {ret:.4f}")
408
395
  if not ret:
409
396
  QMessageBox.warning(self.view, "Error", "Camera calibration failed.")
410
397
  return
@@ -414,10 +401,19 @@ class CalibrationController:
414
401
  obj_points[0], img_points[0], mtx, dist
415
402
  )
416
403
 
417
- # Calculate 2D affine transformation
418
- affine_matrix = self.calculate_2d_affine_matrix(
419
- obj_points[0][:, :2], img_points[0][:, 0, :]
420
- ) # Convert 3D to 2D points
404
+ obj_pts_2d = obj_points[0][:, :2] # shape (N, 2)
405
+ img_pts_2d = img_points[0].reshape(-1, 2) # shape (N, 2)
406
+
407
+ if obj_pts_2d.shape == img_pts_2d.shape and len(obj_pts_2d) >= 3:
408
+ affine_matrix = self.calculate_2d_affine_matrix(img, obj_pts_2d, img_pts_2d)
409
+ else:
410
+ print(
411
+ f"⚠️ Skipping affine matrix — point mismatch or too few points: obj={obj_pts_2d.shape}, img={img_pts_2d.shape}"
412
+ )
413
+ affine_matrix = None
414
+
415
+ # Get ppm from stored value if available
416
+ ppm_value = getattr(self, "ppm", None)
421
417
 
422
418
  # Store calibration data
423
419
  calibration_data = {
@@ -428,6 +424,7 @@ class CalibrationController:
428
424
  "affine_matrix": (
429
425
  affine_matrix.tolist() if affine_matrix is not None else None
430
426
  ),
427
+ "pixels_per_mm": ppm_value if ppm_value else None,
431
428
  }
432
429
 
433
430
  # Save calibration data to file
@@ -455,6 +452,7 @@ class CalibrationController:
455
452
  if calibration_data["affine_matrix"]
456
453
  else None
457
454
  ),
455
+ "pixels_per_mm": ppm_value if ppm_value else None,
458
456
  }
459
457
  self.calibrated = True
460
458
  QMessageBox.information(
@@ -793,7 +791,7 @@ class CalibrationController:
793
791
  except Exception as e:
794
792
  QMessageBox.critical(self, "Error", f"Failed to save calibration: {e}")
795
793
 
796
- def apply_calibration(frame, calibration_data):
794
+ def apply_calibration(self, frame, calibration_data):
797
795
  """
798
796
  Apply calibration to a single frame using provided calibration data.
799
797
 
@@ -819,11 +817,17 @@ class CalibrationController:
819
817
  undistorted_frame = cv2.undistort(
820
818
  frame, camera_matrix, dist_coeffs, None, new_camera_matrix
821
819
  )
822
-
820
+ print("Undistorted frame shape:")
823
821
  # Check if affine transformation is available
824
822
  if "affine_matrix" in calibration_data:
825
823
  affine_matrix = np.array(calibration_data["affine_matrix"])
826
824
 
825
+ if affine_matrix.ndim != 2 or affine_matrix.shape != (2, 3):
826
+ print(
827
+ f"⚠️ Skipping affine transform due to invalid shape: {affine_matrix.shape}"
828
+ )
829
+ return undistorted_frame
830
+
827
831
  # Extract rotation angle from affine transformation
828
832
  angle_rad = np.arctan2(affine_matrix[1, 0], affine_matrix[0, 0])
829
833
  angle_deg = np.degrees(angle_rad) # Convert to degrees
@@ -76,15 +76,16 @@ class CalibrationView(QWidget):
76
76
 
77
77
  # Add elements to the grid size layout
78
78
  grid_size_layout_1.addLayout(label_layout_1)
79
- grid_size_layout_1.addWidget(
80
- QLabel("Rows:"), alignment=Qt.AlignmentFlag.AlignRight
81
- )
82
- grid_size_layout_1.addWidget(self.grid_rows_input_1, stretch=1)
83
79
  grid_size_layout_1.addWidget(
84
80
  QLabel("Cols:"), alignment=Qt.AlignmentFlag.AlignRight
85
81
  )
86
82
  grid_size_layout_1.addWidget(self.grid_cols_input_1, stretch=1)
87
83
 
84
+ grid_size_layout_1.addWidget(
85
+ QLabel("Rows:"), alignment=Qt.AlignmentFlag.AlignRight
86
+ )
87
+ grid_size_layout_1.addWidget(self.grid_rows_input_1, stretch=1)
88
+
88
89
  self.load_button = QPushButton("Load Calibration Images")
89
90
  self.calibrate_button = QPushButton("Calibrate Camera")
90
91
  self.image_label = QLabel("No images loaded")
@@ -147,15 +148,16 @@ class CalibrationView(QWidget):
147
148
 
148
149
  # Add elements to the grid size layout
149
150
  grid_size_layout.addLayout(label_layout)
150
- grid_size_layout.addWidget(
151
- QLabel("Rows:"), alignment=Qt.AlignmentFlag.AlignRight
152
- )
153
- grid_size_layout.addWidget(self.grid_rows_input, stretch=1)
154
151
  grid_size_layout.addWidget(
155
152
  QLabel("Cols:"), alignment=Qt.AlignmentFlag.AlignRight
156
153
  )
157
154
  grid_size_layout.addWidget(self.grid_cols_input, stretch=1)
158
155
 
156
+ grid_size_layout.addWidget(
157
+ QLabel("Rows:"), alignment=Qt.AlignmentFlag.AlignRight
158
+ )
159
+ grid_size_layout.addWidget(self.grid_rows_input, stretch=1)
160
+
159
161
  pattern_resolution_layout.addLayout(grid_size_layout)
160
162
 
161
163
  # 2. Load Image for Resolution Measurement
@@ -0,0 +1,57 @@
1
+ import cv2
2
+ import numpy as np
3
+ import matplotlib.pyplot as plt
4
+
5
+ # Load image
6
+ img = cv2.imread("arcjetcv_calibration_2.jpg")
7
+ gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
8
+
9
+ # Chessboard pattern size (columns, rows) of inner corners
10
+ pattern_size = (9, 6)
11
+
12
+ # Find corners
13
+ ret, corners = cv2.findChessboardCorners(
14
+ gray,
15
+ pattern_size,
16
+ flags=cv2.CALIB_CB_ADAPTIVE_THRESH + cv2.CALIB_CB_NORMALIZE_IMAGE,
17
+ )
18
+
19
+ if not ret:
20
+ print("❌ Chessboard pattern not found.")
21
+ exit()
22
+
23
+ # Refine corners
24
+ criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
25
+ corners = cv2.cornerSubPix(gray, corners, (11, 11), (-1, -1), criteria)
26
+
27
+ # Prepare object points (real-world coords)
28
+ objp = np.zeros((pattern_size[0] * pattern_size[1], 3), np.float32)
29
+ objp[:, :2] = np.mgrid[0 : pattern_size[0], 0 : pattern_size[1]].T.reshape(-1, 2)
30
+
31
+ # Calibrate
32
+ ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(
33
+ [objp], [corners], gray.shape, None, None
34
+ )
35
+
36
+ # Show calibration metrics
37
+ print("\n=== 📐 Calibration Results ===")
38
+ print("Focal Length (fx, fy):", mtx[0, 0], mtx[1, 1])
39
+ print("Principal Point (cx, cy):", mtx[0, 2], mtx[1, 2])
40
+ print("Distortion Coefficients:", dist.ravel().tolist())
41
+
42
+ # Undistort
43
+ undistorted = cv2.undistort(img, mtx, dist)
44
+
45
+ # Show result
46
+ plt.figure(figsize=(14, 6))
47
+ plt.subplot(1, 2, 1)
48
+ plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
49
+ plt.title("Original")
50
+ plt.axis("off")
51
+
52
+ plt.subplot(1, 2, 2)
53
+ plt.imshow(cv2.cvtColor(undistorted, cv2.COLOR_BGR2RGB))
54
+ plt.title("Undistorted")
55
+ plt.axis("off")
56
+ plt.tight_layout()
57
+ plt.show()
@@ -22,6 +22,8 @@ from arcjetCV.utils.utils import (
22
22
  annotate_image_with_frame_number,
23
23
  )
24
24
  from arcjetCV.calibration.calibration_controller import CalibrationController
25
+ from PySide6.QtWidgets import QFileDialog
26
+ import json
25
27
 
26
28
 
27
29
  class MainWindow(QtWidgets.QMainWindow):
@@ -150,10 +152,12 @@ class MainWindow(QtWidgets.QMainWindow):
150
152
  event.accept()
151
153
 
152
154
  def show_img(self):
155
+ print("OK")
153
156
  if self.calibrated == True:
154
157
  self.rgb_frame = CalibrationController.apply_calibration(
155
158
  self.rgb_frame, self.calibration_data
156
159
  )
160
+ print("Calibrated")
157
161
  if self._plot_ref is None:
158
162
  # Create a new plot reference and define the cursor data format
159
163
  self._plot_ref = self.ui.Window0.canvas.axes.imshow(
@@ -478,9 +482,6 @@ class MainWindow(QtWidgets.QMainWindow):
478
482
 
479
483
  def load_calibration(self):
480
484
  """Method to load a .json calibration file and prepare calibration data."""
481
- from PySide6.QtWidgets import QFileDialog
482
- import json
483
- import numpy as np # Ensure numpy is imported
484
485
 
485
486
  # Open a file dialog to select a JSON file
486
487
  file_path, _ = QFileDialog.getOpenFileName(
@@ -531,7 +532,7 @@ class MainWindow(QtWidgets.QMainWindow):
531
532
 
532
533
  shortpath = self.shorten_path(file_path, 60)
533
534
  self.ui.label_calibrationPath.setText(f"Calibration Path: {shortpath}")
534
-
535
+ self.calibrated = True
535
536
  except KeyError as e:
536
537
  self.arcjetcv_message_box(
537
538
  "Error", f"Missing required calibration key: {str(e)}"
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
2
- Name: arcjetCV
3
- Version: 1.1.0.dev2
1
+ Metadata-Version: 2.4
2
+ Name: arcjetcv
3
+ Version: 1.1.0.dev4
4
4
  Summary: Package to process arcjet videos and segment the edge of the shock and of the sample
5
5
  Home-page: https://github.com/magnus-haw/arcjetCV
6
6
  Author: arcjetCV team
@@ -26,11 +26,23 @@ Requires-Dist: scikit-learn
26
26
  Requires-Dist: segmentation-models-pytorch
27
27
  Requires-Dist: torch
28
28
  Requires-Dist: torchvision
29
-
30
- [![Documentation Status](https://readthedocs.org/projects/arcjetcv/badge/?version=latest)](https://arcjetcv.readthedocs.io/en/latest/?badge=latest)
31
- [![Anaconda-Server Badge](https://anaconda.org/conda-forge/arcjetcv/badges/version.svg)](https://anaconda.org/conda-forge/arcjetcv)
29
+ Dynamic: author
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: description-content-type
33
+ Dynamic: home-page
34
+ Dynamic: license-file
35
+ Dynamic: platform
36
+ Dynamic: project-url
37
+ Dynamic: requires-dist
38
+ Dynamic: summary
39
+
40
+ [![GitHub Docs](https://img.shields.io/badge/docs-GitHub%20Pages-blue)](https://magnus-haw.github.io/arcjetCV/)
41
+ [![PyPI version](https://badge.fury.io/py/arcjetcv.svg)](https://pypi.org/project/arcjetcv/)
42
+ [![Downloads](https://pepy.tech/badge/arcjetcv)](https://pepy.tech/project/arcjetcv)
32
43
  [![tutorial](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/magnus-haw/arcjetCV/blob/main/tutorial.ipynb)
33
44
 
45
+
34
46
  -----
35
47
 
36
48
  <div align="center">
@@ -42,8 +54,6 @@ Requires-Dist: torchvision
42
54
 
43
55
  Package to process arcjet videos and segment the edge of the shock and of the sample.
44
56
 
45
- ![arcjetCV Functionality](https://i.imgur.com/YOUR_IMAGE_ID.gif)
46
-
47
57
  ## Installation
48
58
 
49
59
  ### PyPi Installation (Universal)
@@ -1,14 +1,10 @@
1
1
  LICENSE
2
+ MANIFEST.in
2
3
  README.md
4
+ README_pypi.md
3
5
  setup.py
4
6
  arcjetCV/__init__.py
5
7
  arcjetCV/chessboard_pattern.png
6
- arcjetCV.egg-info/PKG-INFO
7
- arcjetCV.egg-info/SOURCES.txt
8
- arcjetCV.egg-info/dependency_links.txt
9
- arcjetCV.egg-info/entry_points.txt
10
- arcjetCV.egg-info/requires.txt
11
- arcjetCV.egg-info/top_level.txt
12
8
  arcjetCV/calibration/__init__.py
13
9
  arcjetCV/calibration/calibrate_video.py
14
10
  arcjetCV/calibration/calibration_controller.py
@@ -18,6 +14,7 @@ arcjetCV/calibration/calibration_view.py
18
14
  arcjetCV/calibration/chessboard_pattern.png
19
15
  arcjetCV/calibration/detetct_example.py
20
16
  arcjetCV/calibration/rotated_pattern.png
17
+ arcjetCV/calibration/test.py
21
18
  arcjetCV/gui/__init__.py
22
19
  arcjetCV/gui/_arcjetCV_gui.py
23
20
  arcjetCV/gui/arcjetCV_gui.py
@@ -40,6 +37,12 @@ arcjetCV/utils/output.py
40
37
  arcjetCV/utils/processor.py
41
38
  arcjetCV/utils/utils.py
42
39
  arcjetCV/utils/video.py
40
+ arcjetcv.egg-info/PKG-INFO
41
+ arcjetcv.egg-info/SOURCES.txt
42
+ arcjetcv.egg-info/dependency_links.txt
43
+ arcjetcv.egg-info/entry_points.txt
44
+ arcjetcv.egg-info/requires.txt
45
+ arcjetcv.egg-info/top_level.txt
43
46
  tests/README.md
44
47
  tests/__init__.py
45
48
  tests/test_calibration_functions.py
@@ -65,8 +65,8 @@ check_linux_dependencies()
65
65
 
66
66
  # Define the setup configuration
67
67
  setup(
68
- name="arcjetCV",
69
- version="1.1.0.dev2", # Set the version directly here
68
+ name="arcjetcv",
69
+ version="1.1.0.dev4", # Set the version directly here
70
70
  author="arcjetCV team",
71
71
  description="Package to process arcjet videos and segment the edge of the shock and of the sample",
72
72
  long_description=long_description,
@@ -251,17 +251,17 @@ def test_apply_shock_filter(app, qtbot, mocker):
251
251
  assert app.processor.HSVShockRange == [(70, 90, 110), (80, 100, 120)]
252
252
 
253
253
 
254
- def test_set_frame_range(app, qtbot, mocker):
255
- """
256
- Test setting the frame range for processing.
257
- """
258
- test_load_video(app, qtbot, mocker)
259
- app.ui.spinBox_FirstGoodFrame.setValue(150)
260
- app.ui.spinBox_LastGoodFrame.setValue(400)
261
- # app.process_all()
262
- assert app.videometa["FIRST_GOOD_FRAME"] == 150
263
- assert app.videometa["LAST_GOOD_FRAME"] == 400
264
- # ✅ Ensure all threads are stopped properly after test
254
+ # def test_set_frame_range(app, qtbot, mocker):
255
+ # """
256
+ # Test setting the frame range for processing.
257
+ # """
258
+ # test_load_video(app, qtbot, mocker)
259
+ # app.ui.spinBox_FirstGoodFrame.setValue(150)
260
+ # app.ui.spinBox_LastGoodFrame.setValue(400)
261
+ # # app.process_all()
262
+ # assert app.videometa["FIRST_GOOD_FRAME"] == 150
263
+ # assert app.videometa["LAST_GOOD_FRAME"] == 400
264
+ # # ✅ Ensure all threads are stopped properly after test
265
265
 
266
266
 
267
267
  def test_process_every_nth_frame(app, qtbot, mocker):
@@ -272,7 +272,6 @@ def test_process_every_nth_frame(app, qtbot, mocker):
272
272
  with qtbot.waitSignal(app.ui.spinBox_frame_skips.valueChanged):
273
273
  app.ui.spinBox_frame_skips.setValue(2)
274
274
  assert app.ui.spinBox_frame_skips.value() == 2
275
-
276
275
 
277
276
 
278
277
  # def test_set_output_filename_and_process(app, qtbot, mocker):
@@ -311,6 +310,7 @@ def test_process_every_nth_frame(app, qtbot, mocker):
311
310
 
312
311
  # app.thread = None
313
312
 
313
+
314
314
  def test_toggle_write_video(app, qtbot, mocker):
315
315
  """
316
316
  Test toggling the 'Write video?' checkbox.
File without changes
File without changes