www.gusucode.com > IPCV_Eval_Kit_R2019a_0ce6858工具箱matlab程序源码 > IPCV_Eval_Kit_R2019a_0ce6858/code/demo_files/I4_10_1_myPcFromKinect_videoinput.m
clc;clear;close all;imtool close all;imaqreset; %% 庢崬傒梡偺僔僗僥儉僆僽僕僃僋僩傪惗惉 colorVid = videoinput('kinect',1); %video input object for RGB (640 x 480) depthVid = videoinput('kinect',2); %video input object for depth triggerconfig([colorVid depthVid], 'manual'); set([colorVid depthVid], 'FramesPerTrigger', 1); set([colorVid depthVid], 'TriggerRepeat', Inf); start([colorVid depthVid]); % start device %% 僨僶僀僗偺弶婜壔 getsnapshot(colorVid); getsnapshot(depthVid); %% 堦僼儗乕儉庢摼 colorImage = getsnapshot(colorVid); depthImage = getsnapshot(depthVid); ptCloud = pcfromkinect(depthVid,depthImage,colorImage); %% 昞帵 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)'); %% 掆巭儃僞儞昞帵 a=true; sz = get(0,'ScreenSize'); figure('MenuBar','none','Toolbar','none','Position',[20 sz(4)-100 100 70]) uicontrol('Style', 'pushbutton', 'String', 'Stop',... 'Position', [20 20 80 40],'Callback', 'a=false;'); % Start timer to calculate frame rate tic; cnt = 1; fps = single(0.0); %% 儖乕僾張棟 while (a) colorImage = getsnapshot(colorVid); depthImage = getsnapshot(depthVid); ptCloud = pcfromkinect(depthVid,depthImage,colorImage); view(player,ptCloud); % Frame rate calculation from averaging 30 frame cnt = cnt + 1; if (mod(cnt,30) == 0) t = toc; fps = single(30/t) tic; end end release(colorVid); release(depthVid); %% 廔椆 %% 億僗僩昞帵 張棟 % figure; pcshow(ptCloud, 'VerticalAxis','Y', 'VerticalAxisDir', 'Down', 'MarkerSize',18) % xlabel('X (m)');ylabel('Y (m)');zlabel('Z (m)'); box on; %% Copyright 2015-2016 The MathWorks, Inc.