Skip to content

Commit

Permalink
stopped as i do not understand the error message
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlib committed Dec 10, 2023
1 parent 6ef0220 commit 2d6e7b4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 28 deletions.
30 changes: 21 additions & 9 deletions py_bind/optv/parameters.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import numpy
numpy.import_array()

cimport numpy as numpy
from cpython cimport PyObject, Py_INCREF
from cpython cimport Py_INCREF, PyObject, PyTypeObject

cdef extern from "optv/parameters.h":
int c_compare_mm_np "compare_mm_np"(mm_np * mm_np1, mm_np * mm_np2)
Expand All @@ -19,16 +19,23 @@ cdef extern from "optv/parameters.h":
void c_free_sequence_par "free_sequence_par"(sequence_par * sp)
int c_compare_sequence_par "compare_sequence_par"(sequence_par * sp1, sequence_par * sp2)

volume_par * c_read_volume_par "read_volume_par"(char * filename);
int c_compare_volume_par "compare_volume_par"(volume_par * v1, volume_par * v2);
volume_par * c_read_volume_par "read_volume_par"(char * filename)
int c_compare_volume_par "compare_volume_par"(volume_par * v1, volume_par * v2)

control_par * c_read_control_par "read_control_par"(char * filename);
control_par * c_new_control_par "new_control_par"(int cams);
void c_free_control_par "free_control_par"(control_par * cp);
int c_compare_control_par "compare_control_par"(control_par * c1, control_par * c2);
control_par * c_read_control_par "read_control_par"(char * filename)
control_par * c_new_control_par "new_control_par"(int cams)
void c_free_control_par "free_control_par"(control_par * cp)
int c_compare_control_par "compare_control_par"(control_par * c1, control_par * c2)

target_par* read_target_par(char *filename)

cdef extern from "numpy/arrayobject.h":
object PyArray_NewFromDescr(PyTypeObject* subtype, numpy.dtype descr,
int nd, numpy.npy_intp* dims,
numpy.npy_intp* strides,
void* data, int flags, object obj)
int PyArray_SetBaseObject(numpy.ndarray arr, PyObject* obj)

cdef numpy.ndarray wrap_1d_c_arr_as_ndarray(object base_obj,
int arr_size, int num_type, void * data, int copy):
"""
Expand All @@ -51,7 +58,8 @@ cdef numpy.ndarray wrap_1d_c_arr_as_ndarray(object base_obj,
shape[0] = <numpy.npy_intp> arr_size

ndarr = numpy.PyArray_SimpleNewFromData(1, shape, num_type, data)
ndarr.base = <PyObject *> base_obj
# ndarr.base = <PyObject *> base_obj
PyArray_SetBaseObject(ndarr, <PyObject *> base_obj)
Py_INCREF(base_obj)

if copy:
Expand Down Expand Up @@ -392,8 +400,12 @@ cdef class SequenceParams:
# Get image base name of camera #cam
def get_img_base_name(self, cam):
cdef char * c_str = self._sequence_par[0].img_base_name[cam]
cdef py_str = c_str
# FILEPATH: /home/user/Documents/repos/openptv/py_bind/optv/parameters.pyx
# BEGIN: ed8c6549bwf9
cdef char* c_str = ...
py_str = c_str
return py_str
# END: ed8c6549bwf9

# Set image base name for camera #cam
def set_img_base_name(self, cam, str new_img_name):
Expand Down
8 changes: 4 additions & 4 deletions py_bind/optv/transforms.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
void metric_to_pixel(double * x_pixel
, double * y_pixel
, double x_metric
, double y_metric
, control_par * parameters);
, control_par * parameters)
void correct_brown_affin (double x
, double y
, ap_52 ap
, double * x1
, double * y1);
, double * y1)
void distort_brown_affin (double x
, double y
, ap_52 ap
, double * x1
, double * y1);
, double * y1)

void correct_brown_affine_exact(double x, double y, ap_52 ap,
double *x1, double *y1, double tol)
Expand Down
30 changes: 15 additions & 15 deletions py_bind/optv/transforms.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def check_inputs(inp_arr, out_arr):
+ str(inp_arr.shape) + " != " + str(out_arr.shape))
return out_arr

def convert_arr_pixel_to_metric(np.ndarray[ndim=2, dtype=np.float_t] input,
def convert_arr_pixel_to_metric(np.ndarray[np.float_t, ndim=2] input,
ControlParams control,
np.ndarray[ndim=2, dtype=np.float_t] out=None):
np.ndarray[np.float_t, ndim=2] out=None):
'''
Convert NumPy 2d, Nx2 array from pixel coordinates to metric coordinates.
Arguments:
Expand All @@ -39,9 +39,9 @@ def convert_arr_pixel_to_metric(np.ndarray[ndim=2, dtype=np.float_t] input,
'''
return convert_generic(input, control._control_par, out, pixel_to_metric)

def convert_arr_metric_to_pixel(np.ndarray[ndim=2, dtype=np.float_t] input,
def convert_arr_metric_to_pixel(np.ndarray[np.float_t, ndim=2] input,
ControlParams control,
np.ndarray[ndim=2, dtype=np.float_t] out=None):
np.ndarray[np.float_t, ndim=2] out=None):
'''
Convert NumPy 2d, Nx2 array from metric coordinates to pixel coordinates.
input - input Numpy ndarray of Nx2 shape.
Expand All @@ -53,10 +53,10 @@ def convert_arr_metric_to_pixel(np.ndarray[ndim=2, dtype=np.float_t] input,
'''
return convert_generic(input, control._control_par, out, metric_to_pixel)

cdef convert_generic(np.ndarray[ndim=2, dtype=np.float_t] input,
cdef convert_generic(np.ndarray[np.float_t, ndim=2] input,
control_par * c_control,
np.ndarray[ndim=2, dtype=np.float_t] out,
void convert_function(double * , double * , double, double , control_par *)):
np.ndarray[np.float_t, ndim=2] out,
void convert_function(double * , double * , double, double , control_par *)) noexcept nogil:
out = check_inputs(input, out)

for i in range(input.shape[0]):
Expand All @@ -69,9 +69,9 @@ cdef convert_generic(np.ndarray[ndim=2, dtype=np.float_t] input,

# Affine #

def correct_arr_brown_affine(np.ndarray[ndim=2, dtype=np.float_t] input,
def correct_arr_brown_affine(np.ndarray[np.float_t, ndim=2] input,
Calibration calibration,
np.ndarray[ndim=2, dtype=np.float_t] out=None):
np.ndarray[np.float_t, ndim=2] out=None):
'''
Correct crd to geo with Brown + affine.
input - input Numpy ndarray of Nx2 shape.
Expand All @@ -85,9 +85,9 @@ def correct_arr_brown_affine(np.ndarray[ndim=2, dtype=np.float_t] input,
return brown_affine_generic(input, calibration._calibration.added_par, out,
correct_brown_affin)

def distort_arr_brown_affine(np.ndarray[ndim=2, dtype=np.float_t] input,
def distort_arr_brown_affine(np.ndarray[np.float_t, ndim=2] input,
Calibration calibration,
np.ndarray[ndim=2, dtype=np.float_t] out=None):
np.ndarray[np.float_t, ndim=2] out=None):
'''
Transformation with Brown + affine.
input - input Numpy ndarray of Nx2 shape.
Expand All @@ -100,9 +100,9 @@ def distort_arr_brown_affine(np.ndarray[ndim=2, dtype=np.float_t] input,
return brown_affine_generic(input, calibration._calibration.added_par, out,
distort_brown_affin)

cdef brown_affine_generic(np.ndarray[ndim=2, dtype=np.float_t] input,
cdef brown_affine_generic(np.ndarray[np.float_t, ndim=2] input,
ap_52 c_ap_52,
np.ndarray[ndim=2, dtype=np.float_t] out,
np.ndarray[np.float_t, ndim=2] out,
void affine_function(double, double, ap_52 , double * , double *)):
out = check_inputs(input, out)

Expand All @@ -114,8 +114,8 @@ cdef brown_affine_generic(np.ndarray[ndim=2, dtype=np.float_t] input,
, < double *> np.PyArray_GETPTR2(out, i, 1))
return out

def distorted_to_flat(np.ndarray[ndim=2, dtype=np.float_t] inp,
Calibration calibration, np.ndarray[ndim=2, dtype=np.float_t] out=None,
def distorted_to_flat(np.ndarray[np.float_t, ndim=2] inp,
Calibration calibration, np.ndarray[np.float_t, ndim=2] out=None,
double tol=0.00001):
"""
Full, exact conversion of distorted metric coordinates to flat unshifted
Expand Down

0 comments on commit 2d6e7b4

Please sign in to comment.