pyvale 2025.5.3__cp311-cp311-musllinux_1_2_i686.whl → 2025.7.0__cp311-cp311-musllinux_1_2_i686.whl

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.

Potentially problematic release.


This version of pyvale might be problematic. Click here for more details.

Files changed (96) hide show
  1. pyvale/__init__.py +12 -0
  2. pyvale/blendercalibrationdata.py +3 -1
  3. pyvale/blenderscene.py +7 -5
  4. pyvale/blendertools.py +27 -5
  5. pyvale/camera.py +1 -0
  6. pyvale/cameradata.py +3 -0
  7. pyvale/camerasensor.py +147 -0
  8. pyvale/camerastereo.py +4 -4
  9. pyvale/cameratools.py +23 -61
  10. pyvale/cython/rastercyth.c +1657 -1352
  11. pyvale/cython/rastercyth.cpython-311-i386-linux-musl.so +0 -0
  12. pyvale/cython/rastercyth.py +71 -26
  13. pyvale/data/plate_hole_def0000.tiff +0 -0
  14. pyvale/data/plate_hole_def0001.tiff +0 -0
  15. pyvale/data/plate_hole_ref0000.tiff +0 -0
  16. pyvale/data/plate_rigid_def0000.tiff +0 -0
  17. pyvale/data/plate_rigid_def0001.tiff +0 -0
  18. pyvale/data/plate_rigid_ref0000.tiff +0 -0
  19. pyvale/dataset.py +96 -6
  20. pyvale/dic/cpp/dicbruteforce.cpp +370 -0
  21. pyvale/dic/cpp/dicfourier.cpp +648 -0
  22. pyvale/dic/cpp/dicinterpolator.cpp +559 -0
  23. pyvale/dic/cpp/dicmain.cpp +215 -0
  24. pyvale/dic/cpp/dicoptimizer.cpp +675 -0
  25. pyvale/dic/cpp/dicrg.cpp +137 -0
  26. pyvale/dic/cpp/dicscanmethod.cpp +677 -0
  27. pyvale/dic/cpp/dicsmooth.cpp +138 -0
  28. pyvale/dic/cpp/dicstrain.cpp +383 -0
  29. pyvale/dic/cpp/dicutil.cpp +563 -0
  30. pyvale/dic2d.py +164 -0
  31. pyvale/dic2dcpp.cpython-311-i386-linux-musl.so +0 -0
  32. pyvale/dicchecks.py +476 -0
  33. pyvale/dicdataimport.py +247 -0
  34. pyvale/dicregionofinterest.py +887 -0
  35. pyvale/dicresults.py +55 -0
  36. pyvale/dicspecklegenerator.py +238 -0
  37. pyvale/dicspecklequality.py +305 -0
  38. pyvale/dicstrain.py +387 -0
  39. pyvale/dicstrainresults.py +37 -0
  40. pyvale/errorintegrator.py +10 -8
  41. pyvale/examples/basics/ex1_1_basicscalars_therm2d.py +124 -113
  42. pyvale/examples/basics/ex1_2_sensormodel_therm2d.py +124 -132
  43. pyvale/examples/basics/ex1_3_customsens_therm3d.py +199 -195
  44. pyvale/examples/basics/ex1_4_basicerrors_therm3d.py +125 -121
  45. pyvale/examples/basics/ex1_5_fielderrs_therm3d.py +145 -141
  46. pyvale/examples/basics/ex1_6_caliberrs_therm2d.py +96 -101
  47. pyvale/examples/basics/ex1_7_spatavg_therm2d.py +109 -105
  48. pyvale/examples/basics/ex2_1_basicvectors_disp2d.py +92 -91
  49. pyvale/examples/basics/ex2_2_vectorsens_disp2d.py +96 -90
  50. pyvale/examples/basics/ex2_3_sensangle_disp2d.py +88 -89
  51. pyvale/examples/basics/ex2_4_chainfielderrs_disp2d.py +172 -171
  52. pyvale/examples/basics/ex2_5_vectorfields3d_disp3d.py +88 -86
  53. pyvale/examples/basics/ex3_1_basictensors_strain2d.py +90 -90
  54. pyvale/examples/basics/ex3_2_tensorsens2d_strain2d.py +93 -91
  55. pyvale/examples/basics/ex3_3_tensorsens3d_strain3d.py +172 -160
  56. pyvale/examples/basics/ex4_1_expsim2d_thermmech2d.py +154 -148
  57. pyvale/examples/basics/ex4_2_expsim3d_thermmech3d.py +249 -231
  58. pyvale/examples/dic/ex1_region_of_interest.py +98 -0
  59. pyvale/examples/dic/ex2_plate_with_hole.py +149 -0
  60. pyvale/examples/dic/ex3_plate_with_hole_strain.py +93 -0
  61. pyvale/examples/dic/ex4_dic_blender.py +95 -0
  62. pyvale/examples/dic/ex5_dic_challenge.py +102 -0
  63. pyvale/examples/imagedef2d/ex_imagedef2d_todisk.py +4 -2
  64. pyvale/examples/renderblender/ex1_1_blenderscene.py +152 -105
  65. pyvale/examples/renderblender/ex1_2_blenderdeformed.py +151 -100
  66. pyvale/examples/renderblender/ex2_1_stereoscene.py +183 -116
  67. pyvale/examples/renderblender/ex2_2_stereodeformed.py +185 -112
  68. pyvale/examples/renderblender/ex3_1_blendercalibration.py +164 -109
  69. pyvale/examples/renderrasterisation/ex_rastenp.py +74 -35
  70. pyvale/examples/renderrasterisation/ex_rastercyth_oneframe.py +6 -13
  71. pyvale/examples/renderrasterisation/ex_rastercyth_static_cypara.py +2 -2
  72. pyvale/examples/renderrasterisation/ex_rastercyth_static_pypara.py +2 -4
  73. pyvale/imagedef2d.py +3 -2
  74. pyvale/imagetools.py +137 -0
  75. pyvale/rastercy.py +34 -4
  76. pyvale/rasternp.py +300 -276
  77. pyvale/rasteropts.py +58 -0
  78. pyvale/renderer.py +47 -0
  79. pyvale/rendermesh.py +52 -62
  80. pyvale/renderscene.py +51 -0
  81. pyvale/sensorarrayfactory.py +2 -2
  82. pyvale/sensortools.py +19 -35
  83. pyvale/simcases/case21.i +1 -1
  84. pyvale/simcases/run_1case.py +8 -0
  85. pyvale/simtools.py +2 -2
  86. pyvale/visualsimplotter.py +180 -0
  87. {pyvale-2025.5.3.dist-info → pyvale-2025.7.0.dist-info}/METADATA +11 -57
  88. {pyvale-2025.5.3.dist-info → pyvale-2025.7.0.dist-info}/RECORD +94 -56
  89. {pyvale-2025.5.3.dist-info → pyvale-2025.7.0.dist-info}/WHEEL +1 -1
  90. pyvale.libs/libgcc_s-887de51c.so.1 +0 -0
  91. pyvale.libs/libgomp-24921df4.so.1.0.0 +0 -0
  92. pyvale.libs/libstdc++-d6415257.so.6.0.33 +0 -0
  93. pyvale/examples/visualisation/ex1_1_plot_traces.py +0 -102
  94. pyvale/examples/visualisation/ex2_1_animate_sim.py +0 -89
  95. {pyvale-2025.5.3.dist-info → pyvale-2025.7.0.dist-info}/licenses/LICENSE +0 -0
  96. {pyvale-2025.5.3.dist-info → pyvale-2025.7.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,370 @@
1
+ // ================================================================================
2
+ // pyvale: the python validation engine
3
+ // License: MIT
4
+ // Copyright (C) 2025 The Computer Aided Validation Team
5
+ // ================================================================================
6
+
7
+
8
+ // STD library Header files
9
+ #include <iostream>
10
+ #include <vector>
11
+ #include <cmath>
12
+ #include <array>
13
+
14
+ // opencv header files
15
+ //#include "opencv2/imgcodecs.hpp"
16
+ //#include "opencv2/highgui.hpp"
17
+ //#include "opencv2/imgproc.hpp"
18
+
19
+ // Program Header files
20
+ #include "./dicbruteforce.hpp"
21
+ #include "./defines.hpp"
22
+
23
+
24
+ namespace brute {
25
+
26
+
27
+
28
+ // directions of spiral.
29
+ std::vector<int> dirs = {1, 0,
30
+ 0, 1,
31
+ -1, 0,
32
+ 0, -1};
33
+
34
+
35
+ // function pointers
36
+ double (*cost_function)(const double *img_ref,
37
+ const int px_hori,
38
+ const int px_vert,
39
+ util::Subset &ss_def,
40
+ util::Subset &ss_ref,
41
+ const int p0,
42
+ const int p1);
43
+
44
+ void (*find_min)(const int ss_x,
45
+ const int ss_y,
46
+ const double *img_ref,
47
+ const int px_hori,
48
+ const int px_vert,
49
+ util::Subset &ss_def,
50
+ util::Subset &ss_ref,
51
+ brute::Parameters &brute);
52
+
53
+
54
+
55
+ void init(std::string &corr_crit, std::string &search_method){
56
+
57
+ // set brute force cost function
58
+ if (corr_crit == "SSD") {
59
+ cost_function = brute::ssd;
60
+ } else if (corr_crit == "NSSD") {
61
+ cost_function = brute::nssd;
62
+ } else if (corr_crit == "ZNSSD") {
63
+ cost_function = brute::znssd;
64
+ } else {
65
+ std::cerr << "Error: cost function not recognised. Using SSD." << std::endl;
66
+ cost_function = brute::ssd;
67
+ }
68
+
69
+ // set brute force search method
70
+ if (search_method == "EXHAUSTIVE") {
71
+ find_min = exhaustive;
72
+ } else if (search_method == "EXPANDING_WAVEFRONT") {
73
+ find_min = expanding_wavefront;
74
+ } else {
75
+ //std::cerr << "Error: search method not recognised. Using EXPANDING_WAVEFRONT." << std::endl;
76
+ find_min = expanding_wavefront;
77
+ }
78
+ }
79
+
80
+
81
+ void expanding_wavefront(const int ss_x,
82
+ const int ss_y,
83
+ const double *img_ref,
84
+ const int px_hori,
85
+ const int px_vert,
86
+ util::Subset &ss_def,
87
+ util::Subset &ss_ref,
88
+ brute::Parameters &brute) {
89
+
90
+
91
+
92
+ const int range = brute.range;
93
+ double cost_min = 1.0e6;
94
+
95
+ int offset_x = 0; //brute.p_rigid_prevmatch[0];
96
+ int offset_y = 0; //brute.p_rigid_prevmatch[1];
97
+
98
+ for (int r = 0; r <= range; r++) {
99
+
100
+ // Go around the current ring at radius r
101
+ for (int dy = -r; dy <= r; dy++) {
102
+ for (int dx = -r; dx <= r; dx++) {
103
+
104
+
105
+ if (!is_perimeter_point(dx, dy, r))
106
+ continue;
107
+
108
+ int p0 = dx + offset_x;
109
+ int p1 = dy + offset_y;
110
+
111
+ if (!is_within_range(p0, p1, range))
112
+ continue;
113
+
114
+ int ss_xmin = ss_x + p0;
115
+ int ss_ymin = ss_y + p1;
116
+ int ss_xmax = ss_x + p0 + ss_def.size;
117
+ int ss_ymax = ss_y + p1 + ss_def.size;
118
+
119
+ if (!is_within_image(ss_xmin, ss_ymin, ss_xmax, ss_ymax,
120
+ px_hori, px_vert))
121
+ continue;
122
+
123
+ double cost = cost_function(img_ref, px_hori,
124
+ px_vert, ss_def,
125
+ ss_ref, p0, p1);
126
+
127
+ if (std::abs(cost) < cost_min) {
128
+ cost_min = cost;
129
+ brute.p_rigid[0] = p0;
130
+ brute.p_rigid[1] = p1;
131
+
132
+ // if its below our threshold and considered a good match. we'll use these values for the next brute force.
133
+ if (cost_min < brute.bf_threshold) {
134
+ brute.p_rigid_prevmatch[0] = brute.p_rigid[0];
135
+ brute.p_rigid_prevmatch[1] = brute.p_rigid[1];
136
+ return;
137
+ }
138
+ }
139
+ }
140
+ }
141
+ }
142
+ }
143
+
144
+
145
+ void exhaustive(const int ss_x,
146
+ const int ss_y,
147
+ const double *img_ref,
148
+ const int px_hori,
149
+ const int px_vert,
150
+ util::Subset &ss_def,
151
+ util::Subset &ss_ref,
152
+ brute::Parameters &brute){
153
+
154
+ const int range = brute.range;
155
+ double cost_min = 1.0e6;
156
+
157
+ // clamp search area to within image bounds
158
+ const int xmin = std::max(0, ss_x - range);
159
+ const int ymin = std::max(0, ss_y - range);
160
+ const int xmax = std::min(px_hori, ss_x + range);
161
+ const int ymax = std::min(px_vert, ss_y + range);
162
+
163
+
164
+ for (int p1 = -ymin; p1 <= ymax; p1++){
165
+ for (int p0 = -xmin; p0 <= xmax; p0++){
166
+
167
+ double cost = cost_function(img_ref, px_hori, px_vert, ss_def,ss_ref,p0,p1);
168
+
169
+ // update minumum value. If Below tolerance then return.
170
+ if (std::abs(cost) < cost_min) {
171
+ cost_min = cost;
172
+ brute.p_rigid[0] = p0;
173
+ brute.p_rigid[1] = p1;
174
+ if (cost_min < brute.bf_threshold) return;
175
+ }
176
+
177
+ }
178
+ }
179
+ }
180
+
181
+
182
+
183
+ double ssd(const double *img_ref,
184
+ const int px_hori,
185
+ const int px_vert,
186
+ util::Subset &ss_def,
187
+ util::Subset &ss_ref,
188
+ const int p0,
189
+ const int p1){
190
+
191
+ const int num_px = ss_def.num_px;
192
+ double cost = 0.0;
193
+
194
+ for (int i = 0; i < num_px; i++){
195
+
196
+ ss_ref.x[i] = ss_def.x[i] + p0;
197
+ ss_ref.y[i] = ss_def.y[i] + p1;
198
+
199
+ const int ss_ref_x_int = static_cast<int>(ss_ref.x[i]);
200
+ const int ss_ref_y_int = static_cast<int>(ss_ref.y[i]);
201
+ const int idx = ss_ref_y_int * px_hori + ss_ref_x_int;
202
+
203
+ ss_ref.vals[i] = img_ref[idx];
204
+
205
+ cost += (ss_def.vals[i] - ss_ref.vals[i]) *
206
+ (ss_def.vals[i] - ss_ref.vals[i]);
207
+
208
+ }
209
+
210
+ return cost;
211
+
212
+ }
213
+
214
+
215
+ double nssd(const double *img_ref,
216
+ const int px_hori,
217
+ const int px_vert,
218
+ util::Subset &ss_def,
219
+ util::Subset &ss_ref,
220
+ const int p0,
221
+ const int p1){
222
+
223
+
224
+ const int num_px = ss_def.num_px;
225
+ double cost = 0.0;
226
+ double sum_squared_ref = 0.0;
227
+ double sum_squared_def = 0.0;
228
+
229
+ // get subset values and cost function denominators
230
+ for (int i = 0; i < num_px; i++){
231
+
232
+ ss_ref.x[i] = ss_def.x[i] + p0;
233
+ ss_ref.y[i] = ss_def.y[i] + p1;
234
+
235
+ const int ss_ref_x_int = static_cast<int>(ss_ref.x[i]);
236
+ const int ss_ref_y_int = static_cast<int>(ss_ref.y[i]);
237
+ const int idx = ss_ref_y_int * px_hori + ss_ref_x_int;
238
+
239
+ ss_ref.vals[i] = img_ref[idx];
240
+
241
+ sum_squared_ref += ss_ref.vals[i] * ss_ref.vals[i];
242
+ sum_squared_def += ss_def.vals[i] * ss_def.vals[i];
243
+
244
+ }
245
+
246
+ double inv_sum_squared_ref = 1.0 / std::sqrt(sum_squared_ref);
247
+ double inv_sum_squared_def = 1.0 / std::sqrt(sum_squared_def);
248
+
249
+
250
+ // calculate cost
251
+ for (int i = 0; i < num_px; i++){
252
+ double def_norm = ss_def.vals[i] * inv_sum_squared_def;
253
+ double ref_norm = ss_ref.vals[i] * inv_sum_squared_ref;
254
+ cost += (def_norm - ref_norm) *
255
+ (def_norm - ref_norm);
256
+ }
257
+
258
+ return cost;
259
+
260
+ }
261
+
262
+ double znssd(const double *img_ref,
263
+ const int px_hori,
264
+ const int px_vert,
265
+ util::Subset &ss_def,
266
+ util::Subset &ss_ref,
267
+ const int p0,
268
+ const int p1){
269
+
270
+ const int num_px = ss_def.num_px;
271
+ double cost = 0.0;
272
+ double mean_ref = 0.0;
273
+ double mean_def = 0.0;
274
+
275
+ // loop over pixel values in reference image
276
+ for (int i = 0; i < num_px; i++){
277
+
278
+ ss_ref.x[i] = ss_def.x[i] + p0;
279
+ ss_ref.y[i] = ss_def.y[i] + p1;
280
+
281
+ const int ss_ref_x_int = static_cast<int>(ss_ref.x[i]);
282
+ const int ss_ref_y_int = static_cast<int>(ss_ref.y[i]);
283
+ const int idx = ss_ref_y_int * px_hori + ss_ref_x_int;
284
+
285
+ ss_ref.vals[i] = img_ref[idx];
286
+ mean_ref += ss_ref.vals[i];
287
+ mean_def += ss_def.vals[i];
288
+ }
289
+
290
+ mean_ref /= num_px;
291
+ mean_def /= num_px;
292
+
293
+ // get cost function denominators
294
+ double sum_squared_ref = 0.0;
295
+ double sum_squared_def = 0.0;
296
+ for (int i = 0; i < num_px; ++i) {
297
+ sum_squared_ref += (ss_ref.vals[i] - mean_ref)*
298
+ (ss_ref.vals[i] - mean_ref);
299
+ sum_squared_def += (ss_def.vals[i] - mean_def)*
300
+ (ss_def.vals[i] - mean_def);
301
+ }
302
+ double inv_sum_squared_ref = 1.0 / std::sqrt(sum_squared_ref);
303
+ double inv_sum_squared_def = 1.0 / std::sqrt(sum_squared_def);
304
+
305
+
306
+
307
+ // calcualte cost
308
+ for (int i = 0; i < num_px; i++){
309
+ double def_norm = ss_def.vals[i] * inv_sum_squared_def;
310
+ double ref_norm = ss_ref.vals[i] * inv_sum_squared_ref;
311
+ cost += (def_norm - ref_norm) * (def_norm - ref_norm);
312
+ }
313
+
314
+ return cost;
315
+ }
316
+
317
+
318
+
319
+ inline bool is_perimeter_point(int dx, int dy, int r) {
320
+ return std::abs(dx) == r || std::abs(dy) == r;
321
+ }
322
+
323
+ inline bool is_within_image(int xmin, int ymin, int xmax, int ymax,
324
+ int width, int height) {
325
+ return xmin >= 0 && xmax < width && ymin >= 0 && ymax < height;
326
+ }
327
+
328
+ inline bool is_within_range(int p0, int p1, int range) {
329
+ return p0 >= -range && p0 < range && p1 >= -range && p1 < range;
330
+ }
331
+
332
+
333
+
334
+ // void cross_correlation(const int ss_x,
335
+ // const int ss_y,
336
+ // const double *img_ref,
337
+ // const int px_vert,
338
+ // const int px_hori,
339
+ // util::Subset *ss_def,
340
+ // util::Subset *ss_ref,
341
+ // brute::Parameters &brute) {
342
+
343
+ // cv::Mat image(px_vert, px_hori, CV_32S, const_cast<int*>(img_ref));
344
+ // cv::Mat ss(ss_def.size, ss_def.size, CV_64F, ss_def.vals.data());
345
+
346
+ // cv::Mat image_float;
347
+ // cv::Mat ss_float;
348
+ // image.convertTo(image_float, CV_32F);
349
+ // ss.convertTo(ss_float, CV_32F);
350
+
351
+
352
+ // cv::Mat result;
353
+ // cv::matchTemplate(image_float, ss_float, result, cv::TM_CCOEFF_NORMED);
354
+
355
+ // double minVal; double maxVal; cv::Point minLoc; cv::Point maxLoc;
356
+ // cv::Point matchLoc;
357
+
358
+ // cv::minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, cv::Mat());
359
+
360
+ // std::cout << "minVal: " << minVal << std::endl;
361
+ // std::cout << "maxVal: " << maxVal << std::endl;
362
+ // std::cout << "minLoc: " << minLoc.x << ", " << minLoc.y << std::endl;
363
+ // std::cout << "maxLoc: " << maxLoc.x << ", " << maxLoc.y << std::endl;
364
+ // brute.p_rigid[0] = maxLoc.x - ss_x;
365
+ // brute.p_rigid[1] = maxLoc.y - ss_y;
366
+ // }
367
+
368
+
369
+ // end of namespace
370
+ }