Comments (5)
Hi,
This is already implemented, you have to set the camera ID
PyInitParameters.camera_linux_id
Here is a simple example with 2 ZED: https://gist.github.com/adujardin/14843cb6f6f1380ad5ca9b948f85c531
from zed-python-api.
`
import cv2
import pyzed.sl as sl
zed1 = sl.Camera()
zed2 = sl.Camera()
def main():
print("Running...")
init_params = sl.InitParameters()
init_params.camera_resolution = sl.RESOLUTION.RESOLUTION_HD720
init_params.camera_fps = 30
init_params.camera_linux_id = 0
if not zed1.is_opened():
print("Opening ZED Camera 1 ...")
err = zed1.open(init_params)
if err != sl.ERROR_CODE.SUCCESS:
print(repr(err))
exit(1)
init_params.camera_linux_id = 1 # Specify the camera index
if not zed2.is_opened():
print("Opening ZED Camera 2 ...")
err = zed2.open(init_params)
if err != sl.ERROR_CODE.SUCCESS:
print(repr(err))
exit(1)
runtime = sl.RuntimeParameters()
mat1 = sl.Mat()
mat2 = sl.Mat()
print_camera_information(zed1)
print_camera_information(zed2)
key = ''
while key != 113: # for 'q' key
err = zed1.grab(runtime)
if err == sl.ERROR_CODE.SUCCESS:
zed1.retrieve_image(mat1, sl.VIEW.VIEW_LEFT)
cv2.imshow("ZED 1", mat1.get_data())
err = zed2.grab(runtime)
if err == sl.ERROR_CODE.SUCCESS:
zed2.retrieve_image(mat2, sl.VIEW.VIEW_LEFT)
cv2.imshow("ZED 2", mat2.get_data())
key = cv2.waitKey(5)
cv2.destroyAllWindows()
zed1.close()
zed2.close()
print("\nFINISH")
def print_camera_information(cam): print("Resolution: {0}, {1}.".format( round(cam.get_resolution().width, 2), cam.get_resolution().height)) print("Camera FPS: {0}.".format(cam.get_camera_fps())) print("Firmware: {0}.".format( cam.get_camera_information().firmware_version)) print("Serial number: {0}.\n".format( cam.get_camera_information().serial_number))
if name == "main":
main()
`
from zed-python-api.
Thanks for sharing! This is a great extension of the SDK. I think the multiple ZED is an important feature and it would be great to see it in the python SDK. Is there any plan to include this? If not, any tips how we can extend it?
Thanks!
from zed-python-api.
Hi,
I am trying to select a camera in a multi-camera setting based on the serial number, using the set_from_serial_number()
function from InitParameters.input
, however, when I open()
with those init_params
, the serial number appears to be ignored and another camera is opened.
Even if I use a random non-existent serial number, upon opening no error is issued and the same default camera is accessed.
Is set_from_serial_number()
reliable or camera_linux_id
is the only viable option to select a camera? (I'm in a Linux environment.)
Thanks in advance!
Best,
Massimo
from zed-python-api.
Hi @mminervini ,
To fix your problem you can use the function set_from_serial_number()
from InitParameters so use :
init.set_from_serial_number(num)
instead of :
init.input.set_from_serial_number(num)
You can also create an object InputType
use the function and then assign it to the InitParameters
but this is more laborious. We will soon remove this ambiguity to avoid confusion so you can just use the set_from functions directly for InitParameters
.
Thanks for your report.
from zed-python-api.
Related Issues (20)
- Python API for 3.7.4 on Jetpack 5.0 HOT 8
- the object detection and body tracking is not working with zed camera on jetson xavier HOT 1
- get_python_api.py is unable to find pyzed installation folder HOT 2
- import error when run as superuser for python 3.8 on ubuntu HOT 2
- ModuleNotFoundError: No module named 'pyzed.sl' as non-root HOT 2
- Can't build plugin, Error: you must install Cuda HOT 2
- Unable to install Zed Python API HOT 2
- Outdated API
- Image Upside down
- ZED svo playback fps error
- ImportError: DLL load failed while importing sl: The specified procedure could not be found. HOT 2
- Bug when importing pyzed.sl HOT 1
- Requests dependency during API installation HOT 1
- When installing on an ubuntu system, the command used when compiling isοΌ python 3 setup. py build, display error: pyzed/sl. pyx: 10455:161 "c_position_type" is not a type identifier, how to solve this problem? HOT 1
- sl.Matrix4f from numpy.ndarray
- TypeError: Expected a mapping, got pyzed.sl.PositionalTrackingFusionParameters
- ValueError: -1835986560 is not a valid POSITIONAL_TRACKING_STATE
- Typos in README.md
- enable_image_validity_check spams compute fern and compute color print statements HOT 1
- wheel file not running
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zed-python-api.