Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 2088

Stereo Camera Calibration/Rectification with Zed Camera (python)

$
0
0
**Goal:** I want to calibrate and rectify my Zed camera. The input video feed leads to some complications. However, this method produces fewer headaches than buying a new computer which contains an NVIDIA GPU just for the sake of using the proprietary software (which may or may not allow of the end goal). For now, all I want to do is calibrate my camera so I can start estimating sizes and distances of (first known, then unknown) objects. For reference, this is what the Zed camera's video looks like: ![Zed camera, raw image](/upfiles/14712852784392052.jpg) FIG. 1 - Raw image from Zed Camera. I figured out a quick-and-dirty method of splitting the video feed. Generally: cap = cv2.VideoCapture(1) # video sourced from Zed camera while(True): # Capture frame-by-frame ret, frame = cap.read() # partition video vidL = frame[0:1080, 0:1280] # left camera vidR = frame[0:1080, 1281:2560] # right camera The resulting images look like this: ![Zed camera, left image](/upfiles/14712854971832172.jpg) FIG 2. - Left image from Zed camera. ![Zed camera, right image](/upfiles/14712855553346555.jpg) FIG 3. - Right image from Zed Camera. My code is adapted from this [source](https://github.com/abidrahmank/OpenCV-Python/blob/master/Other_Examples/camera_calibration.py) . It runs a calibration and rectification of a camera with live video feed. I tested it before I made any changes and it worked, albeit with some odd results. (It partially rectified a section of the image.) #!usr/bin/python import cv, cv2, time, sys import numpy as np #n_boards=0 #no of boards #board_w=int(sys.argv[1]) # number of horizontal corners #board_h=int(sys.argv[2]) # number of vertical corners #n_boards=int(sys.argv[3]) #board_n=board_w*board_h # no of total corners #board_sz=(board_w,board_h) #size of board n_boards=0 #no of boards board_w=(9) # number of horizontal corners board_h=(6) # number of vertical corners n_boards=1 board_n=board_w*board_h # no of total corners board_sz=(board_w,board_h) #size of board # creation of memory storages # Left image_pointsL=cv.CreateMat(n_boards*board_n,2,cv.CV_32FC1) object_pointsL=cv.CreateMat(n_boards*board_n,3,cv.CV_32FC1) point_countsL=cv.CreateMat(n_boards,1,cv.CV_32SC1) intrinsic_matrixL=cv.CreateMat(3,3,cv.CV_32FC1) distortion_coefficient_L=cv.CreateMat(5,1,cv.CV_32FC1) # Right image_pointsR=cv.CreateMat(n_boards*board_n,2,cv.CV_32FC1) object_pointsR=cv.CreateMat(n_boards*board_n,3,cv.CV_32FC1) point_countsR=cv.CreateMat(n_boards,1,cv.CV_32SC1) intrinsic_matrixR=cv.CreateMat(3,3,cv.CV_32FC1) distortion_coefficient_R=cv.CreateMat(5,1,cv.CV_32FC1) # capture frames of specified properties and modification of matrix values i=0 y=0 z=0 # to print number of frames successes=0 # Capture video from camera capture = cv2.VideoCapture(1) # 1 references Zed camera, cange as necessary # partition video while(successes

Viewing all articles
Browse latest Browse all 2088

Trending Articles