ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

get depth image from zed camera

asked 2018-04-10 08:24:09 -0600

abdelkrim gravatar image

updated 2018-05-07 01:32:42 -0600

jayess gravatar image

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()
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-04-10 15:05:51 -0600

You might want Zed to do the computing for you, and supply the depth image. It will figure the disparity itself. /zed/depth/depth_registered Are you using zed-ros-wrapper?

edit flag offensive delete link more

Comments

i'am using zed-ros-wrapper but i wanna work with python to do some demonstration after continue in ros

abdelkrim gravatar image abdelkrim  ( 2018-04-11 07:01:20 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-04-10 08:24:09 -0600

Seen: 1,150 times

Last updated: May 07 '18