get depth image from zed camera
i used this code to get depth image but i don't knew what's missing i got just a gray window :
#! /usr/bin/env python
import cv2
import numpy as np
cap = cv2.VideoCapture(1)
if (cap.isOpened() == False):
print("Unable to read camera feed")
frame_width = int(cap.get(3))
frame_height = int(cap.get(4))
out = cv2.VideoWriter('outpy.avi', cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'), 10, (frame_width, frame_height))
while (True):
ret, frame = cap.read()
vidL = frame[:, 0:1280] # left camera
vidR = frame[:, 1280:2560] # right camera
vL=cv2.cvtColor(vidL, cv2.COLOR_BGR2GRAY)
vR=cv2.cvtColor(vidR, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame', frame)
stereo = cv2.StereoBM_create(numDisparities=16, blockSize=15)
disparity = stereo.compute(vR,vL)
cv2.imshow('depth',disparity)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
out.release()
# Closes all the frames
cv2.destroyAllWindows()