Skip to content

Commit a8f2b78

Browse files
committed
Update for ZED SDK 2.2
1 parent 546aef6 commit a8f2b78

File tree

15 files changed

+152
-210
lines changed

15 files changed

+152
-210
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ This package lets you use the ZED stereo camera in Python 3.
99

1010
### Prerequisites
1111

12-
- [ZED SDK](https://www.stereolabs.com/developers/) and its dependencies
12+
- [ZED SDK 2.2](https://www.stereolabs.com/developers/) and its dependencies
1313
([CUDA](https://developer.nvidia.com/cuda-downloads))
1414
- Python 3.5+ (x64). ([Windows installer](https://www.python.org/ftp/python/3.6.2/python-3.6.2-amd64.exe))
1515
- C++ compiler (VS2015 recommended)
1616
- [Cython 0.26](http://cython.org/#download)
1717
- [Numpy 1.13.1](https://www.scipy.org/scipylib/download.html)
1818

19+
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.
20+
```
21+
python --version
22+
```
23+
**Note:** On Linux the version returned by `python --version` and `sudo python --version` might not be the same.
24+
1925
Cython and Numpy can be installed via pip.
2026
```
2127
python -m pip install cython numpy

examples/live_camera.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def main():
5555
while key != 113: # for 'q' key
5656
err = cam.grab(runtime)
5757
if err == tp.PyERROR_CODE.PySUCCESS:
58-
cam.retrieve_image(mat)
58+
cam.retrieve_image(mat, sl.PyVIEW.PyVIEW_LEFT)
5959
cv2.imshow("ZED", mat.get_data())
6060
key = cv2.waitKey(5)
6161
settings(key, cam, runtime, mat)

examples/read_svo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def main():
3939
filepath = sys.argv[1]
4040
print("Reading SVO file: {0}".format(filepath))
4141

42-
init = zcam.PyInitParameters(svo_input_filename=filepath)
42+
init = zcam.PyInitParameters(svo_input_filename=filepath,svo_real_time_mode=False)
4343
cam = zcam.PyZEDCamera()
4444
status = cam.open(init)
4545
if status != tp.PyERROR_CODE.PySUCCESS:

pyzed/Utils.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,8 @@ namespace sl {
171171
return saveDepthAs(depth, format, name, factor);
172172
}
173173

174-
bool saveMatPointCloudAs(sl::Mat &cloud, sl::POINT_CLOUD_FORMAT format, sl::String name, bool with_color = false, bool keep_occluded_point = false) {
175-
return savePointCloudAs(cloud, format, name, with_color, keep_occluded_point);
176-
174+
bool saveMatPointCloudAs(sl::Mat &cloud, sl::POINT_CLOUD_FORMAT format, sl::String name, bool with_color = false) {
175+
return savePointCloudAs(cloud, format, name, with_color);
177176
}
178177

179178
}

pyzed/camera.pxd

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ cimport pyzed.mesh as mesh
3131

3232
cdef extern from 'sl/Camera.hpp' namespace 'sl':
3333

34-
ctypedef enum RESOLUTION 'sl::SpatialMappingParameters::RESOLUTION':
35-
RESOLUTION_HIGH 'sl::SpatialMappingParameters::RESOLUTION::RESOLUTION_HIGH'
36-
RESOLUTION_MEDIUM 'sl::SpatialMappingParameters::RESOLUTION::RESOLUTION_MEDIUM'
37-
RESOLUTION_LOW 'sl::SpatialMappingParameters::RESOLUTION::RESOLUTION_LOW'
34+
ctypedef enum MAPPING_RESOLUTION 'sl::SpatialMappingParameters::MAPPING_RESOLUTION':
35+
MAPPING_RESOLUTION_HIGH 'sl::SpatialMappingParameters::MAPPING_RESOLUTION::MAPPING_RESOLUTION_HIGH'
36+
MAPPING_RESOLUTION_MEDIUM 'sl::SpatialMappingParameters::MAPPING_RESOLUTION::MAPPING_RESOLUTION_MEDIUM'
37+
MAPPING_RESOLUTION_LOW 'sl::SpatialMappingParameters::MAPPING_RESOLUTION::MAPPING_RESOLUTION_LOW'
3838

3939

40-
ctypedef enum RANGE 'sl::SpatialMappingParameters::RANGE':
41-
RANGE_NEAR 'sl::SpatialMappingParameters::RANGE::RANGE_NEAR'
42-
RANGE_MEDIUM 'sl::SpatialMappingParameters::RANGE::RANGE_MEDIUM'
43-
RANGE_FAR 'sl::SpatialMappingParameters::RANGE::RANGE_FAR'
40+
ctypedef enum MAPPING_RANGE 'sl::SpatialMappingParameters::MAPPING_RANGE':
41+
MAPPING_RANGE_NEAR 'sl::SpatialMappingParameters::MAPPING_RANGE::MAPPING_RANGE_NEAR'
42+
MAPPING_RANGE_MEDIUM 'sl::SpatialMappingParameters::MAPPING_RANGE::MAPPING_RANGE_MEDIUM'
43+
MAPPING_RANGE_FAR 'sl::SpatialMappingParameters::MAPPING_RANGE::MAPPING_RANGE_FAR'
4444

4545

4646
cdef cppclass InitParameters 'sl::InitParameters':
@@ -116,31 +116,30 @@ cdef extern from 'sl/Camera.hpp' namespace 'sl':
116116
cdef cppclass SpatialMappingParameters 'sl::SpatialMappingParameters':
117117
ctypedef pair[float, float] interval
118118

119-
SpatialMappingParameters(RESOLUTION resolution,
120-
RANGE range,
119+
SpatialMappingParameters(MAPPING_RESOLUTION resolution,
120+
MAPPING_RANGE range,
121121
int max_memory_usage_,
122122
bool save_texture_,
123-
bool keep_mesh_consistent_,
124-
bool inverse_triangle_vertices_order_)
123+
bool use_chunk_only_,
124+
bool reverse_vertex_order_)
125125

126126
@staticmethod
127-
float get(RESOLUTION resolution)
127+
float get(MAPPING_RESOLUTION resolution)
128128

129-
void set(RESOLUTION resolution)
129+
void set(MAPPING_RESOLUTION resolution)
130130

131131
@staticmethod
132-
float get(RANGE range)
132+
float get(MAPPING_RANGE range)
133133

134-
void set(RANGE range)
134+
void set(MAPPING_RANGE range)
135135

136136
int max_memory_usage
137137
bool save_texture
138-
bool keep_mesh_consistent
139-
bool inverse_triangle_vertices_order
138+
bool use_chunk_only
139+
bool reverse_vertex_order
140140

141-
const interval allowed_min
142-
const interval allowed_max
143-
interval range_meter
141+
const interval allowed_range
142+
float range_meter
144143
const interval allowed_resolution
145144
float resolution_meter
146145

@@ -226,13 +225,13 @@ cdef extern from 'sl/Camera.hpp' namespace 'sl':
226225

227226
bool saveDepthAs(Camera &zed, defines.DEPTH_FORMAT format, types.String name, float factor)
228227
bool savePointCloudAs(Camera &zed, defines.POINT_CLOUD_FORMAT format, types.String name,
229-
bool with_color, bool keep_occluded_point)
228+
bool with_color)
230229

231230

232231
cdef extern from "Utils.cpp" namespace "sl":
233232
bool saveMatDepthAs(core.Mat &depth, defines.DEPTH_FORMAT format, types.String name, float factor)
234233
bool saveMatPointCloudAs(core.Mat &cloud, defines.POINT_CLOUD_FORMAT format, types.String name,
235-
bool with_color, bool keep_occluded_point)
234+
bool with_color)
236235

237236

238237
cdef class PyZEDCamera:

pyzed/camera.pyx

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ import pyzed.types as types
3434

3535

3636
class PyRESOLUTION(enum.Enum):
37-
PyRESOLUTION_HIGH = RESOLUTION_HIGH
38-
PyRESOLUTION_MEDIUM = RESOLUTION_MEDIUM
39-
PyRESOLUTION_LOW = RESOLUTION_LOW
37+
PyRESOLUTION_HIGH = MAPPING_RESOLUTION_HIGH
38+
PyRESOLUTION_MEDIUM = MAPPING_RESOLUTION_MEDIUM
39+
PyRESOLUTION_LOW = MAPPING_RESOLUTION_LOW
4040

4141

4242
class PyRANGE(enum.Enum):
43-
PyRANGE_NEAR = RANGE_NEAR
44-
PyRANGE_MEDIUM = RANGE_MEDIUM
45-
PyRANGE_FAR = RANGE_FAR
43+
PyRANGE_NEAR = MAPPING_RANGE_NEAR
44+
PyRANGE_MEDIUM = MAPPING_RANGE_MEDIUM
45+
PyRANGE_FAR = MAPPING_RANGE_FAR
4646

4747

4848
cdef class PyInitParameters:
@@ -341,36 +341,36 @@ cdef class PyTrackingParameters:
341341
cdef class PySpatialMappingParameters:
342342
cdef SpatialMappingParameters* spatial
343343
def __cinit__(self, resolution=PyRESOLUTION.PyRESOLUTION_HIGH, range=PyRANGE.PyRANGE_MEDIUM,
344-
max_memory_usage=2048, save_texture=True, keep_mesh_consistent=True,
345-
inverse_triangle_vertices_order=False):
344+
max_memory_usage=2048, save_texture=True, use_chunk_only=True,
345+
reverse_vertex_order=False):
346346
if (isinstance(resolution, PyRESOLUTION) and isinstance(range, PyRANGE) and
347-
isinstance(keep_mesh_consistent, bool) and isinstance(inverse_triangle_vertices_order, bool)):
347+
isinstance(use_chunk_only, bool) and isinstance(reverse_vertex_order, bool)):
348348
self.spatial = new SpatialMappingParameters(resolution.value, range.value, max_memory_usage, save_texture,
349-
keep_mesh_consistent, inverse_triangle_vertices_order)
349+
use_chunk_only, reverse_vertex_order)
350350
else:
351351
raise TypeError()
352352

353353
def get_resolution(self, resolution=PyRESOLUTION.PyRESOLUTION_HIGH):
354354
if isinstance(resolution, PyRESOLUTION):
355-
return self.spatial.get(<RESOLUTION> resolution.value)
355+
return self.spatial.get(<MAPPING_RESOLUTION> resolution.value)
356356
else:
357357
raise TypeError("Argument is not of PyRESOLUTION type.")
358358

359359
def set_resolution(self, resolution=PyRESOLUTION.PyRESOLUTION_HIGH):
360360
if isinstance(resolution, PyRESOLUTION):
361-
self.spatial.set(<RESOLUTION> resolution.value)
361+
self.spatial.set(<MAPPING_RESOLUTION> resolution.value)
362362
else:
363363
raise TypeError("Argument is not of PyRESOLUTION type.")
364364

365365
def get_range(self, range=PyRANGE.PyRANGE_MEDIUM):
366366
if isinstance(range, PyRANGE):
367-
return self.spatial.get(<RANGE> range.value)
367+
return self.spatial.get(<MAPPING_RANGE> range.value)
368368
else:
369369
raise TypeError("Argument is not of PyRANGE type.")
370370

371371
def set_range(self, range=PyRANGE.PyRANGE_MEDIUM):
372372
if isinstance(range, PyRANGE):
373-
self.spatial.set(<RANGE> range.value)
373+
self.spatial.set(<MAPPING_RANGE> range.value)
374374
else:
375375
raise TypeError("Argument is not of PyRANGE type.")
376376

@@ -391,40 +391,32 @@ cdef class PySpatialMappingParameters:
391391
self.spatial.save_texture = value
392392

393393
@property
394-
def keep_mesh_consistent(self):
395-
return self.spatial.keep_mesh_consistent
394+
def use_chunk_only(self):
395+
return self.spatial.use_chunk_only
396396

397-
@keep_mesh_consistent.setter
398-
def keep_mesh_consistent(self, bool value):
399-
self.spatial.keep_mesh_consistent = value
397+
@use_chunk_only.setter
398+
def use_chunk_only(self, bool value):
399+
self.spatial.use_chunk_only = value
400400

401401
@property
402-
def inverse_triangle_vertices_order(self):
403-
return self.spatial.inverse_triangle_vertices_order
402+
def reverse_vertex_order(self):
403+
return self.spatial.reverse_vertex_order
404404

405-
@inverse_triangle_vertices_order.setter
406-
def inverse_triangle_vertices_order(self, bool value):
407-
self.spatial.inverse_triangle_vertices_order = value
405+
@reverse_vertex_order.setter
406+
def reverse_vertex_order(self, bool value):
407+
self.spatial.reverse_vertex_order = value
408408

409409
@property
410-
def allowed_min(self):
411-
return self.spatial.allowed_min
412-
413-
@property
414-
def allowed_max(self):
415-
return self.spatial.allowed_max
410+
def allowed_range(self):
411+
return self.spatial.allowed_range
416412

417413
@property
418414
def range_meter(self):
419415
return self.spatial.range_meter
420416

421417
@range_meter.setter
422-
def range_meter(self, value):
423-
if(self.allowed_min[0] <= value[0] <= self.allowed_min[1] and
424-
self.allowed_max[0] <= value[1] <= self.allowed_max[1]):
425-
self.spatial.range_meter = value
426-
else:
427-
print("Tuple values must fit in min and max allowed intervals.")
418+
def range_meter(self, float value):
419+
self.spatial.range_meter = value
428420

429421
@property
430422
def allowed_resolution(self):
@@ -685,11 +677,11 @@ def save_camera_depth_as(PyZEDCamera zed, format, str name, factor=1):
685677
raise TypeError("Arguments must be of PyDEPTH_FORMAT type and factor not over 65536.")
686678

687679

688-
def save_camera_point_cloud_as(PyZEDCamera zed, format, str name, with_color=False, keep_occluded_point=False):
680+
def save_camera_point_cloud_as(PyZEDCamera zed, format, str name, with_color=False):
689681
if isinstance(format, defines.PyPOINT_CLOUD_FORMAT):
690682
name_save = name.encode()
691683
return savePointCloudAs(zed.camera, format.value, types.String(<char*>name_save),
692-
with_color, keep_occluded_point)
684+
with_color)
693685
else:
694686
raise TypeError("Argument is not of PyPOINT_CLOUD_FORMAT type.")
695687

@@ -701,10 +693,10 @@ def save_mat_depth_as(core.PyMat py_mat, format, str name, factor=1):
701693
raise TypeError("Arguments must be of PyDEPTH_FORMAT type and factor not over 65536.")
702694

703695

704-
def save_mat_point_cloud_as(core.PyMat py_mat, format, str name, with_color=False, keep_occluded_point=False):
696+
def save_mat_point_cloud_as(core.PyMat py_mat, format, str name, with_color=False):
705697
if isinstance(format, defines.PyPOINT_CLOUD_FORMAT):
706698
name_save = name.encode()
707699
return saveMatPointCloudAs(py_mat.mat, format.value, types.String(<char*>name_save),
708-
with_color, keep_occluded_point)
700+
with_color)
709701
else:
710702
raise TypeError("Argument is not of PyPOINT_CLOUD_FORMAT type.")

pyzed/core.pxd

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -194,25 +194,6 @@ cdef extern from "sl/Core.hpp" namespace "sl":
194194
types.Vector3[float] getEulerAngles(bool radian) const
195195
void setEulerAngles(const types.Vector3[float] &euler_angles, bool radian)
196196

197-
cdef cppclass TextureImage 'sl::TextureImage':
198-
199-
Mat img
200-
Transform path
201-
202-
TextureImage(Mat &img_, Transform &path_)
203-
void clear()
204-
205-
206-
cdef cppclass TextureImagePool 'sl::TextureImagePool':
207-
208-
TextureImagePool()
209-
vector[TextureImage] v
210-
int size()
211-
void stack(Mat &image, Transform &path);
212-
void concat(const TextureImagePool &that);
213-
TextureImagePool &operator=(const TextureImagePool &that);
214-
void clear()
215-
216197

217198
ctypedef unsigned char uchar1
218199
ctypedef types.Vector2[unsigned char] uchar2

pyzed/core.pyx

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -685,62 +685,4 @@ cdef class PyTransform(types.PyMatrix4f):
685685
if isinstance(radian, bool):
686686
self.transform.setEulerAngles(types.Vector3[float](input0, input1, input2), radian)
687687
else:
688-
raise TypeError("Argument is not of boolean type.")
689-
690-
cdef class PyTextureImage:
691-
cdef TextureImage* texture_img
692-
def __cinit__(self, PyMat py_mat, PyTransform py_transform):
693-
self.texture_img = new TextureImage(py_mat.mat, py_transform.transform)
694-
695-
def clear(self):
696-
self.texture_img.clear()
697-
698-
@property
699-
def img(self):
700-
image = PyMat()
701-
image.mat = self.texture_img.img
702-
return image
703-
704-
@img.setter
705-
def img(self, PyMat image):
706-
self.texture_img.img = image.mat
707-
708-
@property
709-
def path(self):
710-
texture_path = PyTransform()
711-
texture_path.transform = self.texture_img.path
712-
return texture_path
713-
714-
@path.setter
715-
def path(self, PyTransform texture_path):
716-
self.texture_img.path = texture_path.transform
717-
718-
719-
cdef class PyTextureImagePool:
720-
cdef TextureImagePool texture_img_pool
721-
def __cinit__(self):
722-
self.texture_img_pool = TextureImagePool()
723-
724-
def size(self):
725-
return self.texture_img_pool.size()
726-
727-
def stack(self, PyMat image, PyTransform path):
728-
self.texture_img_pool.stack(image.mat, path.transform)
729-
730-
def concat(self, PyTextureImagePool that):
731-
self.texture_img_pool.concat(that.texture_img_pool)
732-
733-
def clear(self):
734-
self.texture_img_pool.clear()
735-
736-
@property
737-
def v(self):
738-
list = []
739-
for i in range(self.size()):
740-
img = PyMat()
741-
img.mat = self.texture_img_pool.v[i].img
742-
path = PyTransform()
743-
path.transform = self.texture_img_pool.v[i].path
744-
py_texture_img_pool = PyTextureImage(img, path)
745-
list.append(py_texture_img_pool)
746-
return list
688+
raise TypeError("Argument is not of boolean type.")

0 commit comments

Comments
 (0)