Hi, we noticed that the ZED pyzed
library has excessive GPU and CPU utilization even when we only grab the unrectified left eye image, with the depth inference turned off.
We are considering switching away from ZED given this and other related issues. In comparison, a standard UVC camera incurs no GPU utilization and very little CPU usage.
Here is the code for reproducing this:
import asyncio
import cv2
import numpy as np
import pyzed.sl as sl
from vuer import VuerSession, Vuer
from vuer.schemas import Scene, ImageBackground
zed = sl.Camera()
#
# Create a InitParameters object and set configuration parameters
init_params = sl.InitParameters()
init_params.depth_mode = sl.DEPTH_MODE.NONE
init_params.depth_stabilization = 0
init_params.camera_resolution = sl.RESOLUTION.SVGA # Use HD720 opr HD1200 video mode, depending on camera type.
init_params.camera_fps = 60 # Set fps at 30
#
# Open the camera
err = zed.open(init_params)
if err != sl.ERROR_CODE.SUCCESS:
print("Camera Open : " + repr(err) + ". Exit program.")
exit()
#
# # Capture 50 frames and stop
image = sl.Mat()
runtime_parameters = sl.RuntimeParameters()
# runtime_parameters.enable_depth = False
runtime_parameters.enable_fill_mode = False
app = Vuer(port=8112)
@app.spawn(start=True)
async def main(sess: VuerSession):
sess.set @ Scene()
await asyncio.sleep(0.0)
# Create a Camera object
while True:
# # Grab an image, a RuntimeParameters object must be given to grab()
if zed.grab(runtime_parameters) != sl.ERROR_CODE.SUCCESS:
print("capture error.")
break
#
# # A new image is available if grab() returns SUCCESS
zed.retrieve_image(image, sl.VIEW.LEFT_UNRECTIFIED)
buff = image.get_data()[::15, ::15]
# buff = cv2.cvtColor(buff, cv2.COLOR_BGR2RGB)
rgb = np.asanyarray(buff)
sess.upsert @ ImageBackground(rgb, key="rgb")
await asyncio.sleep(0.0)
# Close the camera
# zed.close()