이 페이지는 기계 번역을 사용하여 번역되었습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.
Kinect for Windows V2에서 색상 포인트 클라우드 플롯
이 예제에서는 Kinect® for Windows® V2를 사용하여 색상 포인트 클라우드를 그리는 방법을 보여줍니다.
요구 사항
MATLAB®, Image Acquisition Toolbox™ 및 Computer Vision Toolbox™
Kinect for Windows V2 센서
최소 PC 구성: Windows 10 64비트
Kinect V2 장치에 대한 시스템 객체 만들기
Kinect 카메라에는 색상과 깊이를 위한 별도의 센서가 있습니다. 컬러 센서와 깊이 센서에 대해 별도의 시스템 객체를 생성합니다.
colorDevice = imaq.VideoDevice("kinect",1)
colorDevice = imaq.VideoDevice with properties: Device: 'Kinect V2 Color Sensor (kinect-1)' VideoFormat: 'BGR_1920x1080' ROI: [1 1 1920 1080] ReturnedColorSpace: 'rgb' ReturnedDataType: 'uint8' ReadAllFrames: 'off' DeviceProperties: [1×1 imaq.internal.DeviceProperties]
depthDevice = imaq.VideoDevice("kinect",2)
depthDevice = imaq.VideoDevice with properties: Device: 'Kinect V2 Depth Sensor (kinect-2)' VideoFormat: 'Depth_512x424' ROI: [1 1 512 424] ReturnedColorSpace: 'grayscale' ReturnedDataType: 'uint16' ReadAllFrames: 'off' DeviceProperties: [1×1 imaq.internal.DeviceProperties]
센서를 초기화합니다.
colorDevice(); depthDevice();
각 센서에서 프레임을 하나씩 가져옵니다.
colorImage = colorDevice(); depthImage = depthDevice();
포인트 클라우드 추출
depthDevice
는 Kinect 깊이 videoinput
객체이거나 Kinect 깊이 imaq.VideoDevice
객체여야 합니다.
depthimage
는 uint16
여야 하고 colorImage
는 uint8
여야 합니다.
ptCloud = pcfromkinect(depthDevice,depthImage,colorImage);
3D 포인트 클라우드 데이터를 시각화하기 위해 플레이어를 초기화합니다. 축은 Kinect에서 포인트 클라우드를 시각화하기에 적절하게 설정되었습니다.
player = pcplayer(ptCloud.XLimits,ptCloud.YLimits,ptCloud.ZLimits,"VerticalAxis","y","VerticalAxisDir","down"); xlabel(player.Axes,"X (m)"); ylabel(player.Axes,"Y (m)"); zlabel(player.Axes,"Z (m)");
Kinect 포인트 클라우드 데이터를 수집하고 확인합니다.
while isOpen(player) colorImage = colorDevice(); depthImage = depthDevice(); ptCloud = pcfromkinect(depthDevice,depthImage,colorImage); view(player,ptCloud); end
작업이 끝나면 플레이어를 닫으세요.
장치를 해제합니다
release(colorDevice); release(depthDevice);
Kinect 포인트 클라우드에 대한 추가 정보
오른손 좌표계의 원점은 카메라의 중심에 있습니다. 좌표계의 X축은 오른쪽을 가리키고, Y축은 아래를 가리키고, Z축은 카메라에서 멀어지는 방향을 가리킵니다.
Kinect 깊이 카메라의 범위가 제한되어 있으므로 깊이 이미지의 일부 픽셀에는 해당하는 3D 좌표가 없습니다. 해당 픽셀의 값은 ptCloud의 Location 속성에서 NaN으로 설정됩니다.
Kinect는 게임용으로 설계되었으므로 Kinect의 원래 이미지인 colorImage와 depthImage는 실제 장면의 미러 이미지입니다. 반환된 포인트 클라우드는 실제 장면과 일치하도록 수정됩니다.