Hi,
I’m using python to work use the zed sdk, I have mentioned the frame rate and the resolution in the initial parameters the camera gets the frames at lower fps.
import pyzed.sl as sl
import cv2
import numpy as np
import math
def main():
# Create a Camera object
zed = sl.Camera()
# Create a InitParameters object and set configuration parameters
init_params = sl.InitParameters()
init_params.camera_resolution = sl.RESOLUTION.SVGA # Use HD1080 video mode
init_params.camera_fps = 120 # Set fps at 30
init_params.sdk_verbose = True # Enable the verbose mode
init_params.depth_mode = (
sl.DEPTH_MODE.QUALITY
) # Set the depth mode to performance (fastest)
init_params.coordinate_units = sl.UNIT.CENTIMETER # Use meter units (for depth measurements)
# Open the camera
err = zed.open(init_params)
if err != sl.ERROR_CODE.SUCCESS:
exit(1)
# Capture 50 frames and stop
i = 0
image = sl.Mat()
depth = sl.Mat()
point_cloud = sl.Mat()
runtime_parameters = sl.RuntimeParameters()
while True:
# Grab an image, a RuntimeParameters object must be given to grab()
if zed.grab(runtime_parameters) == sl.ERROR_CODE.SUCCESS:
print("FPS",zed.get_current_fps())
# A new image is available if grab() returns SUCCESS
zed.retrieve_image(image, sl.VIEW.LEFT)
zed.retrieve_measure(depth, sl.MEASURE.DEPTH)
color_image = image.get_data()
depth_image = depth.get_data()
depth_colormap = cv2.applyColorMap(
cv2.convertScaleAbs(depth_image, alpha=0.03), cv2.COLORMAP_JET
)
cv2.namedWindow("ZED X ", cv2.WINDOW_AUTOSIZE)
color_image = cv2.circle(color_image, (900,500), radius=2 , color=(0, 0, 255), thickness=-1)
cv2.imshow("ZED X ", color_image)
# Get the 3D point cloud values for pixel (i, j)
cv2.waitKey(1)
if cv2.waitKey(10) & 0xFF == ord("q"): #113
zed.retrieve_measure(point_cloud, sl.MEASURE.XYZRGBA)
#point_cloud.write("test.pcd")
err, point_cloud_value = point_cloud.get_value(900, 500)
x, y, z, color = point_cloud_value
distance = math.sqrt(
x *x + y * y + z * z
)
print(f"Distance to Camera at : {distance}")
break
# Close the camera
zed.close()
if __name__ == "__main__":
main()
If I change the depth mode to performance, the fps goes upto 20.
Hi, the FPS you set as init parameter is the FPS of the video capture of the camera.
the value you get by calling get_current_fps is your global application FPS, this may be lower than the one you set depending on your hardware compute power and your overall application load.
What do you mean by “video stream” ?
The video itself will reach the FPS you asked for in the initParameters. However, the real fps of your application will be defined by how many time you can run grab() per second. This can be retrieved with get_current_fps
You’re saying that the camera can capture the frames at the mentioned parameters but in order to use it, it depends on the grab() which ultimately depends on the processing capability.
right?
If so, then what is the nominal speed at which the frames can be grabbed and processed by grab()
Is there any way to improve it?
We are using zed x with zed box
What do you mean by “nominal speed” ? If will depends on what you do with the camera. If you just use PERFORMANCE depth, you can easily reach a high FPS, which you cannot with a heavier depth like NEURAL
import pyzed.sl as sl
import cv2
import numpy as np
import math
def main():
# Create a Camera object
zed = sl.Camera()
# Create a InitParameters object and set configuration parameters
init_params = sl.InitParameters()
init_params.camera_resolution = sl.RESOLUTION.HD1080 # Use HD1080 video mode
init_params.camera_fps = 30 # Set fps at 30
init_params.sdk_verbose = True # Enable the verbose mode
init_params.depth_mode = (
sl.DEPTH_MODE.PERFORMANCE
) # Set the depth mode to performance (fastest)
init_params.coordinate_units = sl.UNIT.CENTIMETER # Use meter units (for depth measurements)
# Open the camera
err = zed.open(init_params)
if err != sl.ERROR_CODE.SUCCESS:
exit(1)
image = sl.Mat()
depth = sl.Mat()
point_cloud = sl.Mat()
runtime_parameters = sl.RuntimeParameters()
while True:
# Grab an image, a RuntimeParameters object must be given to grab()
if zed.grab(runtime_parameters) == sl.ERROR_CODE.SUCCESS:
print("FPS",zed.get_current_fps())
# A new image is available if grab() returns SUCCESS
zed.retrieve_image(image, sl.VIEW.LEFT)
zed.retrieve_measure(depth, sl.MEASURE.DEPTH)
color_image = image.get_data()
depth_image = depth.get_data()
# Close the camera
zed.close()
if __name__ == "__main__":
main()
Your code seems pretty straightforward to me, I don’t see anything that could justify the performance loss. What power mode are you using on the ZED Box? Low performance could come from the 15W power mode.
@Gopi-htic
There is probably something wrong with your hardware. I encourage you to contact support@stereolabs.com with your order number and description of the issue to initiate a warranty claim.