配色: 字号:
Kinect on Ubuntu with OpenNI(经测试是成功的(2017-05))
2017-05-15 | 阅:  转:  |  分享 
  
KinectonUbuntuwithOpenNI

UPDATE?October?2015:VerifiedworkinginUbuntu14.04LTSand15.04!

I’vespentallthismorningtryingtotalktotheMicrosoftKinectusingOpenNI.Asitturnsout,theprocessisnotexceptionallydifficult,it’sjusttheredoesn’tseemtobeanyuptodatedocumentationongettingitallworking.So,thispostshouldfillthevoid.IdescribehowtogetaccesstotheKinectworkingusingUbuntu12.04LTS,OpenNI1.5.4,andNITE1.5.2.

Pleasenotethatsincewritingthistutorial,wenowhaveOpenNIandNITE2.0,andPrimeSensehavebeenboughtbyApple.Thistutorialdoesnotworkwithversions2(though1.5worksjustfine),andthereistalkofApplestoppingpublicaccesstoNITE.

TotalktotheKinect,therearetwobasicparts:OpenNIitself,andaSensormodulethatisactuallyresponsibleforcommunicatingwiththehardware.Then,ifyouneedit,thereisNITE,whichisanothermoduleforOpenNIthatdoesskeletaltracking,gestures,andstuff.DependingonhowyouplanonusingthedatafromtheKinect,youmaynotneedNITEatall.

Step1:Prerequisites

Weneedtoinstallabunchofpackagesforallthistowork.Thankfully,thereadmefileincludedwithOpenNIlistsallthese.However,tomakelifeeasier,thisis(asofwriting)whatyouneedtoinstall,inadditiontoallthedevelopmentpackagesyou(hopefully)alreadyhave.Shell

sudoapt-getinstallgitbuild-essentialpythonlibusb-1.0-0-devfreeglut3-devopenjdk-7-jdk

1 sudoapt-getinstallgitbuild-essentialpythonlibusb-1.0-0-devfreeglut3-devopenjdk-7-jdk

Therearealsosomeoptionalpackagesthatyoucaninstall,dependingonwhetheryouwantdocumentation,Monobindings,etc.Notethatonearlierversionstheinstallfailedifyoudidn’thavedoxygeninstalled,eventhoughitislistedasoptional.Shell

sudoapt-getinstalldoxygengraphvizmono-complete

1 sudoapt-getinstalldoxygengraphvizmono-complete

Step2:OpenNI1.5.4

OpenNIisaframeworkforworkingwithwhattheyarecallingnaturalinteractiondevices.Anyway,thisishowitisinstalled:

CheckoutfromGit

OpenNIishostedonGithub,socheckingitoutissimple:Shell

gitclonehttps://github.com/OpenNI/OpenNI.git

1 gitclonehttps://github.com/OpenNI/OpenNI.git

ThefirstthingwewilldoischeckouttheUnstable1.5.4tag.Ifyoudon’tdothis,thentheSensorKinectlibrarywon’tcompileinStep3.Fromthere,changeintothePlatform/Linux-x86/CreateRedistdirectory,andruntheRedistMakerscript.Notethateventhoughthedirectoryisnamedx86,thissamedirectorybuilds64bitversionsjustfine.So,don’tfretifyou’reon64bitLinux.Shell

cdOpenNIgitcheckoutUnstable-1.5.4.0cdPlatform/Linux/CreateRedistchmod+xRedistMaker./RedistMaker

1

2

3

4

5 cdOpenNI

gitcheckoutUnstable-1.5.4.0

cdPlatform/Linux/CreateRedist

chmod+xRedistMaker

./RedistMaker

TheRedistMakerscriptwillcompileeverythingforyou.YouthenneedtochangeintotheRedistdirectoryandruntheinstallscripttoinstallthesoftwareonyoursystem.Shell

cd../Redist/OpenNI-Bin-Dev-Linux-[xxx](where[xxx]isyourarchitectureandthisparticularOpenNIrelease)sudo./install.sh

1

2 cd../Redist/OpenNI-Bin-Dev-Linux-[xxx]??(where[xxx]isyourarchitectureandthisparticularOpenNIrelease)

sudo./install.sh

Step3:KinectSensorModule

OpenNIdoesn’tactuallyprovideanythingfortalkingtothehardware,itismorejustaframeworkforworkingwithdifferentsensorsanddevices.YouneedtoinstallaSensormoduleforactuallydoingthehardwareinterfacing.ThinkofanOpenNIsensormoduleasadevicedriverforthehardware.You’llalsonoteontheOpenNIwebsitethattheyhaveaSensormodulethatyoucandownload.Don’tdothisthough,becausethatsensormoduledoesn’ttalktotheKinect.Ilovehowwelldocumentedallthisis,don’tyou?

ThesensormoduleyouwantisalsoonGitHub,butfromadifferentuser.So,wecancheckoutthecode.Wealsoneedtogetthekinectbranch,notmaster.Shell

gitclonehttps://github.com/avin2/SensorKinectcdSensorKinect

1

2 gitclonehttps://github.com/avin2/SensorKinect

cdSensorKinect

TheinstallprocessforthesensorisprettymuchthesameasforOpenNIitself:Shell

cdPlatform/Linux/CreateRedistchmod+xRedistMaker./RedistMakercd../Redist/Sensor-Bin-Linux-[xxx](where[xxx]isyourarchitectureandthisparticularOpenNIrelease)chmod+xinstall.shsudo./install.sh

1

2

3

4

5

6 cdPlatform/Linux/CreateRedist

chmod+xRedistMaker

./RedistMaker

cd../Redist/Sensor-Bin-Linux-[xxx](where[xxx]isyourarchitectureandthisparticularOpenNIrelease)

chmod+xinstall.sh

sudo./install.sh

OnUbuntu,regularusersareonlygivenreadpermissiontounknownUSBdevices.Theinstallscriptputsinsomeudevrulestofixthis,butifyoufindthatnoneofthesamplesworkunlessyourunthemasroot,tryunpluggingandpluggingtheKinectbackinagain,tomakethenewrulesapply.

Step4:TesttheOpenNISamples

Atthispoint,youhaveenoughinstalledtogetdatafromtheKinect.TheeasiestwaytoverifythisistorunoneoftheOpenNIsamples.Shell

cdOpenNI/Platform/Linux-x86/Bin/Release./Sample-NiSimpleViewer

1

2 cdOpenNI/Platform/Linux-x86/Bin/Release

./Sample-NiSimpleViewer

Youshouldseeayellow-blackdepthimage.Atthispoint,you’releftwith(optionally)installingthehigherlevelNITEmodule.

Step5:InstallNITE1.5(optional)

Firstly,youneedtoobtainNITE1.5.2.GotothefollowinglinkanddownloadNITE1.5.2foryourplatform..

http://www.openni.org/openni-sdk/openni-sdk-history-2/

Extractthearchive,andruntheinstaller:Shell

sudo./install.sh

1 sudo./install.sh

Atsomepoint,youmaybeaskedforalicensekey.AworkinglicensekeycanbefoundjustaboutanywhereontheInternet.Idon’tthinkPrimeSensecare,ormaybethisisanon-commerciallicenseorsomething.Butwhatever,justcopythatlicenseintotheconsole,includingtheequalssignattheend,andNITEwillinstalljustfine.

Conclusion

Afterfollowingthesesteps,youwillbeabletowriteprogramsthatusetheMicrosoftKinectthroughOpenNIandNITEmiddleware.Ihopethishelpssomeone,becauseIspentalotoftimescrewingaroundthismorningtryingtogetitalltowork.LikeIsaid,theprocessisprettystraightforward,itjusthasn’tbeenwrittendowninoneplace(orIsuckatgoogle).



献花(0)
+1
(本文系学海无涯GL首藏)