Processing 结合OpenNI开发kinect的简单笔记

这篇笔记介绍了如何使用Processing结合OpenNI开发基于Kinect的应用,内容包括Processing编程语言的基础,OpenNI的介绍,以及使用SimpleOpenNI库进行骨架追踪的简单示例。笔记中还提到了SkeletonRecorder类用于记录关节位置,并包含PoseRule和SkeletonPoser类的相关代码片段,用于姿势检测和骨架定位。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

笔记是基于Make things See这本书的

原始笔记记于2012年7月份,大三暑假时候,一个假期只研究了这么一个东西

该笔记所记录的方法和类库是一个较早版本的openNI配合processing实现,新版本可能不支持部分函数或是做过改动,抽空研究后,会更新


processing简介:Processing是一种开源编程语言,专门为电子艺术和视觉交互设计而创建,其目的是通过可视化的方式辅助编程教学,并在此基础之上表达数字创意。


OPENNI:OpenNI(开放式的自然交互)是一个由业界领导的非营利组织。该组织专注于提高和改善自然交互设备,应用软件的互操作能力。通过使用这些硬件和中间件(软件)来很方便的访问和使用一些设备。


当时的笔记:记于2012年7月,学完之后,记得简单做了个kinect 手势选择电视频道的东西,后来就再也没跟kinect有过联系了,

后来搬家之后,屋子小,也玩不了体感游戏了,最后来到北京之后,也再没心思玩了.

补充一下.当时用的的processing语言,总以为是个简单语言.后来学多了,才明白,其实这就是java.我的入门语言原来是java

2013.02.21日记

@1 利用第三方库 OpenNi 结合 processing
     
补充:1@。PVector 拥有很多内置方法,
@2.全function

SimpleOpenNI Cheat Sheet

This section attempts to compile a condensed reference to every function and constant available in SimpleOpenNI.

Unless noted, all functions are member functions on a SimpleOpenNI object. Those labeled “PApplet functions” are functions that need to be implement- ed by the PApplet as part of various callback chains. These callback function signatures also include return types so they can be implemented correctly in your sketches. Those labeled “constructors” are constructors.

Return values are noted alongside each function. If no return value is noted, the function returns void. Arguments and their types are noted in the function signature.

Functions and constants are loosely grouped by use case.

No guarantees are made for completeness. Check the website (see “How to Contact Us” on page xviii) for updates since the publication of this book.

    // constants
    USERS_ALL


    SKEL_PROFILE_NONE
    SKEL_PROFILE_ALL
    SKEL_PROFILE_UPPER
    SKEL_PROFILE_LOWER
    SKEL_PROFILE_HEAD_HANDS


    // currently supported joint constants
    SKEL_HEAD
    SKEL_NECK
    SKEL_TORSO


page413image12584
page413image12856

393

A

Appendix

SKEL_LEFT_SHOULDER
SKEL_LEFT_ELBOW
SKEL_LEFT_HAND
SKEL_RIGHT_SHOULDER
SKEL_RIGHT_ELBOW
SKEL_RIGHT_HAND
SKEL_LEFT_HIP
SKEL_LEFT_KNEE
SKEL_LEFT_ANKLE
SKEL_RIGHT_HIP
SKEL_RIGHT_KNEE
SKEL_RIGHT_ANKLE


// present, but unsupported joint constants (maybe in the future)
SKEL_WAIST
SKEL_LEFT_COLLAR
SKEL_LEFT_WRIST


SKEL_LEFT_FINGERTIP
SKEL_RIGHT_COLLAR
SKEL_RIGHT_WRIST
SKEL_RIGHT_FINGERTIP
SKEL_LEFT_FOOT
SKEL_RIGHT_FOOT


// constant for enableRecorder
RECORD_MEDIUM_FILE


// constructors
SimpleOpenNI(PApplet parent)
SimpleOpenNI(PApplet parent,int runMode)
SimpleOpenNI(PApplet parent, String initXMLFile)
SimpleOpenNI(PApplet parent, String initXMLFile,int runMode)


// setup methods
enableDepth()
enableDepth(int width, int height,int fps)
enableRGB()
enableRGB(int width, int height, int fps)
enableIR()
enableIR(int width, int height, int fps)
enableScene()
enableScene(int width, int height, int fps)
enableUser(int flags)
enableGesture()
enableHands()
setMirror(boolean on)
enableRecorder(int recordMedium, String filePath)


update()

// display methods
depthImage() // return PImage
depthMap() // return int[]
depthMapRealWorld() // return PVector[]
rgbImage() // return PImage
irImage() // return PImage
sceneImage() // return PImage
sceneMap() // return int[]
getSceneFloor(PVector point, PVector normal)
getUsersPixels(int user) // return int[]


page414image12976

394 Appendix A

// calibration and recording
// all methods return boolean success
saveCalibrationDataSkeleton(int user, String calibrationFile)
loadCalibrationDataSkeleton(int user, String calibrationFile)
openFileRecording(String filePath)


// accessing position data
getCoM(int userId, PVector container) // returns boolean success
getJointPositionSkeleton(int userId, int jointId,


                         PVector container) // returns float confidence
getJointOrientationSkeleton(int userId, int jointId,


                         PMatrix3D orientation) // returns float confidence
getUsers(IntVEctor userList)


isTrackingSkeleton(int userId) // return boolean


// coordinate  system conversion
convertRealWorldToProjective(PVector world, PVector projective)
convertProjectiveToRealWorld(PVector projective, PVector world)


// display helper functions
drawLimb(int userId, int joint1, int joint2)
drawCamFrustum()


// skeleton calibration callback chain
startPoseDetection(String poseId, int userId)
startTrackingSkeleton(int userId);
startPoseDetection(String poseId, int userId);
stopPoseDetection(int userId);
requestCalibrationSkeleton(int userId, boolean somethingTrue);


// skeleton calibration PApplet functions
void onNewUser(int userId)
void onEndCalibration(int userId, boolean successful)
void onStartPose(String pose, int userId)
void onLostUser(int userId)
void onStartCalibration(int userId)


// gesture recognition PApplet functions
void onStartPose(String poseId, int userId)
void onEndPose(String poseId, int userId)
void onRecognizeGesture(String strGesture, PVector idPosition,


                        PVector endPosition)
void onProgressGesture(String strGesture, PVector idPosition,


                       float progress)
void onStartSession(PVector position)


void onEndSession(String string, PVector position, float progress)
void onFocusSession()


// gesture recognition setup
addGesture(String gestureId)


// hand-tracking PApplet functions
void onCreateHands(int handId, PVector position, float time)
void onUpdateHands(int handId, PVector position, float time)
void onDestroyHands(int handId, float time)


// hand tracking setup 

startTrackingHands(PVector pos)


     
     库名称simple open ni
      
     SimpleOpenNI kienct; //具现化一个对象,类型为openni
     

     再setup中,kinect  =  new SimpleOpenNI(this);实例化对象
     函数, enableDepth(); 打开深度图像, enableRGB();   打开颜色图像。之后,depthImage()以及rgbImage()可以作为具体image来调用现实
     
     depthValue s 为内置数组,记录了没一点的深度值,其存储方式为,将图像阵列横向重新排列,总个数为weight*height,具体x,y 的深度为 x+ y*weight,数值为毫米,400至8000



     稳定closest point的方法:@1 .教材的方法:lerp(lastX,currentX,0.3f);(0.3f为单精度浮点),lerp为插值函数,计算第一个点据第二个的距离,然后按插值,计算相应的差不多数值,结果等于 (currentX - lastX)*0.3f+ lastX
                                                  @2 我的方法:将一段距离内的所有点的x,y分别相加,计算平均值,效果不错

          a = !b;  a,b均为布尔值,这样的话,总是能让boolean开关反转
  &nb
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值