示例#1
0
def processImages(image_folder,
                  lr_image_list,
                  stcal,
                  stmatcher,
                  showPreviewGUI=False):
    for f_lr in lr_image_list:
        f_l, f_r = f_lr
        f_d = f_l[:-1] + "d"
        f_p = f_l[:-1] + "points.ply"
        f_l = image_folder + f_l + ".png"
        f_r = image_folder + f_r + ".png"
        f_d = image_folder + f_d + ".png"
        stcap = StereoCapture("Image", [f_l, f_r])
        s3D = Stereo3D(stcap, stcal, stmatcher)
        connected = s3D.connect()
        if showPreviewGUI:
            while (True):
                exit_code = s3D.run_frame()
                if (exit_code == s3D.EXIT_CODE_QUIT):
                    break
        res, disp = s3D.grab3D(False)
        if (res):
            disp_scaled = s3D.scale_disparity(disp)
            disp_black_mask = disp_scaled <= 0
            # apply color map to disparity
            colormap = cv2.COLORMAP_JET
            disp_colormap = cv2.applyColorMap(disp_scaled, colormap)
            disp_colormap[disp_black_mask != 0] = [0, 0, 0]
            cv2.imwrite(f_d, disp_colormap)
            print("Saved disparty to: " + f_d)
            s3D.save_point_cloud(disp, s3D.rect_image_left, image_folder, f_p,
                                 False)
        else:
            print("Failed to generate 3D")
示例#2
0
from Stereo3D import Stereo3D, StereoCalibration
from Stereo3D.StereoCapture import *

camera_name = "deimos"
marked_image_filepath = "SampleData/deimos_left_marked.png"
stcap = StereoCapture(
    "Image", ["SampleData/deimos_left.png", "SampleData/deimos_right.png"])
# define inout folder
folder = "SampleData/"
outputfolder = "SampleData/output/"

CAL_MODE_FROM_IMAGES = 0
CAL_MODE_FROM_YAML = 1
CAL_MODE_FROM_XML = 2

stcal = None
cal_mode = CAL_MODE_FROM_YAML
if (cal_mode == CAL_MODE_FROM_IMAGES):
    # define calibration directories
    left_images_folder = folder + "deimos_cal/"
    right_images_folder = folder + "deimos_cal/"
    output_folder = folder + "deimos_cal/"
    left_wildcard = "*_l.png"
    right_wildcard = "*_r.png"
    grid_size = 39.0
    grid_rows = 6
    grid_cols = 8
    # generate calibration from images
    stcal = StereoCalibration()
    stcal.calibrate(left_images_folder, right_images_folder, output_folder,
                    left_wildcard, right_wildcard, grid_size, grid_rows,
示例#3
0
from Stereo3D import Stereo3D, StereoCalibration
from Stereo3D.StereoCapture import *

CAMERA_TYPE_PHOBOS = 0
CAMERA_TYPE_DEIMOS = 1
CAMERA_TYPE_PYLON = 2
CAMERA_TYPE_IMAGE = 3
CAMERA_TYPE_VREP = 4

camera_type = CAMERA_TYPE_IMAGE

stcap = None
camera_name = None
if (camera_type == CAMERA_TYPE_PHOBOS):
    camera_name = "phobos"
    stcap = StereoCapture("Phobos", ["22864912", "22864917"])
elif (camera_type == CAMERA_TYPE_PYLON):
    stcap = StereoCapture("Pylon", ["22864912", "22864917"])
elif (camera_type == CAMERA_TYPE_DEIMOS):
    camera_name = "deimos"
    stcap = StereoCapture("Deimos", 0)
elif (camera_type == CAMERA_TYPE_IMAGE):
    #camera_name = "deimos"
    #stcap = StereoCapture("Image",["SampleData/deimos_left.png","SampleData/deimos_right.png"])
    camera_name = "phobos"
    folder_i = "D:/Users/monke/OneDrive - i3d Robotics Ltd/Phobos/BenCCal/test_images"
    stcap = StereoCapture(
        "Image", [folder_i + "/left_a.png", folder_i + "/right_a.png"])
elif (camera_type == CAMERA_TYPE_VREP):
    api_port = 20000
    left_vision_sensor_name = "StereoCameraLeft"
示例#4
0
CAL_MODE_FROM_YAML = 1
CAL_MODE_FROM_XML = 2
MATCH_MODE_BM = "BM"
MATCH_MODE_SGBM = "SGBM"

folder_images = "D:/Users/monke/OneDrive/Desktop/ml/in/deimos/"  # Set this to your image folder (Must end with '/')
out_folder = "D:/Users/monke/OneDrive/Desktop/ml/out/"  # Set ths to your output folder (Must end with '/')
folder_cal = "D:/Users/monke/OneDrive/Desktop/Deimos/deimos_cal_001023/"  # Set this to your calibration folder (Must end with '/')
left_image_name = "20200527_114055_686_l.png"  # Set this to the left image name
right_image_name = "20200527_114055_686_r.png"  # Set this to the right image name
marked_image_name = "20200527_114055_686_l_marked.png"  # Set this to the left marked image name
cal_mode = CAL_MODE_FROM_XML  # Choose calibration load type (can set this to CAL_MODE_FROM_IMAGES to calibrate from images however this isn't well tested yet so I wouldn't)
matcher = MATCH_MODE_BM  # Choose matcher type

stcap = StereoCapture(
    "Image",
    [folder_images + left_image_name, folder_images + right_image_name])
stcal = None
if (cal_mode == CAL_MODE_FROM_IMAGES):
    # define calibration directories
    left_images_folder = folder_cal
    right_images_folder = folder_cal
    output_folder = folder_cal
    left_wildcard = "*_l.png"
    right_wildcard = "*_r.png"
    grid_size = 39.0
    grid_rows = 6
    grid_cols = 8
    # generate calibration from images
    stcal = StereoCalibration()
    stcal.calibrate(left_images_folder, right_images_folder, output_folder,
示例#5
0
from Stereo3D import Stereo3D, StereoCalibration
from Stereo3D.StereoCapture import *

CAMERA_TYPE_PHOBOS = 0
CAMERA_TYPE_DEIMOS = 1
CAMERA_TYPE_PYLON = 2
CAMERA_TYPE_IMAGE = 3
CAMERA_TYPE_VREP = 4

camera_type = CAMERA_TYPE_IMAGE

stcap = None
camera_name = None
if (camera_type == CAMERA_TYPE_PHOBOS):
    camera_name = "phobos"
    stcap = StereoCapture("Phobos", ["22864917", "22864912"])
elif (camera_type == CAMERA_TYPE_PYLON):
    stcap = StereoCapture("Pylon", ["22864917", "22864912"])
elif (camera_type == CAMERA_TYPE_DEIMOS):
    camera_name = "deimos"
    stcap = StereoCapture("Deimos", 0)
elif (camera_type == CAMERA_TYPE_IMAGE):
    camera_name = "deimos"
    stcap = StereoCapture(
        "Image", ["SampleData/deimos_left.png", "SampleData/deimos_right.png"])
elif (camera_type == CAMERA_TYPE_VREP):
    api_port = 20000
    left_vision_sensor_name = "StereoCameraLeft"
    right_vision_sensor_name = "StereoCameraRight"
    stcapVREP = StereoCaptureVREP(left_vision_sensor_name,
                                  right_vision_sensor_name, api_port)