diff --git a/.gitignore b/.gitignore index 6b98ba8d..bad57703 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ py_bind/optv/*.c py_bind/dist py_bind/build py_bind/liboptv +py_bind/optv.egg-info/ liboptv/config.h.in~ liboptv/tests/check_fb.trs diff --git a/.travis.yml b/.travis.yml index b987d66a..bedcfcff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ before_install: install: - conda update --yes conda - - conda create -n testenv --yes $DEPS numpy cython pyyaml nose python=$TRAVIS_PYTHON_VERSION + - conda create -n testenv --yes $DEPS numpy cython pyyaml nose six python=$TRAVIS_PYTHON_VERSION - source activate testenv # for debugging... diff --git a/docker/Dockerfile b/docker/Dockerfile.python2 similarity index 100% rename from docker/Dockerfile rename to docker/Dockerfile.python2 diff --git a/docker/Dockerfile.python3 b/docker/Dockerfile.python3 new file mode 100644 index 00000000..6c824184 --- /dev/null +++ b/docker/Dockerfile.python3 @@ -0,0 +1,11 @@ +# A Dockerfile for an Ubuntu machine that can compile liboptv and the Cython extensions + +FROM python:3.7-stretch + +RUN apt-get update +RUN apt-get --assume-yes install cmake +RUN apt-get --assume-yes install g++ +# RUN apt-get --assume-yes install python-pip +# RUN apt-get --assume-yes install python3 +# RUN pip install virtualenv +RUN python3 -m venv /env \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 20d8ba1e..b6cda219 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,9 +1,11 @@ # Set up the Ubuntu container so we can develop the Cython code on it version: '3' services: - optv-dev: - image: ptv-ubuntu:1 - build: ./ + optv-dev-python3: + image: ptv-ubuntu:python3 + build: + context: ./ + dockerfile: Dockerfile.python3 volumes: - ../:/src command: tail -f /dev/null diff --git a/py_bind/README.txt b/py_bind/README.txt index c2f1365d..6c589c0c 100644 --- a/py_bind/README.txt +++ b/py_bind/README.txt @@ -44,7 +44,7 @@ Testing the installation Regardless of the system you installed on, the shell commands are the same: cd tests/ - nosetests . + nosetests * Usage example ------------- diff --git a/py_bind/optv/calibration.pyx b/py_bind/optv/calibration.pyx index 25589538..8bdb51c7 100644 --- a/py_bind/optv/calibration.pyx +++ b/py_bind/optv/calibration.pyx @@ -9,7 +9,6 @@ import numpy cimport numpy as cnp from optv.calibration import Calibration -from mhlib import isnumeric cdef extern from "optv/calibration.h": calibration *read_calibration(char *ori_file, char *add_file, @@ -160,7 +159,7 @@ cdef class Calibration: of point from sensor middle and sensor-point distance, in this order. """ - if (object>prim_point_pos).shape != (3,): + if (prim_point_pos).shape != (3,): raise ValueError("Expected a 3-element array") self._calibration[0].int_par.xh = prim_point_pos[0] diff --git a/py_bind/optv/image_processing.pyx b/py_bind/optv/image_processing.pyx index ab98b8ff..6add1627 100644 --- a/py_bind/optv/image_processing.pyx +++ b/py_bind/optv/image_processing.pyx @@ -1,6 +1,7 @@ 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, @@ -41,10 +42,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, basestring): + if filter_file == None or not isinstance(filter_file, string_types): raise ValueError("Expecting a filter file name, received None or non-string.") else: - filter_file="" + filter_file=b"" for arr in (input_img, output_img): if not arr.flags['C_CONTIGUOUS']: diff --git a/py_bind/optv/tracker.pyx b/py_bind/optv/tracker.pyx index 8b247f4c..cbf47d33 100644 --- a/py_bind/optv/tracker.pyx +++ b/py_bind/optv/tracker.pyx @@ -14,9 +14,9 @@ from optv.orientation cimport cal_list2arr from optv.tracking_framebuf cimport fb_free default_naming = { - 'corres': 'res/rt_is', - 'linkage': 'res/ptv_is', - 'prio': 'res/added' + 'corres': b'res/rt_is', + 'linkage': b'res/ptv_is', + 'prio': b'res/added' } cdef class Tracker: diff --git a/py_bind/requirements.txt b/py_bind/requirements.txt index 960203de..1a025509 100644 --- a/py_bind/requirements.txt +++ b/py_bind/requirements.txt @@ -1,4 +1,5 @@ -Cython==0.29.5 +Cython==0.29.6 nose==1.3.7 -numpy==1.16.1 -PyYAML>=4.2b1 +numpy==1.16.2 +PyYAML==5.1 +six diff --git a/py_bind/setup.py b/py_bind/setup.py index 805a199c..bdef2b84 100644 --- a/py_bind/setup.py +++ b/py_bind/setup.py @@ -150,10 +150,10 @@ def mk_ext(name, files): package_data={ 'optv': ['*.pxd', '*.c', '*.h'], }, - version='0.2.4', + version='0.2.5', install_requires=[ - 'numpy==1.16.1', + 'numpy>=1.16.1', 'pyyaml', ], - setup_requires=['numpy==1.16.1'], + setup_requires=['numpy>=1.16.1'], ) diff --git a/py_bind/test/test_calibration_binding.py b/py_bind/test/test_calibration_binding.py index eb4a056c..427ab1de 100644 --- a/py_bind/test/test_calibration_binding.py +++ b/py_bind/test/test_calibration_binding.py @@ -4,9 +4,9 @@ class Test_Calibration(unittest.TestCase): def setUp(self): - self.input_ori_file_name = "testing_fodder/calibration/cam1.tif.ori" - self.input_add_file_name = "testing_fodder/calibration/cam2.tif.addpar" - self.output_directory = "testing_fodder/calibration/testing_output/" + self.input_ori_file_name = b"testing_fodder/calibration/cam1.tif.ori" + self.input_add_file_name = b"testing_fodder/calibration/cam2.tif.addpar" + self.output_directory = b"testing_fodder/calibration/testing_output/" # create a temporary output directory (will be deleted by the end of test) if not os.path.exists(self.output_directory): @@ -37,8 +37,8 @@ def test_full_instantiate(self): def test_Calibration_instantiation(self): """Filling a calibration object by reading ori files""" - self.output_ori_file_name = self.output_directory + "output_ori" - self.output_add_file_name = self.output_directory + "output_add" + self.output_ori_file_name = self.output_directory + b"output_ori" + self.output_add_file_name = self.output_directory + b"output_add" # Using a round-trip test. self.cal.from_file(self.input_ori_file_name, self.input_add_file_name) diff --git a/py_bind/test/test_corresp.py b/py_bind/test/test_corresp.py index 09419956..dcc023dc 100644 --- a/py_bind/test/test_corresp.py +++ b/py_bind/test/test_corresp.py @@ -18,11 +18,11 @@ def test_instantiate(self): """Creating a MatchedCoords object""" cal = Calibration() cpar = ControlParams(4) - + cal.from_file( - "testing_fodder/calibration/cam1.tif.ori", - "testing_fodder/calibration/cam2.tif.addpar") - cpar.read_control_par("testing_fodder/corresp/control.par") + b"testing_fodder/calibration/cam1.tif.ori", + b"testing_fodder/calibration/cam2.tif.addpar") + cpar.read_control_par(b"testing_fodder/corresp/control.par") targs = read_targets("testing_fodder/frame/cam1.", 333) mc = MatchedCoords(targs, cpar, cal) @@ -39,9 +39,9 @@ class TestCorresp(unittest.TestCase): def test_full_corresp(self): """Full scene correspondences""" cpar = ControlParams(4) - cpar.read_control_par(r"testing_fodder/corresp/control.par") + cpar.read_control_par(b"testing_fodder/corresp/control.par") vpar = VolumeParams() - vpar.read_volume_par(r"testing_fodder/corresp/criteria.par") + vpar.read_volume_par(b"testing_fodder/corresp/criteria.par") # Cameras are at so high angles that opposing cameras don't see each # other in the normal air-glass-water setting. @@ -54,8 +54,8 @@ def test_full_corresp(self): for c in range(4): cal = Calibration() cal.from_file( - "testing_fodder/calibration/sym_cam%d.tif.ori" % (c + 1), - "testing_fodder/calibration/cam1.tif.addpar") + b"testing_fodder/calibration/sym_cam%d.tif.ori" % (c + 1), + b"testing_fodder/calibration/cam1.tif.addpar") cals.append(cal) # Generate test targets. @@ -87,9 +87,9 @@ def test_full_corresp(self): def test_single_cam_corresp(self): """Single camera correspondence""" cpar = ControlParams(1) - cpar.read_control_par("testing_fodder/single_cam/parameters/ptv.par") + cpar.read_control_par(b"testing_fodder/single_cam/parameters/ptv.par") vpar = VolumeParams() - vpar.read_volume_par("testing_fodder/single_cam/parameters/criteria.par") + vpar.read_volume_par(b"testing_fodder/single_cam/parameters/criteria.par") # Cameras are at so high angles that opposing cameras don't see each # other in the normal air-glass-water setting. @@ -101,8 +101,8 @@ def test_single_cam_corresp(self): corrected = [] cal = Calibration() cal.from_file( - "testing_fodder/single_cam/calibration/cam_1.tif.ori", - "testing_fodder/single_cam/calibration/cam_1.tif.addpar") + b"testing_fodder/single_cam/calibration/cam_1.tif.ori", + b"testing_fodder/single_cam/calibration/cam_1.tif.addpar") cals.append(cal) # Generate test targets. @@ -127,4 +127,11 @@ def test_single_cam_corresp(self): _, _, num_targs = correspondences( img_pts, corrected, cals, vpar, cpar) - self.failUnlessEqual(num_targs, 9) \ No newline at end of file + self.failUnlessEqual(num_targs, 9) + + + +if __name__ == "__main__": + import sys, os + print(os.path.abspath(os.curdir)) + unittest.main() \ No newline at end of file diff --git a/py_bind/test/test_epipolar.py b/py_bind/test/test_epipolar.py index 458d45c3..eab45503 100644 --- a/py_bind/test/test_epipolar.py +++ b/py_bind/test/test_epipolar.py @@ -17,24 +17,24 @@ class TestEpipolarCurve(unittest.TestCase): def test_two_cameras(self): - ori_tmpl = r'testing_fodder/calibration/sym_cam{cam_num}.tif.ori' - add_file = r'testing_fodder/calibration/cam1.tif.addpar' + ori_tmpl = "testing_fodder/calibration/sym_cam{cam_num}.tif.ori" + add_file = "testing_fodder/calibration/cam1.tif.addpar" orig_cal = Calibration() - orig_cal.from_file(ori_tmpl.format(cam_num=1), add_file) + orig_cal.from_file(ori_tmpl.format(cam_num=1).encode(), add_file.encode()) proj_cal = Calibration() - proj_cal.from_file(ori_tmpl.format(cam_num=3), add_file) + proj_cal.from_file(ori_tmpl.format(cam_num=3).encode(), add_file.encode()) # reorient cams: orig_cal.set_angles(np.r_[0., -np.pi/4., 0.]) proj_cal.set_angles(np.r_[0., 3*np.pi/4., 0.]) cpar = ControlParams(4) - cpar.read_control_par("testing_fodder/corresp/control.par") + cpar.read_control_par(b"testing_fodder/corresp/control.par") sens_size = cpar.get_image_size() vpar = VolumeParams() - vpar.read_volume_par("testing_fodder/corresp/criteria.par") + vpar.read_volume_par(b"testing_fodder/corresp/criteria.par") vpar.set_Zmin_lay([-10, -10]) vpar.set_Zmax_lay([10, 10]) diff --git a/py_bind/test/test_framebuf.py b/py_bind/test/test_framebuf.py index 04c69b35..591afb22 100644 --- a/py_bind/test/test_framebuf.py +++ b/py_bind/test/test_framebuf.py @@ -48,7 +48,7 @@ def test_sort_y(self): def test_write_targets(self): """Round-trip test of writing targets.""" targs = read_targets("../../liboptv/tests/testing_fodder/sample_", 42) - targs.write("testing_fodder/round_trip.", 1) + targs.write(b"testing_fodder/round_trip.", 1) tback = read_targets("testing_fodder/round_trip.", 1) self.failUnlessEqual(len(targs), len(tback)) @@ -67,9 +67,9 @@ def tearDown(self): class TestFrame(unittest.TestCase): def test_read_frame(self): """reading a frame""" - targ_files = ["testing_fodder/frame/cam%d." % c for c in xrange(1, 5)] - frm = Frame(4, corres_file_base="testing_fodder/frame/rt_is", - linkage_file_base="testing_fodder/frame/ptv_is", + targ_files = ["testing_fodder/frame/cam%d.".encode() % c for c in range(1, 5)] + frm = Frame(4, corres_file_base=b"testing_fodder/frame/rt_is", + linkage_file_base=b"testing_fodder/frame/ptv_is", target_file_base=targ_files, frame_num=333) pos = frm.positions() diff --git a/py_bind/test/test_orientation.py b/py_bind/test/test_orientation.py index 40e27f57..90ac951c 100644 --- a/py_bind/test/test_orientation.py +++ b/py_bind/test/test_orientation.py @@ -13,10 +13,10 @@ class Test_Orientation(unittest.TestCase): def setUp(self): - self.input_ori_file_name = r'testing_fodder/calibration/cam1.tif.ori' - self.input_add_file_name = r'testing_fodder/calibration/cam2.tif.addpar' - self.control_file_name = r'testing_fodder/control_parameters/control.par' - self.volume_file_name = r'testing_fodder/corresp/criteria.par' + self.input_ori_file_name = b'testing_fodder/calibration/cam1.tif.ori' + self.input_add_file_name = b'testing_fodder/calibration/cam2.tif.addpar' + self.control_file_name = b'testing_fodder/control_parameters/control.par' + self.volume_file_name = b'testing_fodder/corresp/criteria.par' self.calibration = Calibration() self.calibration.from_file( @@ -50,7 +50,7 @@ def test_match_detection_to_ref(self): # create randomized target array indices = range(coords_count) - shuffled_indices = range(coords_count) + shuffled_indices = list(range(coords_count)) while indices == shuffled_indices: random.shuffle(shuffled_indices) @@ -93,8 +93,8 @@ def test_point_positions(self): [17, 42, 0]], dtype=float) num_cams = 4 - ori_tmpl = r'testing_fodder/calibration/sym_cam{cam_num}.tif.ori' - add_file = r'testing_fodder/calibration/cam1.tif.addpar' + ori_tmpl = 'testing_fodder/calibration/sym_cam{cam_num}.tif.ori' + add_file = b'testing_fodder/calibration/cam1.tif.addpar' calibs = [] targs_plain = [] targs_jigged = [] @@ -103,7 +103,7 @@ def test_point_positions(self): # read calibration for each camera from files for cam in range(num_cams): - ori_name = ori_tmpl.format(cam_num=cam + 1) + ori_name = ori_tmpl.format(cam_num=cam + 1).encode() new_cal = Calibration() new_cal.from_file(ori_file=ori_name, add_file=add_file) calibs.append(new_cal) @@ -147,8 +147,8 @@ def test_single_camera_point_positions(self): num_cams = 1 # prepare MultimediaParams - cpar_file = r'testing_fodder/single_cam/parameters/ptv.par' - vpar_file = r'testing_fodder/single_cam/parameters/criteria.par' + cpar_file = b'testing_fodder/single_cam/parameters/ptv.par' + vpar_file = b'testing_fodder/single_cam/parameters/criteria.par' cpar = ControlParams(num_cams) cpar.read_control_par(cpar_file) mult_params = cpar.get_multimedia_params() @@ -156,8 +156,8 @@ def test_single_camera_point_positions(self): vpar = VolumeParams() vpar.read_volume_par(vpar_file) - ori_name = r'testing_fodder/single_cam/calibration/cam_1.tif.ori' - add_name = r'testing_fodder/single_cam/calibration/cam_1.tif.addpar' + ori_name = b'testing_fodder/single_cam/calibration/cam_1.tif.ori' + add_name = b'testing_fodder/single_cam/calibration/cam_1.tif.addpar' calibs = [] @@ -211,8 +211,8 @@ def test_dumbbell(self): [-17.5, 42, 0]], dtype=float) num_cams = 4 - ori_tmpl = r'testing_fodder/dumbbell/cam{cam_num}.tif.ori' - add_file = r'testing_fodder/calibration/cam1.tif.addpar' + ori_tmpl = 'testing_fodder/dumbbell/cam{cam_num}.tif.ori' + add_file = 'testing_fodder/calibration/cam1.tif.addpar' calibs = [] targs_plain = [] @@ -220,10 +220,10 @@ def test_dumbbell(self): for cam in range(num_cams): ori_name = ori_tmpl.format(cam_num=cam + 1) new_cal = Calibration() - new_cal.from_file(ori_file=ori_name, add_file=add_file) + new_cal.from_file(ori_file=ori_name.encode(), add_file=add_file.encode()) calibs.append(new_cal) - for cam_num, cam_cal in enumerate(calibs): + for cam_cal in calibs: new_plain_targ = flat_image_coordinates( points, cam_cal, self.control.get_multimedia_params()) targs_plain.append(new_plain_targ) @@ -251,18 +251,18 @@ class TestGradientDescent(unittest.TestCase): # Based on the C tests in liboptv/tests/check_orientation.c def setUp(self): - control_file_name = r'testing_fodder/corresp/control.par' + control_file_name = b'testing_fodder/corresp/control.par' self.control = ControlParams(4) self.control.read_control_par(control_file_name) self.cal = Calibration() self.cal.from_file( - "testing_fodder/calibration/cam1.tif.ori", - "testing_fodder/calibration/cam1.tif.addpar") + b"testing_fodder/calibration/cam1.tif.ori", + b"testing_fodder/calibration/cam1.tif.addpar") self.orig_cal = Calibration() self.orig_cal.from_file( - "testing_fodder/calibration/cam1.tif.ori", - "testing_fodder/calibration/cam1.tif.addpar") + b"testing_fodder/calibration/cam1.tif.ori", + b"testing_fodder/calibration/cam1.tif.addpar") def test_external_calibration(self): """External calibration using clicked points.""" @@ -300,7 +300,7 @@ def test_full_calibration(self): # Full calibration works with TargetArray objects, not NumPy. target_array = TargetArray(len(targets)) - for i in xrange(len(targets)): + for i in range(len(targets)): target_array[i].set_pnr(i) target_array[i].set_pos(targets[i]) @@ -308,7 +308,7 @@ def test_full_calibration(self): self.cal.set_pos(self.cal.get_pos() + np.r_[15., -15., 15.]) self.cal.set_angles(self.cal.get_angles() + np.r_[-.5, .5, -.5]) - ret, used, err_est = full_calibration( + _, _, _ = full_calibration( self.cal, ref_pts, target_array, self.control) np.testing.assert_array_almost_equal( diff --git a/py_bind/test/test_parameters_bindings.py b/py_bind/test/test_parameters_bindings.py index ab6b1bea..9098adcd 100644 --- a/py_bind/test/test_parameters_bindings.py +++ b/py_bind/test/test_parameters_bindings.py @@ -39,7 +39,7 @@ def test_mm_np_instantiation(self): class Test_TrackingParams(unittest.TestCase): def setUp(self): - self.input_tracking_par_file_name = "testing_fodder/tracking_parameters/track.par" + self.input_tracking_par_file_name = b"testing_fodder/tracking_parameters/track.par" # create an instance of TrackingParams class # testing setters that are used in constructor @@ -101,7 +101,7 @@ def test_comparison(self): class Test_SequenceParams(unittest.TestCase): def setUp(self): - self.input_sequence_par_file_name = "testing_fodder/sequence_parameters/sequence.par" + self.input_sequence_par_file_name = b"testing_fodder/sequence_parameters/sequence.par" # create an instance of SequencParams class self.seq_obj = SequenceParams(num_cams=4) @@ -111,10 +111,10 @@ def test_read_sequence(self): self.seq_obj.read_sequence_par(self.input_sequence_par_file_name, 4) # check that all parameters are equal to the contents of test file - self.failUnless(self.seq_obj.get_img_base_name(0) == "dumbbell/cam1_Scene77_") - self.failUnless(self.seq_obj.get_img_base_name(1) == "dumbbell/cam2_Scene77_") - self.failUnless(self.seq_obj.get_img_base_name(2) == "dumbbell/cam3_Scene77_") - self.failUnless(self.seq_obj.get_img_base_name(3) == "dumbbell/cam4_Scene77_") + self.failUnless(self.seq_obj.get_img_base_name(0) == b"dumbbell/cam1_Scene77_") + self.failUnless(self.seq_obj.get_img_base_name(1) == b"dumbbell/cam2_Scene77_") + self.failUnless(self.seq_obj.get_img_base_name(2) == b"dumbbell/cam3_Scene77_") + self.failUnless(self.seq_obj.get_img_base_name(3) == b"dumbbell/cam4_Scene77_") self.failUnless(self.seq_obj.get_first() == 497) self.failUnless(self.seq_obj.get_last() == 597) @@ -123,7 +123,7 @@ def test_getters_setters(self): for cam in range(cams_num): newStr = str(cam) + "some string" + str(cam) self.seq_obj.set_img_base_name(cam, newStr) - self.failUnless(self.seq_obj.get_img_base_name(cam) == newStr) + self.failUnless(self.seq_obj.get_img_base_name(cam) == newStr.encode()) self.seq_obj.set_first(1234) self.failUnless(self.seq_obj.get_first() == 1234) @@ -152,15 +152,17 @@ def test_full_instantiate(self): """Instantiate a SequenceParams object from keywords.""" spar = SequenceParams( image_base=['test1', 'test2'], frame_range=(1, 100)) - self.failUnless(spar.get_img_base_name(0) == "test1") - self.failUnless(spar.get_img_base_name(1) == "test2") + + print(spar.get_img_base_name(0)) + self.failUnless(spar.get_img_base_name(0) == b"test1") + self.failUnless(spar.get_img_base_name(1) == b"test2") self.failUnless(spar.get_first() == 1) self.failUnless(spar.get_last() == 100) class Test_VolumeParams(unittest.TestCase): def setUp(self): - self.input_volume_par_file_name = "testing_fodder/volume_parameters/volume.par" - self.temp_output_directory = "testing_fodder/volume_parameters/testing_output" + self.input_volume_par_file_name = b"testing_fodder/volume_parameters/volume.par" + self.temp_output_directory = b"testing_fodder/volume_parameters/testing_output" # create a temporary output directory (will be deleted by the end of test) if not os.path.exists(self.temp_output_directory): @@ -259,8 +261,8 @@ def tearDown(self): class Test_ControlParams(unittest.TestCase): def setUp(self): - self.input_control_par_file_name = "testing_fodder/control_parameters/control.par" - self.temp_output_directory = "testing_fodder/control_parameters/testing_output" + self.input_control_par_file_name = b"testing_fodder/control_parameters/control.par" + self.temp_output_directory = b"testing_fodder/control_parameters/testing_output" # create a temporary output directory (will be deleted by the end of test) if not os.path.exists(self.temp_output_directory): @@ -272,15 +274,15 @@ def test_read_control(self): # Fill the ControlParams object with parameters from test file self.cp_obj.read_control_par(self.input_control_par_file_name) # check if all parameters are equal to the contents of test file - self.failUnless(self.cp_obj.get_img_base_name(0) == "dumbbell/cam1_Scene77_4085") - self.failUnless(self.cp_obj.get_img_base_name(1) == "dumbbell/cam2_Scene77_4085") - self.failUnless(self.cp_obj.get_img_base_name(2) == "dumbbell/cam3_Scene77_4085") - self.failUnless(self.cp_obj.get_img_base_name(3) == "dumbbell/cam4_Scene77_4085") + self.failUnless(self.cp_obj.get_img_base_name(0) == b"dumbbell/cam1_Scene77_4085") + self.failUnless(self.cp_obj.get_img_base_name(1) == b"dumbbell/cam2_Scene77_4085") + self.failUnless(self.cp_obj.get_img_base_name(2) == b"dumbbell/cam3_Scene77_4085") + self.failUnless(self.cp_obj.get_img_base_name(3) == b"dumbbell/cam4_Scene77_4085") - self.failUnless(self.cp_obj.get_cal_img_base_name(0) == "cal/cam1.tif") - self.failUnless(self.cp_obj.get_cal_img_base_name(1) == "cal/cam2.tif") - self.failUnless(self.cp_obj.get_cal_img_base_name(2) == "cal/cam3.tif") - self.failUnless(self.cp_obj.get_cal_img_base_name(3) == "cal/cam4.tif") + self.failUnless(self.cp_obj.get_cal_img_base_name(0) == b"cal/cam1.tif") + self.failUnless(self.cp_obj.get_cal_img_base_name(1) == b"cal/cam2.tif") + self.failUnless(self.cp_obj.get_cal_img_base_name(2) == b"cal/cam3.tif") + self.failUnless(self.cp_obj.get_cal_img_base_name(3) == b"cal/cam4.tif") self.failUnless(self.cp_obj.get_num_cams() == 4) self.failUnless(self.cp_obj.get_hp_flag()) @@ -321,10 +323,10 @@ def test_getters_setters(self): new_str = str(cam) + "some string" + str(cam) self.cp_obj.set_img_base_name(cam, new_str) - self.failUnless(self.cp_obj.get_img_base_name(cam) == new_str) + self.failUnless(self.cp_obj.get_img_base_name(cam) == new_str.encode()) self.cp_obj.set_cal_img_base_name(cam, new_str) - self.failUnless(self.cp_obj.get_cal_img_base_name(cam) == new_str) + self.failUnless(self.cp_obj.get_cal_img_base_name(cam) == new_str.encode()) self.cp_obj.set_hp_flag(True) self.failUnless(self.cp_obj.get_hp_flag()) @@ -343,7 +345,7 @@ def test_getters_setters(self): self.cp_obj.set_image_size((4, 5)) self.failUnless(self.cp_obj.get_image_size()== (4, 5)) - print self.cp_obj.get_pixel_size() + print(self.cp_obj.get_pixel_size()) self.cp_obj.set_pixel_size((6.1, 7.0)) numpy.testing.assert_array_equal(self.cp_obj.get_pixel_size(), (6.1, 7)) @@ -374,7 +376,7 @@ def tearDown(self): class TestTargetParams(unittest.TestCase): def test_read(self): - inp_filename = "testing_fodder/target_parameters/targ_rec.par" + inp_filename = b"testing_fodder/target_parameters/targ_rec.par" tp = TargetParams() tp.read(inp_filename) diff --git a/py_bind/test/test_tracker.py b/py_bind/test/test_tracker.py index 74581e60..0d31debf 100644 --- a/py_bind/test/test_tracker.py +++ b/py_bind/test/test_tracker.py @@ -15,25 +15,26 @@ SequenceParams framebuf_naming = { - 'corres': 'testing_fodder/track/res/particles', - 'linkage': 'testing_fodder/track/res/linkage', - 'prio': 'testing_fodder/track/res/whatever' + 'corres': b'testing_fodder/track/res/particles', + 'linkage': b'testing_fodder/track/res/linkage', + 'prio': b'testing_fodder/track/res/whatever' } class TestTracker(unittest.TestCase): def setUp(self): - with open("testing_fodder/track/conf.yaml") as f: + with open(b"testing_fodder/track/conf.yaml") as f: yaml_conf = yaml.load(f) seq_cfg = yaml_conf['sequence'] cals = [] img_base = [] + print(yaml_conf['cameras']) for cix, cam_spec in enumerate(yaml_conf['cameras']): - cam_spec.setdefault('addpar_file', None) + cam_spec.setdefault(b'addpar_file', None) cal = Calibration() - cal.from_file(cam_spec['ori_file'], cam_spec['addpar_file']) + cal.from_file(cam_spec['ori_file'].encode(), cam_spec['addpar_file'].encode()) cals.append(cal) img_base.append(seq_cfg['targets_template'].format(cam=cix + 1)) - + cpar = ControlParams(len(yaml_conf['cameras']), **yaml_conf['scene']) vpar = VolumeParams(**yaml_conf['correspondences']) tpar = TrackingParams(**yaml_conf['tracking']) diff --git a/py_bind/test/test_trafo_bindings.py b/py_bind/test/test_trafo_bindings.py index 7bdfd771..fd800c27 100644 --- a/py_bind/test/test_trafo_bindings.py +++ b/py_bind/test/test_trafo_bindings.py @@ -10,12 +10,12 @@ class Test_transforms(unittest.TestCase): def setUp(self): - self.input_control_par_file_name = "testing_fodder/control_parameters/control.par" + self.input_control_par_file_name = b"testing_fodder/control_parameters/control.par" self.control = ControlParams(4) self.control.read_control_par(self.input_control_par_file_name) - self.input_ori_file_name = "testing_fodder/calibration/cam1.tif.ori" - self.input_add_file_name = "testing_fodder/calibration/cam2.tif.addpar" + self.input_ori_file_name = b"testing_fodder/calibration/cam1.tif.ori" + self.input_add_file_name = b"testing_fodder/calibration/cam2.tif.addpar" self.calibration = Calibration() self.calibration.from_file(self.input_ori_file_name, self.input_add_file_name)