ZED相机捕获图像

1.捕获图像

(1)将该py文件命名为“ZedCaptureImg.py”;
(2)在存放ZedCaptureImg.py文件夹中创建名为“Img”的文件夹;
(3)按“空格”保存图片,按“q”退出运行;

2.ZedCaptureImg.py

import cv2
import pyzed.sl as sl

# Global variable
camera_settings = sl.VIDEO_SETTINGS.BRIGHTNESS
str_camera_settings = "BRIGHTNESS"
step_camera_settings = 1
led_on = True
selection_rect = sl.Rect()
select_in_progress = False
origin_rect = (-1, -1)


def main():
    init = sl.InitParameters()
    cam = sl.Camera()
    status = cam.open(init)
    if status != sl.ERROR_CODE.SUCCESS:
        print("Camera Open : " + repr(status) + ". Exit program.")
        exit()

    runtime = sl.RuntimeParameters()
    mat = sl.Mat()
    win_name = "Camera Control"
    cv2.namedWindow(win_name)
    key = ''
    i = 0
    while key != 113:  # for 'q' key
        err = cam.grab(runtime)
        if err == sl.ERROR_CODE.SUCCESS:  # Check that a new image is successfully acquired
            # cam.retrieve_image(mat, sl.VIEW.LEFT)  # Retrieve left image
            cam.retrieve_image(mat,sl.VIEW.LEFT)  # Retrieve left image
            cvImage = mat.get_data()  # Convert sl.Mat to cv2.Mat
            cv2.imshow(win_name, cvImage)  # Display image
            if cv2.waitKey(1) & 0xFF == ord(' '):
                cv2.imwrite("./img/{}.jpg".format(i), cvImage)
                i = i+1
            print("i: ",i)
        else:
            print("Error during capture : ", err)
            break

        key = cv2.waitKey(5)

    cv2.destroyAllWindows()

    cam.close()



if __name__ == "__main__":
    main()

3. 参数

3.1 分辨率的选择

HD2K2208*1242 (x2), available framerates: 15 fps.
HD10801920*1080 (x2), available framerates: 15, 30, 60 fps.
HD12001920*1200 (x2), available framerates: 15, 30, 60 fps.
HD7201280*720 (x2), available framerates: 15, 30, 60 fps
SVGA960*600 (x2), available framerates: 15, 30, 60, 120 fps.
VGA672*376 (x2), available framerates: 15, 30, 60, 100 fps.
AUTOSelect the resolution compatible with camera, on ZED X HD1200, HD720 otherwise

3.2 可捕获的视图

HD2K
LEFT
RIGHT
LEFT_GRAY
RIGHT_GRAY
LEFT_UNRECTIFIED
LEFT_UNRECTIFIED_GRAY
RIGHT_UNRECTIFIED_GRAY
SIDE_BY_SIDE
DEPTH
CONFIDENCE
NORMALS
DEPTH_RIGHT
NORMALS_RIGHT

3.3计算获得的视图

DISPARITYDisparity map. Each pixel contains 1 float. sl.MAT_TYPE.F32_C1
DEPTHDepth map, in sl.UNIT defined in sl.InitParameters. Each pixel contains 1 float. sl.MAT_TYPE.F32_C1
CONFIDENCECertainty/confidence of the depth map. Each pixel contains 1 float. sl.MAT_TYPE.F32_C1
XYZPoint cloud. Each pixel contains 4 float (X, Y, Z, not used). sl.MAT_TYPE.F32_C4
XYZRGBAColored point cloud. Each pixel contains 4 float (X, Y, Z, color). The color needs to be read as an unsigned char[4] representing the RGBA color. sl.MAT_TYPE.F32_C4
XYZBGRAColored point cloud. Each pixel contains 4 float (X, Y, Z, color). The color needs to be read as an unsigned char[4] representing the BGRA color. sl.MAT_TYPE.F32_C4
XYZARGBColored point cloud. Each pixel contains 4 float (X, Y, Z, color). The color needs to be read as an unsigned char[4] representing the ARGB color. sl.MAT_TYPE.F32_C4
XYZABGRColored point cloud. Each pixel contains 4 float (X, Y, Z, color). The color needs to be read as an unsigned char[4] representing the ABGR color. sl.MAT_TYPE.F32_C4
NORMALSNormals vector. Each pixel contains 4 float (X, Y, Z, 0). sl.MAT_TYPE.F32_C4
DISPARITY_RIGHTDisparity map for right sensor. Each pixel contains 1 float. sl.MAT_TYPE.F32_C1
DEPTH_RIGHTDepth map for right sensor. Each pixel contains 1 float. sl.MAT_TYPE.F32_C1
XYZ_RIGHTPoint cloud for right sensor. Each pixel contains 4 float (X, Y, Z, not used). sl.MAT_TYPE.F32_C4
XYZRGBA_RIGHTColored point cloud for right sensor. Each pixel contains 4 float (X, Y, Z, color). The color needs to be read as an unsigned char[4] representing the RGBA color. sl.MAT_TYPE.F32_C4
XYZBGRA_RIGHTColored point cloud for right sensor. Each pixel contains 4 float (X, Y, Z, color). The color needs to be read as an unsigned char[4] representing the BGRA color. sl.MAT_TYPE.F32_C4
XYZARGB_RIGHTColored point cloud for right sensor. Each pixel contains 4 float (X, Y, Z, color). The color needs to be read as an unsigned char[4] representing the ARGB color. sl.MAT_TYPE.F32_C4
XYZABGR_RIGHTColored point cloud for right sensor. Each pixel contains 4 float (X, Y, Z, color). The color needs to be read as an unsigned char[4] representing the ABGR color. sl.MAT_TYPE.F32_C4
NORMALS_RIGHTNormals vector for right view. Each pixel contains 4 float (X, Y, Z, 0). sl.MAT_TYPE.F32_C4
DEPTH_U16_MMDepth map in millimeter whatever the sl.UNIT defined in sl.InitParameters. Invalid values are set to 0, depth values are clamped at 65000. Each pixel contains 1 unsigned short. sl.MAT_TYPE.U16_C1
DEPTH_U16_MM_RIGHTDepth map in millimeter for right sensor. Each pixel contains 1 unsigned short. sl.MAT_TYPE.U16_C1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值