diff --git a/liboptv/include/calibration.h b/liboptv/include/calibration.h index f4d0c07f..7902c7fe 100644 --- a/liboptv/include/calibration.h +++ b/liboptv/include/calibration.h @@ -58,10 +58,8 @@ typedef struct { -int write_ori(Exterior Ex, Interior I, Glass G, ap_52 ap, char *filename, - char *add_file); -int read_ori (Exterior Ex[], Interior I[], Glass G[], char *ori_file, - ap_52 addp[], char *add_file, char *add_fallback); +int write_ori(Exterior ext_par, Interior int_par, Glass glass_par, ap_52 added_par, char *filename, char *add_file); +int read_ori (Exterior ext_par[], Interior int_par[], Glass glass_par[], char *ori_file, ap_52 added_par[], char *add_file, char *add_fallback); int compare_exterior(Exterior *e1, Exterior *e2); int compare_interior(Interior *i1, Interior *i2); int compare_glass(Glass *g1, Glass *g2); diff --git a/liboptv/include/ray_tracing.h b/liboptv/include/ray_tracing.h index 7305d4d2..f23c2ec6 100644 --- a/liboptv/include/ray_tracing.h +++ b/liboptv/include/ray_tracing.h @@ -23,7 +23,7 @@ void ray_tracing (double x , double X[3] , double a[3]); -void old_ray_tracing (double x, double y, Exterior Ex, Interior I, Glass G,\ +void old_ray_tracing (double x, double y, Exterior ext_par, Interior int_par, Glass glass_par,\ mm_np mm, double *Xb2, double *Yb2, double *Zb2, \ double *a3, double *b3,double *c3); diff --git a/liboptv/src/orientation.c b/liboptv/src/orientation.c index 21f23c22..20387627 100644 --- a/liboptv/src/orientation.c +++ b/liboptv/src/orientation.c @@ -723,10 +723,19 @@ int read_man_ori_fix(vec3d fix4[4], char* calblock_filename, goto handle_error; } - for (i=0; i #include #include "tracking_frame_buf.h" +#include "calibration.h" /* Check that target t1 is equal to target t2, i.e. all their fields are equal. * diff --git a/py_bind/optv/correspondences.pyx b/py_bind/optv/correspondences.pyx index 1b14fc3b..3e21ff67 100644 --- a/py_bind/optv/correspondences.pyx +++ b/py_bind/optv/correspondences.pyx @@ -84,11 +84,11 @@ cdef class MatchedCoords: """ cdef: np.ndarray[ndim=2, dtype=np.float64_t] pos - np.ndarray[ndim=1, dtype=np.int_t] pnr + np.ndarray[ndim=1, dtype=np.int32_t] pnr int pt pos = np.empty((self._num_pts, 2)) - pnr = np.empty(self._num_pts, dtype=np.int_) + pnr = np.empty(self._num_pts, dtype=np.int32) for pt in range(self._num_pts): pos[pt,0] = self.buf[pt].x @@ -97,7 +97,7 @@ cdef class MatchedCoords: return pos, pnr - def get_by_pnrs(self, np.ndarray[ndim=1, dtype=np.int_t] pnrs): + def get_by_pnrs(self, np.ndarray[ndim=1, dtype=np.int32_t] pnrs): """ Return the flat positions of points whose pnr property is given, as an (n,2) flat position array. Assumes all pnrs are to be found, otherwise @@ -160,7 +160,7 @@ def correspondences(list img_pts, list flat_coords, list cals, num_cams * sizeof(coord_2d *)) frame frm - np.ndarray[ndim=2, dtype=np.int_t] clique_ids + np.ndarray[ndim=2, dtype=np.int32_t] clique_ids np.ndarray[ndim=3, dtype=np.float64_t] clique_targs # Return buffers: diff --git a/py_bind/optv/orientation.pyx b/py_bind/optv/orientation.pyx index b3ef927e..473689ba 100644 --- a/py_bind/optv/orientation.pyx +++ b/py_bind/optv/orientation.pyx @@ -263,7 +263,7 @@ def full_calibration(Calibration cal, cdef: vec3d *ref_coord np.ndarray[ndim=2, dtype=pos_t] ret - np.ndarray[ndim=1, dtype=np.int_t] used + np.ndarray[ndim=1, dtype=np.int32_t] used np.ndarray[ndim=1, dtype=pos_t] err_est orient_par *orip double *residuals diff --git a/py_bind/optv/parameters.pyx b/py_bind/optv/parameters.pyx index a294d224..0f83ee8e 100644 --- a/py_bind/optv/parameters.pyx +++ b/py_bind/optv/parameters.pyx @@ -402,7 +402,7 @@ cdef class SequenceParams: cdef char * c_str = self._sequence_par[0].img_base_name[cam] # FILEPATH: /home/user/Documents/repos/openptv/py_bind/optv/parameters.pyx # BEGIN: ed8c6549bwf9 - cdef char* c_str = ... + # cdef char* c_str = ... py_str = c_str return py_str # END: ed8c6549bwf9 diff --git a/py_bind/optv/segmentation.pyx b/py_bind/optv/segmentation.pyx index d40dff9e..d04f0a99 100644 --- a/py_bind/optv/segmentation.pyx +++ b/py_bind/optv/segmentation.pyx @@ -21,7 +21,7 @@ DTYPE = np.uint8 # "ctypedef" assigns a corresponding compile-time type to DTYPE_t. For # every type in the numpy module there's a corresponding compile-time # type with a _t-suffix. -ctypedef np.int_t DTYPE_t +ctypedef np.uint8_t DTYPE_t from optv.parameters cimport TargetParams, ControlParams from optv.tracking_framebuf cimport TargetArray diff --git a/py_bind/optv/transforms.pxd b/py_bind/optv/transforms.pxd index bc573b40..7765a23b 100644 --- a/py_bind/optv/transforms.pxd +++ b/py_bind/optv/transforms.pxd @@ -7,22 +7,22 @@ cdef extern from "optv/trafo.h": , double * y_metric , double x_pixel , double y_pixel - , control_par * parameters) + , control_par * parameters) noexcept void metric_to_pixel(double * x_pixel , double * y_pixel , double x_metric , double y_metric - , control_par * parameters) + , control_par * parameters) noexcept void correct_brown_affin (double x , double y , ap_52 ap , double * x1 - , double * y1) + , double * y1) noexcept void distort_brown_affin (double x , double y , ap_52 ap , double * x1 - , double * y1) + , double * y1) noexcept void correct_brown_affine_exact(double x, double y, ap_52 ap, double *x1, double *y1, double tol) diff --git a/py_bind/optv/transforms.pyx b/py_bind/optv/transforms.pyx index 2bcd7acb..b9f9afbe 100644 --- a/py_bind/optv/transforms.pyx +++ b/py_bind/optv/transforms.pyx @@ -53,18 +53,24 @@ def convert_arr_metric_to_pixel(np.ndarray[np.float_t, ndim=2] input, ''' return convert_generic(input, control._control_par, out, metric_to_pixel) -cdef convert_generic(np.ndarray[np.float_t, ndim=2] input, - control_par * c_control, - np.ndarray[np.float_t, ndim=2] out, - void convert_function(double * , double * , double, double , control_par *)) noexcept nogil: +cdef convert_generic( + np.ndarray[np.float_t, ndim=2] input, + control_par * c_control, + np.ndarray[np.float_t, ndim=2] out, + void (*convert_function)(double *, double *, double, double, control_par *) + noexcept ): + # Acquire GIL before calling any GIL-requiring functions out = check_inputs(input, out) for i in range(input.shape[0]): - convert_function(< double *> np.PyArray_GETPTR2(out, i, 0) - , < double *> np.PyArray_GETPTR2(out, i, 1) - , (< double *> np.PyArray_GETPTR2(input, i, 0))[0] - , (< double *> np.PyArray_GETPTR2(input, i, 1))[0] - , c_control) + convert_function( np.PyArray_GETPTR2(out, i, 0), + np.PyArray_GETPTR2(out, i, 1), + ( np.PyArray_GETPTR2(input, i, 0))[0], + ( np.PyArray_GETPTR2(input, i, 1))[0], + c_control) + + # Acquire GIL before returning the Python object + return out # Affine # @@ -103,7 +109,7 @@ def distort_arr_brown_affine(np.ndarray[np.float_t, ndim=2] input, cdef brown_affine_generic(np.ndarray[np.float_t, ndim=2] input, ap_52 c_ap_52, np.ndarray[np.float_t, ndim=2] out, - void affine_function(double, double, ap_52 , double * , double *)): + void (*affine_function)(double, double, ap_52, double *, double *) noexcept): out = check_inputs(input, out) for i in range(input.shape[0]): diff --git a/py_bind/pyproject.toml b/py_bind/pyproject.toml index 4f45da8c..068bf258 100644 --- a/py_bind/pyproject.toml +++ b/py_bind/pyproject.toml @@ -4,8 +4,8 @@ requires = [ "packaging==20.5; platform_machine=='arm64'", # macos M1 "setuptools==59.2.0", "wheel==0.37.0", - "Cython>=0.29.28,<3.0", # Note: keep in sync with tools/cythonize.py - "numpy>=1.17.3, <1.24", + "Cython", # Note: keep in sync with tools/cythonize.py + "numpy", ] [tool.cibuildwheel] diff --git a/py_bind/setup.py b/py_bind/setup.py index d13b621c..834847c1 100644 --- a/py_bind/setup.py +++ b/py_bind/setup.py @@ -82,7 +82,7 @@ def get_numpy_include_dir(): del builtins.__NUMPY_SETUP__ import importlib import numpy - importlib.reload(numpy) + # importlib.reload(numpy) else: import builtins if hasattr(__builtin__, '__NUMPY_SETUP__'): @@ -122,7 +122,7 @@ def get_liboptv_sources(): def mk_ext(name, files): # Do not specify include dirs, as they require numpy to be installed. Add them in BuildExt - return Extension(name, files + get_liboptv_sources()) + return Extension(name, files + get_liboptv_sources(), define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')]) ext_mods = [ @@ -154,9 +154,9 @@ def mk_ext(name, files): package_data={ 'optv': ['*.pxd', '*.c', '*.h'], }, - version='0.2.8', + version='0.3.0', install_requires=[ - 'numpy<1.24', + 'numpy', 'pyyaml', ], setup_requires=['numpy'],