diff --git a/README.md b/README.md index c050aab..a97e01a 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,19 @@ This package lets you use the ZED stereo camera in Python 3. ### Prerequisites -- [ZED SDK](https://www.stereolabs.com/developers/) and its dependencies +- [ZED SDK 2.2](https://www.stereolabs.com/developers/) and its dependencies ([CUDA](https://developer.nvidia.com/cuda-downloads)) - Python 3.5+ (x64). ([Windows installer](https://www.python.org/ftp/python/3.6.2/python-3.6.2-amd64.exe)) - C++ compiler (VS2015 recommended) - [Cython 0.26](http://cython.org/#download) - [Numpy 1.13.1](https://www.scipy.org/scipylib/download.html) +Please check your python version with the following command. The result should be 3.5 or higer, check the tutorial [here](https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux) to manage multiple python versions on Linux. +``` +python --version +``` +**Note:** On Linux the version returned by `python --version` and `sudo python --version` might not be the same. + Cython and Numpy can be installed via pip. ``` python -m pip install cython numpy diff --git a/examples/live_camera.py b/examples/live_camera.py index 4b27b4d..a7d41d2 100644 --- a/examples/live_camera.py +++ b/examples/live_camera.py @@ -55,7 +55,7 @@ def main(): while key != 113: # for 'q' key err = cam.grab(runtime) if err == tp.PyERROR_CODE.PySUCCESS: - cam.retrieve_image(mat) + cam.retrieve_image(mat, sl.PyVIEW.PyVIEW_LEFT) cv2.imshow("ZED", mat.get_data()) key = cv2.waitKey(5) settings(key, cam, runtime, mat) diff --git a/examples/read_svo.py b/examples/read_svo.py index b6fc94e..419077d 100644 --- a/examples/read_svo.py +++ b/examples/read_svo.py @@ -39,7 +39,7 @@ def main(): filepath = sys.argv[1] print("Reading SVO file: {0}".format(filepath)) - init = zcam.PyInitParameters(svo_input_filename=filepath) + init = zcam.PyInitParameters(svo_input_filename=filepath,svo_real_time_mode=False) cam = zcam.PyZEDCamera() status = cam.open(init) if status != tp.PyERROR_CODE.PySUCCESS: diff --git a/pyzed/Utils.cpp b/pyzed/Utils.cpp index cf09043..ee65370 100644 --- a/pyzed/Utils.cpp +++ b/pyzed/Utils.cpp @@ -171,9 +171,8 @@ namespace sl { return saveDepthAs(depth, format, name, factor); } - bool saveMatPointCloudAs(sl::Mat &cloud, sl::POINT_CLOUD_FORMAT format, sl::String name, bool with_color = false, bool keep_occluded_point = false) { - return savePointCloudAs(cloud, format, name, with_color, keep_occluded_point); - + bool saveMatPointCloudAs(sl::Mat &cloud, sl::POINT_CLOUD_FORMAT format, sl::String name, bool with_color = false) { + return savePointCloudAs(cloud, format, name, with_color); } } diff --git a/pyzed/camera.pxd b/pyzed/camera.pxd index f77d081..3c7a6ea 100644 --- a/pyzed/camera.pxd +++ b/pyzed/camera.pxd @@ -31,16 +31,16 @@ cimport pyzed.mesh as mesh cdef extern from 'sl/Camera.hpp' namespace 'sl': - ctypedef enum RESOLUTION 'sl::SpatialMappingParameters::RESOLUTION': - RESOLUTION_HIGH 'sl::SpatialMappingParameters::RESOLUTION::RESOLUTION_HIGH' - RESOLUTION_MEDIUM 'sl::SpatialMappingParameters::RESOLUTION::RESOLUTION_MEDIUM' - RESOLUTION_LOW 'sl::SpatialMappingParameters::RESOLUTION::RESOLUTION_LOW' + ctypedef enum MAPPING_RESOLUTION 'sl::SpatialMappingParameters::MAPPING_RESOLUTION': + MAPPING_RESOLUTION_HIGH 'sl::SpatialMappingParameters::MAPPING_RESOLUTION::MAPPING_RESOLUTION_HIGH' + MAPPING_RESOLUTION_MEDIUM 'sl::SpatialMappingParameters::MAPPING_RESOLUTION::MAPPING_RESOLUTION_MEDIUM' + MAPPING_RESOLUTION_LOW 'sl::SpatialMappingParameters::MAPPING_RESOLUTION::MAPPING_RESOLUTION_LOW' - ctypedef enum RANGE 'sl::SpatialMappingParameters::RANGE': - RANGE_NEAR 'sl::SpatialMappingParameters::RANGE::RANGE_NEAR' - RANGE_MEDIUM 'sl::SpatialMappingParameters::RANGE::RANGE_MEDIUM' - RANGE_FAR 'sl::SpatialMappingParameters::RANGE::RANGE_FAR' + ctypedef enum MAPPING_RANGE 'sl::SpatialMappingParameters::MAPPING_RANGE': + MAPPING_RANGE_NEAR 'sl::SpatialMappingParameters::MAPPING_RANGE::MAPPING_RANGE_NEAR' + MAPPING_RANGE_MEDIUM 'sl::SpatialMappingParameters::MAPPING_RANGE::MAPPING_RANGE_MEDIUM' + MAPPING_RANGE_FAR 'sl::SpatialMappingParameters::MAPPING_RANGE::MAPPING_RANGE_FAR' cdef cppclass InitParameters 'sl::InitParameters': @@ -116,31 +116,30 @@ cdef extern from 'sl/Camera.hpp' namespace 'sl': cdef cppclass SpatialMappingParameters 'sl::SpatialMappingParameters': ctypedef pair[float, float] interval - SpatialMappingParameters(RESOLUTION resolution, - RANGE range, + SpatialMappingParameters(MAPPING_RESOLUTION resolution, + MAPPING_RANGE range, int max_memory_usage_, bool save_texture_, - bool keep_mesh_consistent_, - bool inverse_triangle_vertices_order_) + bool use_chunk_only_, + bool reverse_vertex_order_) @staticmethod - float get(RESOLUTION resolution) + float get(MAPPING_RESOLUTION resolution) - void set(RESOLUTION resolution) + void set(MAPPING_RESOLUTION resolution) @staticmethod - float get(RANGE range) + float get(MAPPING_RANGE range) - void set(RANGE range) + void set(MAPPING_RANGE range) int max_memory_usage bool save_texture - bool keep_mesh_consistent - bool inverse_triangle_vertices_order + bool use_chunk_only + bool reverse_vertex_order - const interval allowed_min - const interval allowed_max - interval range_meter + const interval allowed_range + float range_meter const interval allowed_resolution float resolution_meter @@ -226,13 +225,13 @@ cdef extern from 'sl/Camera.hpp' namespace 'sl': bool saveDepthAs(Camera &zed, defines.DEPTH_FORMAT format, types.String name, float factor) bool savePointCloudAs(Camera &zed, defines.POINT_CLOUD_FORMAT format, types.String name, - bool with_color, bool keep_occluded_point) + bool with_color) cdef extern from "Utils.cpp" namespace "sl": bool saveMatDepthAs(core.Mat &depth, defines.DEPTH_FORMAT format, types.String name, float factor) bool saveMatPointCloudAs(core.Mat &cloud, defines.POINT_CLOUD_FORMAT format, types.String name, - bool with_color, bool keep_occluded_point) + bool with_color) cdef class PyZEDCamera: diff --git a/pyzed/camera.pyx b/pyzed/camera.pyx index 4ac9071..96b9091 100644 --- a/pyzed/camera.pyx +++ b/pyzed/camera.pyx @@ -34,15 +34,15 @@ import pyzed.types as types class PyRESOLUTION(enum.Enum): - PyRESOLUTION_HIGH = RESOLUTION_HIGH - PyRESOLUTION_MEDIUM = RESOLUTION_MEDIUM - PyRESOLUTION_LOW = RESOLUTION_LOW + PyRESOLUTION_HIGH = MAPPING_RESOLUTION_HIGH + PyRESOLUTION_MEDIUM = MAPPING_RESOLUTION_MEDIUM + PyRESOLUTION_LOW = MAPPING_RESOLUTION_LOW class PyRANGE(enum.Enum): - PyRANGE_NEAR = RANGE_NEAR - PyRANGE_MEDIUM = RANGE_MEDIUM - PyRANGE_FAR = RANGE_FAR + PyRANGE_NEAR = MAPPING_RANGE_NEAR + PyRANGE_MEDIUM = MAPPING_RANGE_MEDIUM + PyRANGE_FAR = MAPPING_RANGE_FAR cdef class PyInitParameters: @@ -341,36 +341,36 @@ cdef class PyTrackingParameters: cdef class PySpatialMappingParameters: cdef SpatialMappingParameters* spatial def __cinit__(self, resolution=PyRESOLUTION.PyRESOLUTION_HIGH, range=PyRANGE.PyRANGE_MEDIUM, - max_memory_usage=2048, save_texture=True, keep_mesh_consistent=True, - inverse_triangle_vertices_order=False): + max_memory_usage=2048, save_texture=True, use_chunk_only=True, + reverse_vertex_order=False): if (isinstance(resolution, PyRESOLUTION) and isinstance(range, PyRANGE) and - isinstance(keep_mesh_consistent, bool) and isinstance(inverse_triangle_vertices_order, bool)): + isinstance(use_chunk_only, bool) and isinstance(reverse_vertex_order, bool)): self.spatial = new SpatialMappingParameters(resolution.value, range.value, max_memory_usage, save_texture, - keep_mesh_consistent, inverse_triangle_vertices_order) + use_chunk_only, reverse_vertex_order) else: raise TypeError() def get_resolution(self, resolution=PyRESOLUTION.PyRESOLUTION_HIGH): if isinstance(resolution, PyRESOLUTION): - return self.spatial.get( resolution.value) + return self.spatial.get( resolution.value) else: raise TypeError("Argument is not of PyRESOLUTION type.") def set_resolution(self, resolution=PyRESOLUTION.PyRESOLUTION_HIGH): if isinstance(resolution, PyRESOLUTION): - self.spatial.set( resolution.value) + self.spatial.set( resolution.value) else: raise TypeError("Argument is not of PyRESOLUTION type.") def get_range(self, range=PyRANGE.PyRANGE_MEDIUM): if isinstance(range, PyRANGE): - return self.spatial.get( range.value) + return self.spatial.get( range.value) else: raise TypeError("Argument is not of PyRANGE type.") def set_range(self, range=PyRANGE.PyRANGE_MEDIUM): if isinstance(range, PyRANGE): - self.spatial.set( range.value) + self.spatial.set( range.value) else: raise TypeError("Argument is not of PyRANGE type.") @@ -391,40 +391,32 @@ cdef class PySpatialMappingParameters: self.spatial.save_texture = value @property - def keep_mesh_consistent(self): - return self.spatial.keep_mesh_consistent + def use_chunk_only(self): + return self.spatial.use_chunk_only - @keep_mesh_consistent.setter - def keep_mesh_consistent(self, bool value): - self.spatial.keep_mesh_consistent = value + @use_chunk_only.setter + def use_chunk_only(self, bool value): + self.spatial.use_chunk_only = value @property - def inverse_triangle_vertices_order(self): - return self.spatial.inverse_triangle_vertices_order + def reverse_vertex_order(self): + return self.spatial.reverse_vertex_order - @inverse_triangle_vertices_order.setter - def inverse_triangle_vertices_order(self, bool value): - self.spatial.inverse_triangle_vertices_order = value + @reverse_vertex_order.setter + def reverse_vertex_order(self, bool value): + self.spatial.reverse_vertex_order = value @property - def allowed_min(self): - return self.spatial.allowed_min - - @property - def allowed_max(self): - return self.spatial.allowed_max + def allowed_range(self): + return self.spatial.allowed_range @property def range_meter(self): return self.spatial.range_meter @range_meter.setter - def range_meter(self, value): - if(self.allowed_min[0] <= value[0] <= self.allowed_min[1] and - self.allowed_max[0] <= value[1] <= self.allowed_max[1]): - self.spatial.range_meter = value - else: - print("Tuple values must fit in min and max allowed intervals.") + def range_meter(self, float value): + self.spatial.range_meter = value @property def allowed_resolution(self): @@ -685,11 +677,11 @@ def save_camera_depth_as(PyZEDCamera zed, format, str name, factor=1): raise TypeError("Arguments must be of PyDEPTH_FORMAT type and factor not over 65536.") -def save_camera_point_cloud_as(PyZEDCamera zed, format, str name, with_color=False, keep_occluded_point=False): +def save_camera_point_cloud_as(PyZEDCamera zed, format, str name, with_color=False): if isinstance(format, defines.PyPOINT_CLOUD_FORMAT): name_save = name.encode() return savePointCloudAs(zed.camera, format.value, types.String(name_save), - with_color, keep_occluded_point) + with_color) else: raise TypeError("Argument is not of PyPOINT_CLOUD_FORMAT type.") @@ -701,10 +693,10 @@ def save_mat_depth_as(core.PyMat py_mat, format, str name, factor=1): raise TypeError("Arguments must be of PyDEPTH_FORMAT type and factor not over 65536.") -def save_mat_point_cloud_as(core.PyMat py_mat, format, str name, with_color=False, keep_occluded_point=False): +def save_mat_point_cloud_as(core.PyMat py_mat, format, str name, with_color=False): if isinstance(format, defines.PyPOINT_CLOUD_FORMAT): name_save = name.encode() return saveMatPointCloudAs(py_mat.mat, format.value, types.String(name_save), - with_color, keep_occluded_point) + with_color) else: raise TypeError("Argument is not of PyPOINT_CLOUD_FORMAT type.") diff --git a/pyzed/core.pxd b/pyzed/core.pxd index 1999090..ccb2190 100644 --- a/pyzed/core.pxd +++ b/pyzed/core.pxd @@ -194,25 +194,6 @@ cdef extern from "sl/Core.hpp" namespace "sl": types.Vector3[float] getEulerAngles(bool radian) const void setEulerAngles(const types.Vector3[float] &euler_angles, bool radian) - cdef cppclass TextureImage 'sl::TextureImage': - - Mat img - Transform path - - TextureImage(Mat &img_, Transform &path_) - void clear() - - - cdef cppclass TextureImagePool 'sl::TextureImagePool': - - TextureImagePool() - vector[TextureImage] v - int size() - void stack(Mat &image, Transform &path); - void concat(const TextureImagePool &that); - TextureImagePool &operator=(const TextureImagePool &that); - void clear() - ctypedef unsigned char uchar1 ctypedef types.Vector2[unsigned char] uchar2 diff --git a/pyzed/core.pyx b/pyzed/core.pyx index 236c406..a0c6453 100644 --- a/pyzed/core.pyx +++ b/pyzed/core.pyx @@ -685,62 +685,4 @@ cdef class PyTransform(types.PyMatrix4f): if isinstance(radian, bool): self.transform.setEulerAngles(types.Vector3[float](input0, input1, input2), radian) else: - raise TypeError("Argument is not of boolean type.") - -cdef class PyTextureImage: - cdef TextureImage* texture_img - def __cinit__(self, PyMat py_mat, PyTransform py_transform): - self.texture_img = new TextureImage(py_mat.mat, py_transform.transform) - - def clear(self): - self.texture_img.clear() - - @property - def img(self): - image = PyMat() - image.mat = self.texture_img.img - return image - - @img.setter - def img(self, PyMat image): - self.texture_img.img = image.mat - - @property - def path(self): - texture_path = PyTransform() - texture_path.transform = self.texture_img.path - return texture_path - - @path.setter - def path(self, PyTransform texture_path): - self.texture_img.path = texture_path.transform - - -cdef class PyTextureImagePool: - cdef TextureImagePool texture_img_pool - def __cinit__(self): - self.texture_img_pool = TextureImagePool() - - def size(self): - return self.texture_img_pool.size() - - def stack(self, PyMat image, PyTransform path): - self.texture_img_pool.stack(image.mat, path.transform) - - def concat(self, PyTextureImagePool that): - self.texture_img_pool.concat(that.texture_img_pool) - - def clear(self): - self.texture_img_pool.clear() - - @property - def v(self): - list = [] - for i in range(self.size()): - img = PyMat() - img.mat = self.texture_img_pool.v[i].img - path = PyTransform() - path.transform = self.texture_img_pool.v[i].path - py_texture_img_pool = PyTextureImage(img, path) - list.append(py_texture_img_pool) - return list + raise TypeError("Argument is not of boolean type.") \ No newline at end of file diff --git a/pyzed/defines.pxd b/pyzed/defines.pxd index 056188a..96292bd 100644 --- a/pyzed/defines.pxd +++ b/pyzed/defines.pxd @@ -20,12 +20,30 @@ # File containing the Cython declarations to use the defines.hpp functions. -from libcpp.string cimport string +from libc.string cimport const_char from libcpp.vector cimport vector from libcpp.pair cimport pair from libcpp cimport bool +cdef extern from "sl/types.hpp" namespace "sl": + ctypedef enum UNIT: + UNIT_MILLIMETER + UNIT_CENTIMETER + UNIT_METER + UNIT_INCH + UNIT_FOOT + UNIT_LAST + + + ctypedef enum COORDINATE_SYSTEM: + COORDINATE_SYSTEM_IMAGE + COORDINATE_SYSTEM_LEFT_HANDED_Y_UP + COORDINATE_SYSTEM_RIGHT_HANDED_Y_UP + COORDINATE_SYSTEM_RIGHT_HANDED_Z_UP + COORDINATE_SYSTEM_LEFT_HANDED_Z_UP + COORDINATE_SYSTEM_LAST + cdef extern from "sl/defines.hpp" namespace "sl": ctypedef enum RESOLUTION: @@ -70,24 +88,6 @@ cdef extern from "sl/defines.hpp" namespace "sl": SENSING_MODE_LAST - ctypedef enum UNIT: - UNIT_MILLIMETER - UNIT_CENTIMETER - UNIT_METER - UNIT_INCH - UNIT_FOOT - UNIT_LAST - - - ctypedef enum COORDINATE_SYSTEM: - COORDINATE_SYSTEM_IMAGE - COORDINATE_SYSTEM_LEFT_HANDED_Y_UP - COORDINATE_SYSTEM_RIGHT_HANDED_Y_UP - COORDINATE_SYSTEM_RIGHT_HANDED_Z_UP - COORDINATE_SYSTEM_LEFT_HANDED_Z_UP - COORDINATE_SYSTEM_LAST - - ctypedef enum MEASURE: MEASURE_DISPARITY MEASURE_DEPTH @@ -194,28 +194,28 @@ cdef extern from "sl/defines.hpp" namespace "sl": cdef vector[pair[int, int]] cameraResolution @staticmethod - cdef string resolution2str(RESOLUTION res) + cdef const_char* resolution2str(RESOLUTION res) @staticmethod - cdef string statusCode2str(SELF_CALIBRATION_STATE state) + cdef const_char* statusCode2str(SELF_CALIBRATION_STATE state) @staticmethod - cdef DEPTH_MODE str2mode(string mode) + cdef DEPTH_MODE str2mode(const_char* mode) @staticmethod - cdef string depthMode2str(DEPTH_MODE mode) + cdef const_char* depthMode2str(DEPTH_MODE mode) @staticmethod - cdef string sensingMode2str(SENSING_MODE mode) + cdef const_char* sensingMode2str(SENSING_MODE mode) @staticmethod - cdef string unit2str(UNIT unit) + cdef const_char* unit2str(UNIT unit) @staticmethod - cdef UNIT str2unit(string unit) + cdef UNIT str2unit(const_char* unit) @staticmethod - cdef string trackingState2str(TRACKING_STATE state) + cdef const_char* trackingState2str(TRACKING_STATE state) @staticmethod - cdef string spatialMappingState2str(SPATIAL_MAPPING_STATE state) + cdef const_char* spatialMappingState2str(SPATIAL_MAPPING_STATE state) diff --git a/pyzed/defines.pyx b/pyzed/defines.pyx index 4357536..290fabc 100644 --- a/pyzed/defines.pyx +++ b/pyzed/defines.pyx @@ -31,10 +31,10 @@ class PyRESOLUTION(enum.Enum): PyRESOLUTION_LAST = RESOLUTION_LAST def __str__(self): - return resolution2str(self.value).decode() + return ( resolution2str(self.value)).decode() def __repr__(self): - return resolution2str(self.value).decode() + return ( resolution2str(self.value)).decode() class PyCAMERA_SETTINGS(enum.Enum): @@ -57,10 +57,10 @@ class PySELF_CALIBRATION_STATE(enum.Enum): PySELF_CALIBRATION_STATE_LAST = SELF_CALIBRATION_STATE_LAST def __str__(self): - return statusCode2str(self.value).decode() + return ( statusCode2str(self.value)).decode() def __repr__(self): - return statusCode2str(self.value).decode() + return ( statusCode2str(self.value)).decode() class PyDEPTH_MODE(enum.Enum): @@ -71,10 +71,10 @@ class PyDEPTH_MODE(enum.Enum): PyDEPTH_MODE_LAST = DEPTH_MODE_LAST def __str__(self): - return depthMode2str(self.value).decode() + return ( depthMode2str(self.value)).decode() def __repr__(self): - return depthMode2str(self.value).decode() + return ( depthMode2str(self.value)).decode() class PySENSING_MODE(enum.Enum): @@ -83,10 +83,10 @@ class PySENSING_MODE(enum.Enum): PySENSING_MODE_LAST = SENSING_MODE_LAST def __str__(self): - return sensingMode2str(self.value).decode() + return ( sensingMode2str(self.value)).decode() def __repr__(self): - return sensingMode2str(self.value).decode() + return ( sensingMode2str(self.value)).decode() class PyUNIT(enum.Enum): @@ -98,10 +98,10 @@ class PyUNIT(enum.Enum): PyUNIT_LAST = UNIT_LAST def __str__(self): - return unit2str(self.value).decode() + return ( unit2str(self.value)).decode() def __repr__(self): - return unit2str(self.value).decode() + return ( unit2str(self.value)).decode() class PyCOORDINATE_SYSTEM(enum.Enum): @@ -175,10 +175,10 @@ class PyTRACKING_STATE(enum.Enum): PyTRACKING_STATE_LAST = TRACKING_STATE_LAST def __str__(self): - return trackingState2str(self.value).decode() + return ( trackingState2str(self.value)).decode() def __repr__(self): - return trackingState2str(self.value).decode() + return ( trackingState2str(self.value)).decode() class PyAREA_EXPORT_STATE(enum.Enum): @@ -206,10 +206,10 @@ class PySPATIAL_MAPPING_STATE(enum.Enum): PySPATIAL_MAPPING_STATE_LAST = SPATIAL_MAPPING_STATE_LAST def __str__(self): - return spatialMappingState2str(self.value).decode() + return ( spatialMappingState2str(self.value)).decode() def __repr__(self): - return spatialMappingState2str(self.value).decode() + return ( spatialMappingState2str(self.value)).decode() class PySVO_COMPRESSION_MODE(enum.Enum): diff --git a/pyzed/mesh.pxd b/pyzed/mesh.pxd index f4a9f9b..0af4710 100644 --- a/pyzed/mesh.pxd +++ b/pyzed/mesh.pxd @@ -45,15 +45,15 @@ cdef extern from "sl/Mesh.hpp" namespace "sl": MESH_TEXTURE_LAST - ctypedef enum FILTER 'sl::MeshFilterParameters::FILTER': - FILTER_LOW 'sl::MeshFilterParameters::FILTER::FILTER_LOW' - FILTER_MEDIUM 'sl::MeshFilterParameters::FILTER::FILTER_MEDIUM' - FILTER_HIGH 'sl::MeshFilterParameters::FILTER::FILTER_HIGH' + ctypedef enum MESH_FILTER 'sl::MeshFilterParameters::MESH_FILTER': + MESH_FILTER_LOW 'sl::MeshFilterParameters::MESH_FILTER::MESH_FILTER_LOW' + MESH_FILTER_MEDIUM 'sl::MeshFilterParameters::MESH_FILTER::MESH_FILTER_MEDIUM' + MESH_FILTER_HIGH 'sl::MeshFilterParameters::MESH_FILTER::MESH_FILTER_HIGH' cdef cppclass MeshFilterParameters 'sl::MeshFilterParameters': - MeshFilterParameters(FILTER filtering_) - void set(FILTER filtering_) + MeshFilterParameters(MESH_FILTER filtering_) + void set(MESH_FILTER filtering_) bool save(types.String filename) bool load(types.String filename) diff --git a/pyzed/mesh.pyx b/pyzed/mesh.pyx index 8672944..46b0abc 100644 --- a/pyzed/mesh.pyx +++ b/pyzed/mesh.pyx @@ -42,22 +42,19 @@ class PyMESH_TEXTURE_FORMAT(enum.Enum): PyMESH_TEXTURE_LAST = MESH_TEXTURE_LAST class PyFILTER(enum.Enum): - PyFILTER_LOW = FILTER_LOW - PyFILTER_MEDIUM = FILTER_MEDIUM - PyFILTER_HIGH = FILTER_HIGH + PyFILTER_LOW = MESH_FILTER_LOW + PyFILTER_MEDIUM = MESH_FILTER_MEDIUM + PyFILTER_HIGH = MESH_FILTER_HIGH cdef class PyMeshFilterParameters: cdef MeshFilterParameters* meshFilter - cdef FILTER filter def __cinit__(self): - self.filter = PyFILTER.PyFILTER_LOW - self.meshFilter = new MeshFilterParameters(PyFILTER.PyFILTER_LOW) + self.meshFilter = new MeshFilterParameters(MESH_FILTER_LOW) def set(self, filter=PyFILTER.PyFILTER_LOW): if isinstance(filter, PyFILTER): - self.filter = filter.value - set(filter.name) + self.meshFilter.set(filter.value) else: raise TypeError("Argument is not of PyFILTER type.") diff --git a/pyzed/types.pxd b/pyzed/types.pxd index e4b310d..f49c594 100644 --- a/pyzed/types.pxd +++ b/pyzed/types.pxd @@ -50,7 +50,7 @@ cdef extern from "sl/types.hpp" namespace "sl": ERROR_CODE_CORRUPTED_SDK_INSTALLATION ERROR_CODE_LAST - string errorCode2str(ERROR_CODE err) + String errorCode2str(ERROR_CODE err) void sleep_ms(int time) diff --git a/pyzed/types.pyx b/pyzed/types.pyx index 7cd1032..b32d7f8 100644 --- a/pyzed/types.pyx +++ b/pyzed/types.pyx @@ -49,10 +49,10 @@ class PyERROR_CODE(enum.Enum): PyERROR_CODE_LAST = ERROR_CODE_LAST def __str__(self): - return errorCode2str(self.value).decode() + return errorCode2str(self.value).get() def __repr__(self): - return errorCode2str(self.value).decode() + return errorCode2str(self.value).get() def c_sleep_ms(int time): diff --git a/setup.py b/setup.py index 7d116ad..3971f65 100644 --- a/setup.py +++ b/setup.py @@ -29,13 +29,39 @@ import os import sys import shutil +import re incDirs = "" libDirs = "" libs = "" cflags = "" - +ZED_SDK_MAJOR="2" +ZED_SDK_MINOR="2" + +def check_zed_sdk_version(file_path): + file_path=file_path+"/sl/defines.hpp" + + with open (file_path, "r") as myfile: + data = myfile.read() + + p = re.compile("ZED_SDK_MAJOR_VERSION (.*)") + major = p.search(data).group(1) + + p = re.compile("ZED_SDK_MINOR_VERSION (.*)") + minor = p.search(data).group(1) + + p = re.compile("ZED_SDK_PATCH_VERSION (.*)") + patch = p.search(data).group(1) + + if major==ZED_SDK_MAJOR and minor>=ZED_SDK_MINOR: + print("ZED SDK Version: OK") + else: + print("WARNING ! Required ZED SDK version: " + ZED_SDK_MAJOR + "." + ZED_SDK_MINOR) + print("ZED SDK detected: " + major + "." + minor + "." + patch) + print("Aborting") + sys.exit(0) + def clean_cpp(): if os.path.isfile("pyzed/camera.cpp"): os.remove("pyzed/camera.cpp") @@ -69,6 +95,7 @@ def clean_cpp(): elif os.getenv("CUDA_PATH") is None: print("Error: you must install Cuda.") else: + check_zed_sdk_version(os.getenv("ZED_INCLUDE_DIRS")) incDirs = [numpy.get_include(), os.getenv("ZED_INCLUDE_DIRS"), os.getenv("CUDA_PATH") + "/include"] @@ -80,14 +107,13 @@ def clean_cpp(): cuda_path = "/usr/local/cuda" if sys.platform == "linux": - zed_path = "/usr/local/zed" if not os.path.isdir(zed_path): print("Error: you must install the ZED SDK.") elif not os.path.isdir(cuda_path): print("Error: you must install Cuda.") else: - + check_zed_sdk_version(zed_path+"/include") incDirs = [numpy.get_include(), zed_path + "/include", cuda_path + "/include"] @@ -150,7 +176,7 @@ def create_extension(name, sources): extensions.extend(extList) setup(name="pyzed", - version="2.1", + version="2.2", author_email="developers@stereolabs.com", description="Use the ZED SDK with Python", packages=py_packages,