• 大小: 1.38MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-10-24
  • 语言: Matlab
  • 标签: kinectv2  matlab  2016a  

资源简介

通过简单的编译操作即可在matlab 2016a以上的环境下调用kinectv2的完整功能,压缩文件内有具体说明。

资源截图

代码片段和文件信息

% BODYDEMO Illustrates how to use the Kin2 object to get and draw the
% Skeleton data
%
% Juan R. Terven jrterven@hotmail.com
% Diana M. Cordova diana_mce@hotmail.com

% Citation:
% Terven Juan. Cordova-Esparza Diana “Kin2. A Kinect 2 Toolbox for MATLAB“ Science of
% Computer Programming 2016. DOI: http://dx.doi.org/10.1016/j.scico.2016.05.009
%
% https://github.com/jrterven/Kin2 2016.

addpath(‘Mex‘);
clear all
close all

% Create Kinect 2 object and initialize it
% Available sources: ‘color‘ ‘depth‘ ‘infrared‘ ‘body_index‘ ‘body‘
% ‘face‘ and ‘HDface‘
k2 = Kin2(‘color‘‘depth‘‘body‘);

% images sizes
d_width = 512; d_height = 424; outOfRange = 4000;
c_width = 1920; c_height = 1080;

% Color image is to big let‘s scale it down
COL_SCALE = 1.0;

% Create matrices for the images
depth = zeros(d_heightd_width‘uint16‘);
color = zeros(c_height*COL_SCALEc_width*COL_SCALE3‘uint8‘);

% depth stream figure
d.h = figure;
d.ax = axes;
d.im = imshow(zeros(d_heightd_width‘uint8‘));
%hold on;

title(‘Depth Source (press q to exit)‘)
set(gcf‘keypress‘‘k=get(gcf‘‘currentchar‘‘);‘); % listen keypress

% color stream figure
c.h = figure;
c.ax = axes;
c.im = imshow(color[]);
title(‘Color Source (press q to exit)‘);
set(gcf‘keypress‘‘k=get(gcf‘‘currentchar‘‘);‘); % listen keypress
%hold on

% Loop until pressing ‘q‘ on any figure
k=[];

disp(‘Press q on any figure to exit‘)
while true
    % Get frames from Kinect and save them on underlying buffer
    validData = k2.updateData;
    
    % Before processing the data we need to make sure that a valid
    % frame was acquired.
    if validData
        % Copy data to Matlab matrices
        depth = k2.getDepth;
        color = k2.getColor;

        % update depth figure
        depth8u = uint8(depth*(255/outOfRange));
        depth8uc3 = repmat(depth8u[1 1 3]);
        d.im = imshow(depth8uc3 ‘Parent‘ d.ax);

        %set(d.im‘CData‘depth8uc3); 

        % update color figure
        color = imresize(colorCOL_SCALE);
        c.im = imshow(color ‘Parent‘ c.ax);

        %set(c.im‘CData‘color); 

        % Get 3D bodies joints 
        % Input parameter can be ‘Quat‘ or ‘Euler‘ for the joints
        % orientations.
        % getBodies returns a structure array.
        % The structure array (bodies) contains 6 bodies at most
        % Each body has:
        % -Position: 3x25 matrix containing the xyz of the 25 joints in
        %   camera space coordinates
        % - Orientation: 
        %   If input parameter is ‘Quat‘: 4x25 matrix containing the 
        %   orientation of each joint in [x; y; z w]
        %   If input parameter is ‘Euler‘: 3x25 matrix containing the 
        %   orientation of each joint in [Pitch; Yaw; Roll] 
        % -TrackingState: state of each joint. These can be:
        %   NotTracked=0 Inferred=1 or Tracked=2
        % -LeftHandState: state of the left hand
        % -RightHandState: state of the right hand
        [bodies fcp timeStamp] = k2.

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-07-05 18:26  jrterven-Kin2-afeec4f\
     文件         378  2017-07-05 18:26  jrterven-Kin2-afeec4f\.gitattributes
     文件         652  2017-07-05 18:26  jrterven-Kin2-afeec4f\.gitignore
     文件        2577  2017-07-05 18:26  jrterven-Kin2-afeec4f\DemoAll.m
     目录           0  2017-07-05 18:26  jrterven-Kin2-afeec4f\Mex\
     文件       13003  2017-07-05 18:26  jrterven-Kin2-afeec4f\Mex\Kin2.h
     文件       56159  2017-07-05 18:26  jrterven-Kin2-afeec4f\Mex\Kin2.m
     文件       11968  2017-07-05 18:26  jrterven-Kin2-afeec4f\Mex\Kin2Collector.m
     文件       21792  2017-07-05 18:26  jrterven-Kin2-afeec4f\Mex\Kin2_base.cpp
     文件       12743  2017-07-05 18:26  jrterven-Kin2-afeec4f\Mex\Kin2_face.cpp
     文件       21378  2017-07-05 18:26  jrterven-Kin2-afeec4f\Mex\Kin2_fusion.cpp
     文件       14846  2017-07-05 18:26  jrterven-Kin2-afeec4f\Mex\Kin2_mapping.cpp
     文件       37234  2017-07-05 18:26  jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp
     文件        2332  2017-07-05 18:26  jrterven-Kin2-afeec4f\Mex\calibCostFun.m
     文件        1877  2017-07-05 18:26  jrterven-Kin2-afeec4f\Mex\class_handle.hpp
     文件        2200  2017-07-05 18:26  jrterven-Kin2-afeec4f\README.txt
     目录           0  2017-07-05 18:26  jrterven-Kin2-afeec4f\UserGuide\
     文件      217941  2017-07-05 18:26  jrterven-Kin2-afeec4f\UserGuide\kin2-user-guide.pdf
     文件        4623  2017-07-05 18:26  jrterven-Kin2-afeec4f\bodyDemo.m
     文件        2503  2017-07-05 18:26  jrterven-Kin2-afeec4f\bodyIndexDemo.m
     文件        4236  2017-07-05 18:26  jrterven-Kin2-afeec4f\calibrationDemo.m
     文件        1627  2017-07-05 18:26  jrterven-Kin2-afeec4f\compile_cpp_files.m
     文件        3055  2017-07-05 18:26  jrterven-Kin2-afeec4f\faceDemo.m
     文件        3951  2017-07-05 18:26  jrterven-Kin2-afeec4f\faceHDDemo.m
     文件        3221  2017-07-05 18:26  jrterven-Kin2-afeec4f\faceHDDemo2.m
     文件     1167604  2017-07-05 18:26  jrterven-Kin2-afeec4f\image.png
     文件        2970  2017-07-05 18:26  jrterven-Kin2-afeec4f\kinectFusionDemo.m
     文件        5314  2017-07-05 18:26  jrterven-Kin2-afeec4f\mapping2CamDemo.m
     文件        4965  2017-07-05 18:26  jrterven-Kin2-afeec4f\mappingDemo.m
     文件        2322  2017-07-05 18:26  jrterven-Kin2-afeec4f\pointCloudDemo.m
     文件        2757  2017-07-05 18:26  jrterven-Kin2-afeec4f\pointCloudDemo2.m
............此处省略2个文件信息

评论

共有 条评论