Skip to content

Commit

Permalink
Update for ZED SDK 2.8 (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
adujardin authored Apr 19, 2019
1 parent 4103b75 commit 50cdaba
Show file tree
Hide file tree
Showing 8 changed files with 548 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The changes were made to better reflect the C++ API and ease of use. Mainly all

### Prerequisites

- [ZED SDK 2.7](https://www.stereolabs.com/developers/) and its dependency
- [ZED SDK 2.8](https://www.stereolabs.com/developers/) and its dependency
[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)
Expand Down
13 changes: 13 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ Plane sample is searching for the floor in a video and extracts it into a mesh i
```
python examples/plane_example.py svo_file.svo
```

### Streaming

These 2 samples show the local network streaming capabilities of the SDK. The sender is opening the camera and transmitting the images.
The receiver opens the network image stream and display the images.

```
python examples/camera_streaming/sender/streaming_sender.py
```

```
python examples/camera_streaming/receiver/streaming_receiver.py 127.0.0.1
```
66 changes: 66 additions & 0 deletions examples/camera_streaming/receiver/streaming_receiver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
########################################################################
#
# Copyright (c) 2017, STEREOLABS.
#
# All rights reserved.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
########################################################################

"""
Read SVO sample to read the video and the information of the camera. It can pick a frame of the svo and save it as
a JPEG or PNG file. Depth map and Point Cloud can also be saved into files.
"""
import sys
import pyzed.sl as sl
import cv2


def main():

init = sl.InitParameters()
init.camera_resolution = sl.RESOLUTION.RESOLUTION_HD720
init.depth_mode = sl.DEPTH_MODE.DEPTH_MODE_PERFORMANCE

if (len(sys.argv) > 1) :
ip = sys.argv[1]
init.set_from_stream(ip)
else :
print('Usage : python3 streaming_receiver.py ip')
exit(1)

cam = sl.Camera()
status = cam.open(init)
if status != sl.ERROR_CODE.SUCCESS:
print(repr(status))
exit(1)

runtime = sl.RuntimeParameters()
mat = sl.Mat()

key = ''
print(" Quit : CTRL+C\n")
while key != 113:
err = cam.grab(runtime)
if (err == sl.ERROR_CODE.SUCCESS) :
cam.retrieve_image(mat, sl.VIEW.VIEW_LEFT)
cv2.imshow("ZED", mat.get_data())
key = cv2.waitKey(1)
else :
key = cv2.waitKey(1)

cam.close()

if __name__ == "__main__":
main()
59 changes: 59 additions & 0 deletions examples/camera_streaming/sender/streaming_sender.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
########################################################################
#
# Copyright (c) 2017, STEREOLABS.
#
# All rights reserved.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
########################################################################

"""
Read SVO sample to read the video and the information of the camera. It can pick a frame of the svo and save it as
a JPEG or PNG file. Depth map and Point Cloud can also be saved into files.
"""
import sys
import pyzed.sl as sl
import cv2


def main():

init = sl.InitParameters()
init.camera_resolution = sl.RESOLUTION.RESOLUTION_HD720
init.depth_mode = sl.DEPTH_MODE.DEPTH_MODE_NONE
cam = sl.Camera()
status = cam.open(init)
if status != sl.ERROR_CODE.SUCCESS:
print(repr(status))
exit(1)

runtime = sl.RuntimeParameters()

stream = sl.StreamingParameters()
stream.codec = sl.STREAMING_CODEC.STREAMING_CODEC_AVCHD
stream.bitrate = 4000
status = cam.enable_streaming(stream)
if status != sl.ERROR_CODE.SUCCESS:
print(repr(status))
exit(1)

print(" Quit : CTRL+C\n")
while True:
err = cam.grab(runtime)

cam.disable_streaming()
cam.close()

if __name__ == "__main__":
main()
Loading

0 comments on commit 50cdaba

Please sign in to comment.