optv 0.2.8__tar.gz → 0.3.0__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 (103) hide show
  1. optv-0.3.0/MANIFEST.in +6 -0
  2. optv-0.3.0/PKG-INFO +47 -0
  3. optv-0.3.0/README.md +36 -0
  4. optv-0.3.0/liboptv/include/calibration.h +84 -0
  5. optv-0.3.0/liboptv/include/glass.h +11 -0
  6. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/parameters.h +2 -2
  7. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/ray_tracing.h +1 -11
  8. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/track.h +11 -0
  9. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/tracking_frame_buf.h +163 -163
  10. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/tracking_run.h +36 -36
  11. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/vec_utils.h +43 -43
  12. {optv-0.2.8 → optv-0.3.0}/liboptv/src/calibration.c +11 -17
  13. {optv-0.2.8 → optv-0.3.0}/liboptv/src/epi.c +5 -0
  14. {optv-0.2.8 → optv-0.3.0}/liboptv/src/orientation.c +34 -12
  15. {optv-0.2.8 → optv-0.3.0}/liboptv/src/segmentation.c +537 -537
  16. {optv-0.2.8 → optv-0.3.0}/liboptv/src/track.c +1275 -1275
  17. {optv-0.2.8 → optv-0.3.0}/liboptv/src/tracking_frame_buf.c +724 -724
  18. {optv-0.2.8 → optv-0.3.0}/liboptv/src/tracking_run.c +92 -92
  19. {optv-0.2.8 → optv-0.3.0}/liboptv/src/trafo.c +114 -50
  20. optv-0.3.0/optv/__init__.py +4 -0
  21. optv-0.3.0/optv/calibration.c +16774 -0
  22. {optv-0.2.8 → optv-0.3.0}/optv/calibration.pxd +8 -2
  23. optv-0.3.0/optv/correspondences.c +16004 -0
  24. {optv-0.2.8 → optv-0.3.0}/optv/correspondences.pxd +3 -0
  25. optv-0.3.0/optv/epipolar.c +11563 -0
  26. {optv-0.2.8 → optv-0.3.0}/optv/epipolar.pxd +2 -6
  27. optv-0.3.0/optv/image_processing.c +11796 -0
  28. {optv-0.2.8 → optv-0.3.0}/optv/image_processing.pxd +3 -0
  29. optv-0.3.0/optv/imgcoord.c +12884 -0
  30. {optv-0.2.8 → optv-0.3.0}/optv/imgcoord.pxd +3 -0
  31. optv-0.3.0/optv/orientation.c +17217 -0
  32. {optv-0.2.8 → optv-0.3.0}/optv/orientation.pxd +3 -0
  33. optv-0.3.0/optv/parameters.c +36868 -0
  34. {optv-0.2.8 → optv-0.3.0}/optv/parameters.pxd +38 -5
  35. optv-0.3.0/optv/segmentation.c +11724 -0
  36. {optv-0.2.8 → optv-0.3.0}/optv/segmentation.pxd +4 -1
  37. optv-0.3.0/optv/tracker.c +13844 -0
  38. {optv-0.2.8 → optv-0.3.0}/optv/tracker.pxd +3 -0
  39. optv-0.3.0/optv/tracking_framebuf.c +18509 -0
  40. {optv-0.2.8 → optv-0.3.0}/optv/tracking_framebuf.pxd +3 -1
  41. optv-0.3.0/optv/transforms.c +34041 -0
  42. {optv-0.2.8 → optv-0.3.0}/optv/transforms.pxd +2 -0
  43. optv-0.3.0/optv/version.py +1 -0
  44. optv-0.3.0/optv.egg-info/PKG-INFO +47 -0
  45. {optv-0.2.8 → optv-0.3.0}/optv.egg-info/SOURCES.txt +23 -18
  46. optv-0.3.0/optv.egg-info/requires.txt +2 -0
  47. optv-0.3.0/pyproject.toml +30 -0
  48. {optv-0.2.8 → optv-0.3.0}/setup.cfg +4 -4
  49. optv-0.3.0/setup.py +105 -0
  50. {optv-0.2.8 → optv-0.3.0}/test/test_burgers.py +3 -3
  51. {optv-0.2.8 → optv-0.3.0}/test/test_corresp.py +14 -14
  52. {optv-0.2.8 → optv-0.3.0}/test/test_epipolar.py +2 -2
  53. {optv-0.2.8 → optv-0.3.0}/test/test_orientation.py +14 -14
  54. {optv-0.2.8 → optv-0.3.0}/test/test_parameters_bindings.py +25 -26
  55. {optv-0.2.8 → optv-0.3.0}/test/test_segmentation.py +82 -82
  56. {optv-0.2.8 → optv-0.3.0}/test/test_tracker.py +39 -7
  57. {optv-0.2.8 → optv-0.3.0}/test/test_trafo_bindings.py +4 -4
  58. optv-0.3.0/test/test_version.py +15 -0
  59. optv-0.2.8/PKG-INFO +0 -3
  60. optv-0.2.8/liboptv/include/optv/calibration.h +0 -78
  61. optv-0.2.8/optv/__init__.py +0 -0
  62. optv-0.2.8/optv/calibration.c +0 -9768
  63. optv-0.2.8/optv/correspondences.c +0 -10372
  64. optv-0.2.8/optv/epipolar.c +0 -7174
  65. optv-0.2.8/optv/image_processing.c +0 -7298
  66. optv-0.2.8/optv/imgcoord.c +0 -8080
  67. optv-0.2.8/optv/orientation.c +0 -11486
  68. optv-0.2.8/optv/parameters.c +0 -21067
  69. optv-0.2.8/optv/segmentation.c +0 -7260
  70. optv-0.2.8/optv/tracker.c +0 -5083
  71. optv-0.2.8/optv/tracking_framebuf.c +0 -11369
  72. optv-0.2.8/optv/transforms.c +0 -9186
  73. optv-0.2.8/optv.egg-info/PKG-INFO +0 -3
  74. optv-0.2.8/optv.egg-info/requires.txt +0 -2
  75. optv-0.2.8/pyproject.toml +0 -15
  76. optv-0.2.8/setup.py +0 -163
  77. {optv-0.2.8 → optv-0.3.0}/README.txt +0 -0
  78. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/correspondences.h +0 -0
  79. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/epi.h +0 -0
  80. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/image_processing.h +0 -0
  81. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/imgcoord.h +0 -0
  82. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/lsqadj.h +0 -0
  83. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/multimed.h +0 -0
  84. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/orientation.h +0 -0
  85. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/segmentation.h +0 -0
  86. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/sortgrid.h +0 -0
  87. {optv-0.2.8/liboptv/include/optv → optv-0.3.0/liboptv/include}/trafo.h +0 -0
  88. {optv-0.2.8 → optv-0.3.0}/liboptv/src/correspondences.c +0 -0
  89. {optv-0.2.8 → optv-0.3.0}/liboptv/src/image_processing.c +0 -0
  90. {optv-0.2.8 → optv-0.3.0}/liboptv/src/imgcoord.c +0 -0
  91. {optv-0.2.8 → optv-0.3.0}/liboptv/src/lsqadj.c +0 -0
  92. {optv-0.2.8 → optv-0.3.0}/liboptv/src/multimed.c +0 -0
  93. {optv-0.2.8 → optv-0.3.0}/liboptv/src/parameters.c +0 -0
  94. {optv-0.2.8 → optv-0.3.0}/liboptv/src/ray_tracing.c +0 -0
  95. {optv-0.2.8 → optv-0.3.0}/liboptv/src/sortgrid.c +0 -0
  96. {optv-0.2.8 → optv-0.3.0}/liboptv/src/vec_utils.c +0 -0
  97. {optv-0.2.8 → optv-0.3.0}/optv/vec_utils.pxd +0 -0
  98. {optv-0.2.8 → optv-0.3.0}/optv.egg-info/dependency_links.txt +0 -0
  99. {optv-0.2.8 → optv-0.3.0}/optv.egg-info/top_level.txt +0 -0
  100. {optv-0.2.8 → optv-0.3.0}/test/test_calibration_binding.py +0 -0
  101. {optv-0.2.8 → optv-0.3.0}/test/test_framebuf.py +0 -0
  102. {optv-0.2.8 → optv-0.3.0}/test/test_image_processing.py +0 -0
  103. {optv-0.2.8 → optv-0.3.0}/test/test_img_coord.py +0 -0
optv-0.3.0/MANIFEST.in ADDED
@@ -0,0 +1,6 @@
1
+ include src/optv/*.pxd
2
+ include src/optv/*.pyx
3
+ include src/optv/*.h
4
+ include liboptv/include/*.h
5
+ include liboptv/src/*.c
6
+ include liboptv/*.h
optv-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: optv
3
+ Version: 0.3.0
4
+ Summary: OpenPTV Python bindings
5
+ Author-email: OpenPTV Community <openptv@googlegroups.com>
6
+ License: LGPL-3.0-or-later
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: numpy==1.26.4
10
+ Requires-Dist: pyyaml
11
+
12
+ # OpenPTV Python Bindings
13
+
14
+ Python bindings for the OpenPTV library.
15
+
16
+ ## Installation
17
+
18
+ Simple installation via pip:
19
+
20
+ ```bash
21
+ pip install openptv
22
+ ```
23
+
24
+ ## Building from Source
25
+
26
+ 1. Install dependencies:
27
+ ```bash
28
+ pip install numpy cython setuptools
29
+ ```
30
+
31
+ 2. Build the package:
32
+ ```bash
33
+ python setup.py prepare
34
+ python setup.py build
35
+ python setup.py install
36
+ ```
37
+
38
+ ## Testing
39
+
40
+ Run the test suite:
41
+ ```bash
42
+ pytest test/
43
+ ```
44
+
45
+ ## License
46
+
47
+ LGPL-3.0-or-later
optv-0.3.0/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # OpenPTV Python Bindings
2
+
3
+ Python bindings for the OpenPTV library.
4
+
5
+ ## Installation
6
+
7
+ Simple installation via pip:
8
+
9
+ ```bash
10
+ pip install openptv
11
+ ```
12
+
13
+ ## Building from Source
14
+
15
+ 1. Install dependencies:
16
+ ```bash
17
+ pip install numpy cython setuptools
18
+ ```
19
+
20
+ 2. Build the package:
21
+ ```bash
22
+ python setup.py prepare
23
+ python setup.py build
24
+ python setup.py install
25
+ ```
26
+
27
+ ## Testing
28
+
29
+ Run the test suite:
30
+ ```bash
31
+ pytest test/
32
+ ```
33
+
34
+ ## License
35
+
36
+ LGPL-3.0-or-later
@@ -0,0 +1,84 @@
1
+ /* Objects related to calibration: exterior and interior parameters, glass
2
+ parameters. A Calibration object to rule them all and find them.
3
+
4
+ References:
5
+ [1] Th. Dracos (editor). Three-Dimensional Velocity and Vorticity Measuring
6
+ and Image Analysis Techniques. Kluwer Academic Publishers. 1996.
7
+ pp.165-168
8
+ */
9
+ #ifndef CALIBRATION_H
10
+ #define CALIBRATION_H
11
+
12
+ #include "vec_utils.h"
13
+
14
+ #ifdef __cplusplus
15
+ extern "C" {
16
+ #endif
17
+
18
+ typedef double Dmatrix[3][3];
19
+
20
+ /* Define Glass structure first */
21
+ typedef struct Glass_t {
22
+ double vec_x, vec_y, vec_z;
23
+ double n1, n2, n3;
24
+ double d;
25
+ } Glass;
26
+
27
+ /* Then the rest of the structs */
28
+ typedef struct Exterior_t {
29
+ double x0, y0, z0;
30
+ double omega, phi, kappa;
31
+ Dmatrix dm;
32
+ } Exterior;
33
+
34
+ typedef struct Interior_t {
35
+ double xh, yh;
36
+ double cc;
37
+ } Interior;
38
+
39
+
40
+ typedef struct {
41
+ double k1, k2, k3;
42
+ double p1, p2;
43
+ double scx, she;
44
+ int field;
45
+ } ap_52;
46
+
47
+ typedef struct {
48
+ vec3d origin;
49
+ int nr, nz, rw;
50
+ double *data;
51
+ } mmlut;
52
+
53
+ typedef struct {
54
+ Exterior ext_par;
55
+ Interior int_par;
56
+ Glass glass_par;
57
+ ap_52 added_par;
58
+ mmlut mmlut;
59
+ } Calibration;
60
+
61
+ /* Function declarations - now all structs are defined */
62
+ int write_ori(Exterior Ex, Interior interior, Glass glass, ap_52 ap,
63
+ char *filename, char *add_file);
64
+ int read_ori(Exterior Ex[], Interior interior[], Glass glass[], char *ori_file,
65
+ ap_52 addp[], char *add_file, char *add_fallback);
66
+ void rotation_matrix(Exterior *ex);
67
+
68
+ /* Compare two calibration objects for equality */
69
+ int compare_calib(Calibration *c1, Calibration *c2);
70
+
71
+ /* Compare individual calibration components */
72
+ int compare_exterior(Exterior *e1, Exterior *e2);
73
+ int compare_interior(Interior *i1, Interior *i2);
74
+ int compare_glass(Glass *g1, Glass *g2);
75
+ int compare_addpar(ap_52 *a1, ap_52 *a2);
76
+
77
+ Calibration* read_calibration(char *ori_file, char *add_file, char *fallback_file);
78
+ int write_calibration(Calibration *cal, char *filename, char *add_file);
79
+
80
+ #ifdef __cplusplus
81
+ }
82
+ #endif
83
+
84
+ #endif
@@ -0,0 +1,11 @@
1
+ // glass.h
2
+ #ifndef GLASS_H
3
+ #define GLASS_H
4
+
5
+ typedef struct Glass_t {
6
+ double vec_x, vec_y, vec_z;
7
+ double n1, n2, n3;
8
+ double d;
9
+ } Glass;
10
+
11
+ #endif // GLASS_H
@@ -20,13 +20,13 @@ sequence_par* new_sequence_par(int num_cams);
20
20
  void free_sequence_par(sequence_par * sp);
21
21
  int compare_sequence_par(sequence_par *sp1, sequence_par *sp2);
22
22
 
23
- typedef struct
24
- {
23
+ typedef struct {
25
24
  double dacc, dangle, dvxmax, dvxmin;
26
25
  double dvymax, dvymin, dvzmax, dvzmin;
27
26
  int dsumg, dn, dnx, dny, add;
28
27
  } track_par;
29
28
 
29
+ /* Function declarations */
30
30
  track_par* read_track_par(char *filename);
31
31
  int compare_track_par(track_par *t1, track_par *t2);
32
32
 
@@ -16,17 +16,7 @@
16
16
  #include "tracking_frame_buf.h"
17
17
  #include "lsqadj.h"
18
18
 
19
- void ray_tracing (double x
20
- , double y
21
- , Calibration* cal
22
- , mm_np mm
23
- , double X[3]
24
- , double a[3]);
25
-
26
- void old_ray_tracing (double x, double y, Exterior Ex, Interior I, Glass G,\
27
- mm_np mm, double *Xb2, double *Yb2, double *Zb2, \
28
- double *a3, double *b3,double *c3);
29
-
19
+ void ray_tracing(double x, double y, Calibration* cal, mm_np mm, double X[3], double a[3]);
30
20
 
31
21
  #endif
32
22
 
@@ -58,4 +58,15 @@ void trackcorr_c_loop (tracking_run *run_info, int step);
58
58
  void trackcorr_c_finish(tracking_run *run_info, int step);
59
59
  double trackback_c(tracking_run *run_info);
60
60
 
61
+ /* add_particle() inserts a particle at a given position to the end of the
62
+ * frame, along with associated targets.
63
+ *
64
+ * Arguments:
65
+ * frame *frm - the frame to store the particle.
66
+ * vec3d pos - position of inserted particle in the global coordinates.
67
+ * int cand_inds[][MAX_CANDS] - indices of candidate targets for association
68
+ * with this particle.
69
+ */
70
+ void add_particle(frame *frm, vec3d pos, int cand_inds[][MAX_CANDS]);
71
+
61
72
  #endif
@@ -1,163 +1,163 @@
1
- /*
2
- Definition for the tracking frame buffers. Each frame holds target information
3
- for all cameras, correspondence information and path links information.
4
- */
5
-
6
- #ifndef TRACKING_FRAME_BUF_H
7
- #define TRACKING_FRAME_BUF_H
8
-
9
- /* For point positions */
10
- #include "vec_utils.h"
11
-
12
- #define POSI 80
13
- #define STR_MAX_LEN 255
14
-
15
- #define PT_UNUSED -999
16
-
17
- typedef struct
18
- {
19
- int pnr;
20
- double x, y;
21
- int n, nx, ny, sumg;
22
- int tnr;
23
- }
24
- target;
25
-
26
- int compare_targets(target *t1, target *t2);
27
- int read_targets(target buffer[], char* file_base, int frame_num);
28
- int write_targets(target buffer[], int num_targets, char* file_base, \
29
- int frame_num);
30
-
31
- typedef struct
32
- {
33
- int nr;
34
- int p[4];
35
- }
36
- corres;
37
-
38
- int compare_corres(corres *c1, corres *c2);
39
- #define CORRES_NONE -1
40
-
41
- typedef float fitness_t;
42
-
43
- typedef struct Pstruct
44
- {
45
- vec3d x; /*coordinates*/
46
- int prev, next; /*pointer to prev or next link*/
47
- int prio; /*Prority of link is used for differen levels*/
48
- fitness_t decis[POSI]; /*Bin for decision critera of possible links to next dataset*/
49
- fitness_t finaldecis; /*final decision critera by which the link was established*/
50
- int linkdecis[POSI]; /* pointer of possible links to next data set*/
51
- int inlist; /* Counter of number of possible links to next data set*/
52
- } P;
53
-
54
- int compare_path_info(P *p1, P *p2);
55
- void register_link_candidate(P *self, fitness_t fitness, int cand);
56
- #define PREV_NONE -1
57
- #define NEXT_NONE -2
58
- #define PRIO_DEFAULT 2
59
- void reset_links(P *self);
60
-
61
- int read_path_frame(corres *cor_buf, P *path_buf, \
62
- char *corres_file_base, char *linkage_file_base,
63
- char *prio_file_base, int frame_num);
64
- int write_path_frame(corres *cor_buf, P *path_buf, int num_parts,\
65
- char *corres_file_base, char *linkage_file_base,
66
- char *prio_file_base, int frame_num);
67
-
68
- typedef struct {
69
- P *path_info;
70
- corres *correspond;
71
- target **targets;
72
- int num_cams, max_targets;
73
- int num_parts; /* Number of 3D particles in the correspondence buffer */
74
- int *num_targets; /* Pointer to array of 2D particle counts per image. */
75
- } frame;
76
-
77
- void frame_init(frame *new_frame, int num_cams, int max_targets);
78
- void free_frame(frame *self);
79
- int read_frame(frame *self, char *corres_file_base, char *linkage_file_base,
80
- char *prio_file_base, char **target_file_base, int frame_num);
81
- int write_frame(frame *self, char *corres_file_base, char *linkage_file_base,
82
- char *prio_file_base, char **target_file_base, int frame_num);
83
-
84
-
85
- /*
86
- * Following is the frame buffer class, that holds a given number of frame structs,
87
- * and treats them as a deque (doube-ended queue, a queue that can advance forward
88
- * or backward).
89
- *
90
- * The memory locations are advanced with fb_next()/fb_prev(). Filling out the new
91
- * frame that joined the queue and flushing out the frame that exited the queue
92
- * are respectively done using fb_read_frame_at_end() and fb_write_frame_from_start().
93
- *
94
- * To make it possible to read frames from different sources, we use a
95
- * base-class/child-class structure. framebuf_base is the base class, and implements
96
- * only the memory-advance methods. The filling-out of frames is done by
97
- * "virtual" functions. That is to say, fb_read_frame_at_end, for example,
98
- * only forwards the call to a function that really reads the data.
99
- *
100
- * The virtual functions are placed in the "vtable" by the constructor - the
101
- * function that allocates and populates the child class.
102
- *
103
- * In tracking_framebuf.c and here there's an example child-class that reads
104
- * frame information from *_target files. This is the original mode of
105
- * liboptv. The struct framebuf *inherits* from framebuf_base (by incorporating
106
- * the base as 1st member - the order is important). fb_init(), the constructor,
107
- * then populates the vtable with fb_disk_* functions. These are the derived
108
- * implementations of the base-class virtual functions.
109
- *
110
- * There is also a virtual destructor, fb_free(), which delegates to the free()
111
- * virtual function, and implemented in the example by fb_disk_free().
112
- *
113
- * Note: fb_disk_free does not release the strings it holds, as I don't remember if
114
- * it owns them.
115
- *
116
- * Yes, in C++ it's easier :)
117
- */
118
-
119
- // Virtual function table definitions for frame buffer objects:
120
- typedef struct framebuf_base* fbp;
121
- typedef struct {
122
- void (*free)(fbp self);
123
- int (*read_frame_at_end)(fbp self, int frame_num, int read_links);
124
- int (*write_frame_from_start)(fbp self, int frame_num);
125
- } fb_vtable;
126
-
127
- typedef struct framebuf_base {
128
- fb_vtable *_vptr;
129
-
130
- /* _ring_vec is the underlying double-size vector, buf is the pointer to
131
- the start of the ring. */
132
- frame **buf, **_ring_vec;
133
- int buf_len, num_cams;
134
- } framebuf_base;
135
-
136
- // These just call the corresponding virtual function.
137
- // Actual implementations are below each child class.
138
- void fb_free(framebuf_base *self);
139
- int fb_read_frame_at_end(framebuf_base *self, int frame_num, int read_links);
140
- int fb_write_frame_from_start(framebuf_base *self, int frame_num);
141
-
142
- // Non-virtual methods of the base class.
143
- void fb_base_init(framebuf_base *new_buf, int buf_len, int num_cams, int max_targets);
144
- void fb_next(framebuf_base *self);
145
- void fb_prev(framebuf_base *self);
146
-
147
- // child class that reads from _target files.
148
- typedef struct {
149
- framebuf_base base; // must be 1st member.
150
-
151
- char *corres_file_base, *linkage_file_base, *prio_file_base;
152
- char **target_file_base;
153
- } framebuf;
154
-
155
- void fb_init(framebuf *new_buf, int buf_len, int num_cams, int max_targets,\
156
- char *corres_file_base, char* linkage_file_base, char *prio_file_base,
157
- char **target_file_base);
158
-
159
- void fb_disk_free(framebuf_base *self);
160
- int fb_disk_read_frame_at_end(framebuf_base *self, int frame_num, int read_links);
161
- int fb_disk_write_frame_from_start(framebuf_base *self, int frame_num);
162
-
163
- #endif
1
+ /*
2
+ Definition for the tracking frame buffers. Each frame holds target information
3
+ for all cameras, correspondence information and path links information.
4
+ */
5
+
6
+ #ifndef TRACKING_FRAME_BUF_H
7
+ #define TRACKING_FRAME_BUF_H
8
+
9
+ /* For point positions */
10
+ #include "vec_utils.h"
11
+
12
+ #define POSI 80
13
+ #define STR_MAX_LEN 255
14
+
15
+ #define PT_UNUSED -999
16
+
17
+ typedef struct
18
+ {
19
+ int pnr;
20
+ double x, y;
21
+ int n, nx, ny, sumg;
22
+ int tnr;
23
+ }
24
+ target;
25
+
26
+ int compare_targets(target *t1, target *t2);
27
+ int read_targets(target buffer[], char* file_base, int frame_num);
28
+ int write_targets(target buffer[], int num_targets, char* file_base, \
29
+ int frame_num);
30
+
31
+ typedef struct
32
+ {
33
+ int nr;
34
+ int p[4];
35
+ }
36
+ corres;
37
+
38
+ int compare_corres(corres *c1, corres *c2);
39
+ #define CORRES_NONE -1
40
+
41
+ typedef float fitness_t;
42
+
43
+ typedef struct Pstruct
44
+ {
45
+ vec3d x; /*coordinates*/
46
+ int prev, next; /*pointer to prev or next link*/
47
+ int prio; /*Prority of link is used for differen levels*/
48
+ fitness_t decis[POSI]; /*Bin for decision critera of possible links to next dataset*/
49
+ fitness_t finaldecis; /*final decision critera by which the link was established*/
50
+ int linkdecis[POSI]; /* pointer of possible links to next data set*/
51
+ int inlist; /* Counter of number of possible links to next data set*/
52
+ } P;
53
+
54
+ int compare_path_info(P *p1, P *p2);
55
+ void register_link_candidate(P *self, fitness_t fitness, int cand);
56
+ #define PREV_NONE -1
57
+ #define NEXT_NONE -2
58
+ #define PRIO_DEFAULT 2
59
+ void reset_links(P *self);
60
+
61
+ int read_path_frame(corres *cor_buf, P *path_buf, \
62
+ char *corres_file_base, char *linkage_file_base,
63
+ char *prio_file_base, int frame_num);
64
+ int write_path_frame(corres *cor_buf, P *path_buf, int num_parts,\
65
+ char *corres_file_base, char *linkage_file_base,
66
+ char *prio_file_base, int frame_num);
67
+
68
+ typedef struct {
69
+ P *path_info;
70
+ corres *correspond;
71
+ target **targets;
72
+ int num_cams, max_targets;
73
+ int num_parts; /* Number of 3D particles in the correspondence buffer */
74
+ int *num_targets; /* Pointer to array of 2D particle counts per image. */
75
+ } frame;
76
+
77
+ void frame_init(frame *new_frame, int num_cams, int max_targets);
78
+ void free_frame(frame *self);
79
+ int read_frame(frame *self, char *corres_file_base, char *linkage_file_base,
80
+ char *prio_file_base, char **target_file_base, int frame_num);
81
+ int write_frame(frame *self, char *corres_file_base, char *linkage_file_base,
82
+ char *prio_file_base, char **target_file_base, int frame_num);
83
+
84
+
85
+ /*
86
+ * Following is the frame buffer class, that holds a given number of frame structs,
87
+ * and treats them as a deque (doube-ended queue, a queue that can advance forward
88
+ * or backward).
89
+ *
90
+ * The memory locations are advanced with fb_next()/fb_prev(). Filling out the new
91
+ * frame that joined the queue and flushing out the frame that exited the queue
92
+ * are respectively done using fb_read_frame_at_end() and fb_write_frame_from_start().
93
+ *
94
+ * To make it possible to read frames from different sources, we use a
95
+ * base-class/child-class structure. framebuf_base is the base class, and implements
96
+ * only the memory-advance methods. The filling-out of frames is done by
97
+ * "virtual" functions. That is to say, fb_read_frame_at_end, for example,
98
+ * only forwards the call to a function that really reads the data.
99
+ *
100
+ * The virtual functions are placed in the "vtable" by the constructor - the
101
+ * function that allocates and populates the child class.
102
+ *
103
+ * In tracking_framebuf.c and here there's an example child-class that reads
104
+ * frame information from *_target files. This is the original mode of
105
+ * liboptv. The struct framebuf *inherits* from framebuf_base (by incorporating
106
+ * the base as 1st member - the order is important). fb_init(), the constructor,
107
+ * then populates the vtable with fb_disk_* functions. These are the derived
108
+ * implementations of the base-class virtual functions.
109
+ *
110
+ * There is also a virtual destructor, fb_free(), which delegates to the free()
111
+ * virtual function, and implemented in the example by fb_disk_free().
112
+ *
113
+ * Note: fb_disk_free does not release the strings it holds, as I don't remember if
114
+ * it owns them.
115
+ *
116
+ * Yes, in C++ it's easier :)
117
+ */
118
+
119
+ // Virtual function table definitions for frame buffer objects:
120
+ typedef struct framebuf_base* fbp;
121
+ typedef struct {
122
+ void (*free)(fbp self);
123
+ int (*read_frame_at_end)(fbp self, int frame_num, int read_links);
124
+ int (*write_frame_from_start)(fbp self, int frame_num);
125
+ } fb_vtable;
126
+
127
+ typedef struct framebuf_base {
128
+ fb_vtable *_vptr;
129
+
130
+ /* _ring_vec is the underlying double-size vector, buf is the pointer to
131
+ the start of the ring. */
132
+ frame **buf, **_ring_vec;
133
+ int buf_len, num_cams;
134
+ } framebuf_base;
135
+
136
+ // These just call the corresponding virtual function.
137
+ // Actual implementations are below each child class.
138
+ void fb_free(framebuf_base *self);
139
+ int fb_read_frame_at_end(framebuf_base *self, int frame_num, int read_links);
140
+ int fb_write_frame_from_start(framebuf_base *self, int frame_num);
141
+
142
+ // Non-virtual methods of the base class.
143
+ void fb_base_init(framebuf_base *new_buf, int buf_len, int num_cams, int max_targets);
144
+ void fb_next(framebuf_base *self);
145
+ void fb_prev(framebuf_base *self);
146
+
147
+ // child class that reads from _target files.
148
+ typedef struct {
149
+ framebuf_base base; // must be 1st member.
150
+
151
+ char *corres_file_base, *linkage_file_base, *prio_file_base;
152
+ char **target_file_base;
153
+ } framebuf;
154
+
155
+ void fb_init(framebuf *new_buf, int buf_len, int num_cams, int max_targets,\
156
+ char *corres_file_base, char* linkage_file_base, char *prio_file_base,
157
+ char **target_file_base);
158
+
159
+ void fb_disk_free(framebuf_base *self);
160
+ int fb_disk_read_frame_at_end(framebuf_base *self, int frame_num, int read_links);
161
+ int fb_disk_write_frame_from_start(framebuf_base *self, int frame_num);
162
+
163
+ #endif
@@ -1,36 +1,36 @@
1
- /* An object representing a tracking run. Holds parameters but also
2
- intermediate results collected on each step of tracking. For use in
3
- tracking algorithms that need to communicate with sub-components such as
4
- single-step tracking routine driven by a loop.
5
- */
6
-
7
- #ifndef TRACKING_RUN_H
8
- #define TRACKING_RUN_H
9
-
10
- #include "parameters.h"
11
- #include "calibration.h"
12
- #include "tracking_frame_buf.h"
13
-
14
- typedef struct {
15
- framebuf_base *fb;
16
- sequence_par *seq_par;
17
- track_par *tpar;
18
- volume_par *vpar;
19
- control_par *cpar;
20
- Calibration **cal;
21
- double flatten_tol; /* Tolerance for dist_to_flat() */
22
-
23
- /* Intermediate calculations done in run setup phase and used in the loop: */
24
- double ymin, ymax, lmax;
25
- int npart, nlinks;
26
- } tracking_run;
27
-
28
- tracking_run* tr_new_legacy(char *seq_par_fname, char *tpar_fname,
29
- char *vpar_fname, char *cpar_fnamei, Calibration **cal);
30
- tracking_run* tr_new(sequence_par *seq_par, track_par *tpar,
31
- volume_par *vpar, control_par *cpar, int buf_len, int max_targets,
32
- char *corres_file_base, char *linkage_file_base, char *prio_file_base,
33
- Calibration **cal, double flatten_tol);
34
- void tr_free(tracking_run *tr);
35
-
36
- #endif
1
+ /* An object representing a tracking run. Holds parameters but also
2
+ intermediate results collected on each step of tracking. For use in
3
+ tracking algorithms that need to communicate with sub-components such as
4
+ single-step tracking routine driven by a loop.
5
+ */
6
+
7
+ #ifndef TRACKING_RUN_H
8
+ #define TRACKING_RUN_H
9
+
10
+ #include "parameters.h"
11
+ #include "calibration.h"
12
+ #include "tracking_frame_buf.h"
13
+
14
+ typedef struct {
15
+ framebuf_base *fb;
16
+ sequence_par *seq_par;
17
+ track_par *tpar;
18
+ volume_par *vpar;
19
+ control_par *cpar;
20
+ Calibration **cal;
21
+ double flatten_tol; /* Tolerance for dist_to_flat() */
22
+
23
+ /* Intermediate calculations done in run setup phase and used in the loop: */
24
+ double ymin, ymax, lmax;
25
+ int npart, nlinks;
26
+ } tracking_run;
27
+
28
+ tracking_run* tr_new_legacy(char *seq_par_fname, char *tpar_fname,
29
+ char *vpar_fname, char *cpar_fnamei, Calibration **cal);
30
+ tracking_run* tr_new(sequence_par *seq_par, track_par *tpar,
31
+ volume_par *vpar, control_par *cpar, int buf_len, int max_targets,
32
+ char *corres_file_base, char *linkage_file_base, char *prio_file_base,
33
+ Calibration **cal, double flatten_tol);
34
+ void tr_free(tracking_run *tr);
35
+
36
+ #endif