Skip to content

Commit

Permalink
still need to find some bug with int32 vs long
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlib committed Dec 6, 2024
1 parent 3a1f8ef commit 514bae0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
16 changes: 8 additions & 8 deletions py_bind/optv/correspondences.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ cdef class MatchedCoords:
pnr - n-length array, the corresponding target number for each point.
"""
cdef:
np.ndarray[ndim=2, dtype=np.float64_t] pos
np.ndarray[ndim=1, dtype=np.int32_t] pnr
np.ndarray[ndim=2, dtype=np.float64_t] positions
np.ndarray[ndim=1, dtype=np.int32_t] point_numbers
int pt

pos = np.empty((self._num_pts, 2))
pnr = np.empty(self._num_pts, dtype=np.int32)
positions = np.empty((self._num_pts, 2))
point_numbers = np.empty(self._num_pts, dtype=np.int32)

for pt in range(self._num_pts):
pos[pt,0] = self.buf[pt].x
pos[pt,1] = self.buf[pt].y
pnr[pt] = self.buf[pt].pnr
positions[pt,0] = self.buf[pt].x
positions[pt,1] = self.buf[pt].y
point_numbers[pt] = self.buf[pt].pnr

return pos, pnr
return positions, point_numbers

def get_by_pnrs(self, np.ndarray[ndim=1, dtype=np.int32_t] pnrs):
"""
Expand Down
5 changes: 2 additions & 3 deletions py_bind/optv/image_processing.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from optv.parameters cimport ControlParams, control_par
import numpy as np
cimport numpy as np
from six import string_types

def preprocess_image(np.ndarray[ndim=2, dtype=np.uint8_t] input_img,
int filter_hp,
Expand Down Expand Up @@ -42,10 +41,10 @@ def preprocess_image(np.ndarray[ndim=2, dtype=np.uint8_t] input_img,
output_img = np.empty_like(input_img)

if filter_hp == 2:
if filter_file == None or not isinstance(filter_file, string_types):
if filter_file is None or not isinstance(filter_file, str):
raise ValueError("Expecting a filter file name, received None or non-string.")
else:
filter_file=b""
filter_file = b""

for arr in (input_img, output_img):
if not arr.flags['C_CONTIGUOUS']:
Expand Down
21 changes: 12 additions & 9 deletions py_bind/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = [
"packaging==20.5; platform_machine=='arm64'", # macos M1
"setuptools==59.2.0",
"wheel==0.37.0",
"Cython", # Note: keep in sync with tools/cythonize.py
requires = ["flit_core >=2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "optv"
version = "0.3.0"
description = "OpenPTV "
authors = [
{ name="Alex Liberzon", email="[email protected]"}
]
dependencies = [
"numpy",
"cython"
]

[tool.cibuildwheel]
before-build = "pip install numpy cython && cd py_bind && python setup.py prepare"
test-requires = ["nose","six"]
test-command = "cd {project}/py_bind/test && nosetests"
skip = ["cp310-*","pp*"]
6 changes: 3 additions & 3 deletions py_bind/test/test_burgers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ def test_forward(self):
self.tracker.restart()
last_step = 10001
while self.tracker.step_forward():
self.failUnless(self.tracker.current_step() > last_step)
self.assertTrue(self.tracker.current_step() > last_step)
with open("testing_fodder/burgers/res/rt_is.%d" % last_step) as f:
lines = f.readlines()
# print(last_step,lines[0])
# print(lines)
if last_step == 10003:
self.failUnless(lines[0] == "4\n")
self.assertTrue(lines[0] == "4\n")
else:
self.failUnless(lines[0] == "5\n")
self.assertTrue(lines[0] == "5\n")
last_step += 1
self.tracker.finalize()

Expand Down

0 comments on commit 514bae0

Please sign in to comment.