Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Bisect Video Feed - Zed Camera

Background: I was given a Zed Camera with the task of using it as a stereo camera. StereoLabs provided a proprietary software which requires CUDA (NVIDIA hardware-dependent software package) to run. I found a few tutorials for making and calibrating a stereo camera (example). I need to reformat the Zed camera's video feed in order to use this method.

Goal: I'm trying to set up my zed camera as a stereo camera. The camera takes images which look like this: (see Fig. 1) Fig. 1 - Initial camera output. and using the below script I separated the static image into two halves: (see Figs 2,3) Fig. 2 - Left. Fig. 3 - Right.

Script:

#!usr/bin/python
import cv2
import numpy as np

# Import image
img = cv2.imread('TestPicture3.jpg')

# split image (indexing)
image_left = img[1:1080, 1:1920]
image_right = img[1:1080, 1920:3840]

# Display left and right images
cv2.namedWindow('Left', cv2.WINDOW_NORMAL)
cv2.resizeWindow('Left', 1920, 1080)
cv2.imshow('Left', image_left)

cv2.namedWindow('Right', cv2.WINDOW_NORMAL)
cv2.resizeWindow('Right', 1920, 1080)
cv2.imshow('Right', image_right)

cv2.waitKey(0)

# export images
cv2.imwrite('TestPic_left.jpg', image_left)
cv2.imwrite('TestPic_right.jpg', image_right)

cv2.destroyAllWindows()

I want to bisect the video feed in order to capture left and right video. Below is the script I've written to attempt the bifurcation, but it hasn't worked. What should I do?

#!usr/bin/python
import cv2
import numpy as np

# script imports Zed camera feed and splits the two feeds into left and right frames

# Capture video on camera device 1
vid = cv2.VideoCapture(1)

# Split video feed on left side
imgLeft = vid.read[1:1080, 1:1920]

# Split video feed on right side
imgRight = vid.read[1:1080, 1920:3840]

while(True):
# Capture frame-by-frame
    ret, frame = vid.read()
# Display the resulting frame
    # left
    cv2.namedWindow('Left', cv2.WINDOW_NORMAL)
    cv2.resizeWindow('Left', 2208, 1242)
    cv2.imshow('Left', imgLeft)
    # right
    cv2.namedWindow('Right', cv2.WINDOW_NORMAL)
    cv2.resizeWindow('Right', 2208, 1242)
    cv2.imshow('Right', imgRight)

# End Process
cv2.waitKey(0)
cv2.destroyAllWindows()

The resulting error is:

Traceback (most recent call last):
  File "Split_VideoCapture_Test.py", line 11, in <module>
    imgLeft = vid.read[1:1080, 1:1920]
TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'

Thank in advance for the assistance.

Cheers, Jordan