{"id":552,"date":"2012-11-24T23:34:14","date_gmt":"2012-11-24T14:34:14","guid":{"rendered":"http:\/\/www.syuheiuda.com\/?p=552"},"modified":"2012-11-24T23:34:14","modified_gmt":"2012-11-24T14:34:14","slug":"orf2012","status":"publish","type":"post","link":"https:\/\/www.syuheiuda.com\/?p=552","title":{"rendered":"ORF2012"},"content":{"rendered":"<p>ORF\u3067\u4f7f\u3063\u305f\u300c\u670d\u306e\u578b\u7d19\u3092\u81ea\u52d5\u3067\u30ea\u30b5\u30a4\u30ba\u3057\u3066\u304f\u308c\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u300d\u306e\u30b3\u30fc\u30c9\u3092\u3068\u308a\u3042\u3048\u305a\u516c\u958b<br \/>\n\u30e9\u30a4\u30d6\u30e9\u30ea\u306fSimpleOpenNI\u3068ControlP5\u3092\u4f7f\u7528<\/p>\n<p>\u3042\u307e\u308a\u306b\u3082\u65e5\u672c\u8a9e\u306e\u30ea\u30bd\u30fc\u30b9\u304c\u5c11\u306a\u3044\u306e\u3067\u3001<br \/>\n\u305d\u306e\u3046\u3061SimpleOpenNI\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u7684\u306a\u4f55\u304b\u3092\u66f8\u3051\u305f\u3089\u66f8\u304f\u4e88\u5b9a<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\nimport SimpleOpenNI.*;\nSimpleOpenNI context;\nimport controlP5.*;\nControlP5 controlP5;\nimport processing.pdf.*;\nboolean saveOneFrame = false;\n\nRadioButton r;\n\nint\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 mode=0;\n\nfloat\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 zoomF =0.5f;\nfloat\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 rotX = radians(180);\nfloat\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 rotY = radians(0);\nboolean\u00a0\u00a0\u00a0\u00a0\u00a0 autoCalib=true;\nPVector\u00a0\u00a0\u00a0\u00a0\u00a0 bodyCenter = new PVector();\/\/\u4f53\u306e\u4e2d\u592e\nPVector\u00a0\u00a0\u00a0\u00a0\u00a0 bodyDir = new PVector();\/\/\u4f53\u306e\u5411\u304d\nPVector realWorldPoint;\ncolor&#x5B;]\u00a0\u00a0\u00a0\u00a0\u00a0 userColors = {\ncolor(255, 0, 0), color(0, 255, 0), color(0, 0, 255), color(255, 255, 0), color(255, 0, 255), color(0, 255, 255)\n};\nint topIndex;\nint waistIndex;\nint waistRightIndex;\nint waistLeftIndex;\nint&#x5B;] userMap = null;\n\nfloat mitake;\nfloat yuki;\nfloat kosimawari;\nfloat sodetake;\nfloat sodehaba;\nfloat sodeguti;\nfloat sodemarumi;\nfloat kitake;\nfloat sodetuke;\nfloat miyatuguti;\nfloat kurikosi;\nfloat okumisagari;\nfloat erisita;\nfloat kensaki;\nfloat katahaba;\nfloat atohaba;\nfloat maehaba;\nfloat okumihaba;\nfloat aiduma;\nfloat erikataaki;\nfloat katamawari;\nfloat erituke;\nfloat Height=150;\nfloat Waist=70;\nfloat Arm=60;\nfloat Height2=150;\nfloat Waist2=70;\nfloat Arm2=60;\n\nPFrame f;\nsecondApplet s;\n\nvoid setup() {\nsize(1024, 768, P3D);\nPFrame f = new PFrame();\ncontext = new SimpleOpenNI(this);\ncontext.setMirror(false);\n\/\/\u30ad\u30cd\u30af\u30c8\u672a\u63a5\u7d9a\u6642\u306e\u4f8b\u5916\u51e6\u7406\nif (context.enableDepth() == false)\n{\nprintln(&quot;Can't open the depthMap, maybe the camera is not connected!&quot;);\nexit();\nreturn;\n}\ncontext.enableUser(SimpleOpenNI.SKEL_PROFILE_ALL);\nstroke(255, 255, 255);\nsmooth();\n}\n\nvoid draw() {\nif (mode==0) {\n\/\/println(&quot;mode:Kinect&quot;);\nmitake=Height;\nkosimawari=Waist;\nyuki=Arm;\n}\nif (mode==1) {\n\/\/println(&quot;mode:Slider&quot;);\nmitake=Height2;\nkosimawari=Waist2;\nyuki=Arm2;\n}\nkitake=mitake*0.83*2;\nsodetake=55*2;\nsodehaba=(yuki\/2+1)*2;\nsodeguti=23*2;\nsodemarumi=2*2;\nsodetuke=23*2;\nmiyatuguti=15*2;\nkurikosi=2*2;\nokumisagari=22*2;\nerisita=88*2;\nkensaki=7.5*2;\n\n\/\/pushMatrix();\nperspective(radians(45), float(width)\/float(height), 10, 150000);\ncontext.update();\nbackground(0, 0, 0);\n\n\/\/ set the scene pos\ntranslate(width\/2, height\/2, 0);\nrotateX(rotX);\nrotateY(rotY);\nscale(zoomF);\n\nint&#x5B;]\u00a0\u00a0 depthMap = context.depthMap();\nint\u00a0\u00a0\u00a0\u00a0 steps\u00a0\u00a0 = 3;\u00a0 \/\/ to speed up the drawing, draw every third point\nint\u00a0\u00a0\u00a0\u00a0 index;\n\ntranslate(0, 0, -1000);\u00a0 \/\/ set the rotation center of the scene 1000 infront of the camera\n\nint userCount = context.getNumberOfUsers();\nif (userCount &amp;gt; 0)\n{\nuserMap = context.getUsersPixels(SimpleOpenNI.USERS_ALL);\n}\n\n\/\/\u30c7\u30d7\u30b9\u30de\u30c3\u30d7\u8868\u793a\nstroke(100);\nfor (int y=0;y &amp;lt; context.depthHeight();y+=steps)\n{\nfor (int x=0;x &amp;lt; context.depthWidth();x+=steps)\n{\nindex = x + y * context.depthWidth();\nif (depthMap&#x5B;index] &amp;gt; 0)\n{\n\/\/ \u70b9\u306e\u63cf\u753b\nrealWorldPoint = context.depthMapRealWorld()&#x5B;index];\n\/\/ check if there is a user\nif (userMap != null &amp;amp;&amp;amp; userMap&#x5B;index] != 0)\n{\u00a0 \/\/ calc the user color\nint colorIndex = userMap&#x5B;index] % userColors.length;\nstroke(userColors&#x5B;colorIndex]);\n}\nelse\n\/\/ default color\nstroke(100);\npoint(realWorldPoint.x, realWorldPoint.y, realWorldPoint.z);\n}\n}\n}\n\n\/\/\u30b9\u30b1\u30eb\u30c8\u30f3\u8868\u793a\nint&#x5B;] userList = context.getUsers();\nfor (int i=0;i&amp;lt;userList.length;i++)\n{\nif (context.isTrackingSkeleton(userList&#x5B;i]))\ndrawSkeleton(userList&#x5B;i]);\n}\n\n\/\/ draw the kinect cam\n\/\/context.drawCamFrustum();\n}\nPVector cameraPos = new PVector(0, 0, 0);\nPVector cameraRot = new PVector(0, 0, 0);\nPVector cameraTargetPos = new PVector(0, 0, 0);\nfloat ftmp = 1.0f;\nfloat cameraTargetR = 1000.0f;\nvoid setCamera() {\ncameraPos.x = cameraTargetPos.x + ftmp*sin(cameraRot.y)* cameraTargetR * cos(cameraRot.x);\ncameraPos.y = ftmp*sin(cameraRot.x) * cameraTargetR;\ncameraPos.z = cameraTargetPos.z + ftmp*cos(cameraRot.y) * cameraTargetR *cos(cameraRot.x);\n\ncamera(cameraPos.x, cameraPos.y, cameraPos.z,\ncameraTargetPos.x, cameraTargetPos.y, cameraTargetPos.z,\n0, 1, 0);\nperspective(PI\/2.0, (float)width\/(float)height, 1, 5000);\n}\n\npublic class PFrame extends Frame {\npublic PFrame() {\nsetBounds(100, 100, 768, 768);\ns = new secondApplet();\nadd(s);\ns.init();\nshow();\n}\n}\n\npublic class secondApplet extends PApplet {\npublic void setup() {\nsize(768, 768);\ncontrolP5 = new ControlP5(this);\nr = controlP5.addRadioButton(&quot;radioButton&quot;)\n.setPosition(500, 580)\n.setSize(20, 20)\n.setColorForeground(color(120))\n.setColorActive(color(255))\n.setColorLabel(color(255))\n.setItemsPerRow(5)\n.setSpacingColumn(50)\n.addItem(&quot;Kinect&quot;, 0)\n.addItem(&quot;Slider&quot;, 1)\n.activate(mode)\n;\ncontrolP5.addButton(&quot;Save&quot;)\n.setValue(0)\n.setPosition(500, 700)\n.setSize(30, 20)\n;\n\ncontrolP5.addSlider(&quot;Height&quot;, 150, 190, 500, 610, 200, 20);\ncontrolP5.addSlider(&quot;Waist&quot;, 70, 100, 500, 640, 200, 20);\ncontrolP5.addSlider(&quot;Arm&quot;, 60, 90, 500, 670, 200, 20);\n\/\/ noLoop();\n}\n\npublic void draw() {\nbackground(0);\nstroke(255);\nnoFill();\ncontrolP5.controller(&quot;Height&quot;).setValue(mitake);\ncontrolP5.controller(&quot;Waist&quot;).setValue(kosimawari);\ncontrolP5.controller(&quot;Arm&quot;).setValue(yuki);\nif (saveOneFrame == true) {\nbeginRecord(PDF, &quot;Line.pdf&quot;);\n}\ndrawsode(50, 200);\ndrawsode(50, 500);\ndrawmigoro(200, 350, 1);\ndrawmigoro(400, 350, -1);\ndrawokumi(500, 100, 1);\ndrawokumi(600, 100, -1);\ndraweri();\nif (saveOneFrame == true) {\nendRecord();\nsaveOneFrame = false;\n}\nredraw();\n}\nvoid drawsode(int x, int y) {\nPVector sode1=new PVector(x, y);\nPVector sode2=new PVector(sode1.x+sodehaba, sode1.y);\nPVector sode3=new PVector(sode2.x, sode2.y+sodetuke);\nPVector sode4=new PVector(sode2.x, sode2.y+sodetake);\nPVector sode5=new PVector(sode4.x-sodehaba+sodemarumi, sode4.y);\nPVector sode6=new PVector(sode5.x-sodemarumi, sode5.y-sodemarumi);\nPVector sode7=new PVector(sode1.x, sode1.y+sodeguti);\nPVector sode8=new PVector(sode5.x, sode5.y-sodemarumi);\nPVector sode13=new PVector(sode2.x, sode2.y-sodetuke);\nPVector sode14=new PVector(sode2.x, sode2.y-sodetake);\nPVector sode15=new PVector(sode14.x-sodehaba+sodemarumi, sode14.y);\nPVector sode16=new PVector(sode15.x-sodemarumi, sode15.y+sodemarumi);\nPVector sode17=new PVector(sode1.x, sode1.y+sodeguti);\nPVector sode18=new PVector(sode15.x, sode15.y+sodemarumi);\nline(sode1.x, sode1.y, sode2.x, sode2.y);\nline(sode2.x, sode2.y, sode3.x, sode3.y);\nline(sode3.x, sode3.y, sode4.x, sode4.y);\nline(sode4.x, sode4.y, sode5.x, sode5.y);\nline(sode6.x, sode6.y, sode7.x, sode7.y);\nline(sode7.x, sode7.y, sode1.x, sode1.y);\narc(sode8.x, sode8.y, sodemarumi*2, sodemarumi*2, HALF_PI, PI);\nline(sode2.x, sode2.y, sode13.x, sode13.y);\nline(sode13.x, sode13.y, sode14.x, sode14.y);\nline(sode14.x, sode14.y, sode15.x, sode15.y);\nline(sode16.x, sode16.y, sode17.x, sode17.y);\nline(sode17.x, sode17.y, sode1.x, sode1.y);\narc(sode18.x, sode18.y, sodemarumi*2, sodemarumi*2, PI, PI+HALF_PI);\n}\n\nvoid drawmigoro(int x, int y, int dir) {\nkatahaba=(yuki\/2-1)*2*dir;\nmaehaba=(kosimawari\/2-7-15)*2*dir;\natohaba=((kosimawari\/2+7)\/2+2)*2*dir;\nerikataaki=8.5*2*dir;\nPVector migoro1=new PVector(x, y);\nPVector migoro2=new PVector(migoro1.x+katahaba-erikataaki, migoro1.y);\nPVector migoro3=new PVector(migoro2.x, migoro2.y+kurikosi);\nPVector migoro4=new PVector(migoro3.x+erikataaki, migoro3.y);\nPVector migoro5=new PVector(migoro4.x, migoro4.y+kitake-kurikosi);\nPVector migoro6=new PVector(migoro5.x-atohaba, migoro5.y);\nPVector migoro7=new PVector(migoro1.x+katahaba-atohaba, migoro1.y+sodetuke+miyatuguti);\nPVector migoro8=new PVector(migoro7.x, migoro1.y-sodetuke-miyatuguti);\nPVector migoro9=new PVector(migoro8.x, migoro8.y-kitake+sodetuke+miyatuguti);\nPVector migoro10=new PVector(migoro9.x+maehaba, migoro9.y);\nPVector migoro11=new PVector(migoro10.x-1, migoro10.y+kitake-okumisagari);\nPVector migoro12=new PVector(migoro1.x+maehaba, migoro1.y);\n\nline(migoro1.x, migoro1.y, migoro2.x, migoro2.y);\nline(migoro2.x, migoro2.y, migoro3.x, migoro3.y);\nline(migoro3.x, migoro3.y, migoro4.x, migoro4.y);\nline(migoro4.x, migoro4.y, migoro5.x, migoro5.y);\nline(migoro5.x, migoro5.y, migoro6.x, migoro6.y);\nline(migoro6.x, migoro6.y, migoro7.x, migoro7.y);\nline(migoro7.x, migoro7.y, migoro1.x, migoro1.y);\nline(migoro1.x, migoro1.y, migoro8.x, migoro8.y);\nline(migoro8.x, migoro8.y, migoro9.x, migoro9.y);\nline(migoro9.x, migoro9.y, migoro10.x, migoro10.y);\nline(migoro10.x, migoro10.y, migoro11.x, migoro11.y);\nline(migoro11.x, migoro11.y, migoro12.x, migoro12.y);\n}\n\nvoid drawokumi(int x, int y, int dir) {\nokumihaba=15.5*2*dir;\naiduma=14*2*dir;\nPVector okumi1=new PVector(x, y);\nPVector okumi2=new PVector(okumi1.x+okumihaba, okumi1.y);\nPVector okumi3=new PVector(okumi2.x, okumi2.y+kitake-okumisagari);\nPVector okumi4=new PVector(okumi3.x-aiduma, okumi1.y+erisita);\nline(okumi1.x, okumi1.y, okumi2.x, okumi2.y);\nline(okumi2.x, okumi2.y, okumi3.x, okumi3.y);\nline(okumi3.x, okumi3.y, okumi4.x, okumi4.y);\nline(okumi4.x, okumi4.y, okumi1.x, okumi1.y);\n}\n\nvoid draweri() {\nerikataaki=8.5*2;\nkensaki=6.5*2;\nkatamawari=5.5*2;\nerituke=30.5*2;\nPVector eri1=new PVector(700, 350);\nPVector eri2=new PVector(eri1.x, eri1.y+erikataaki+0.6*2);\nPVector eri3=new PVector(eri1.x, eri2.y+okumisagari);\nPVector eri4=new PVector(eri1.x, eri3.y+erituke);\nPVector eri5=new PVector(eri1.x+kensaki, eri4.y);\nPVector eri6=new PVector(eri3.x+kensaki, eri3.y);\nPVector eri7=new PVector(eri2.x+katamawari, eri2.y);\nPVector eri8=new PVector(eri7.x, eri1.y);\nPVector eri9=new PVector(eri1.x, eri1.y-erikataaki-0.6*2);\nPVector eri10=new PVector(eri1.x, eri9.y-okumisagari);\nPVector eri11=new PVector(eri1.x, eri10.y-erituke);\nPVector eri12=new PVector(eri1.x+kensaki, eri11.y);\nPVector eri13=new PVector(eri10.x+kensaki, eri10.y);\nPVector eri14=new PVector(eri9.x+katamawari, eri9.y);\n\nline(eri1.x, eri1.y, eri2.x, eri2.y);\nline(eri2.x, eri2.y, eri3.x, eri3.y);\nline(eri3.x, eri3.y, eri4.x, eri4.y);\nline(eri4.x, eri4.y, eri5.x, eri5.y);\nline(eri5.x, eri5.y, eri6.x, eri6.y);\nline(eri6.x, eri6.y, eri7.x, eri7.y);\nline(eri7.x, eri7.y, eri8.x, eri8.y);\nline(eri8.x, eri8.y, eri1.x, eri1.y);\n\nline(eri1.x, eri1.y, eri9.x, eri9.y);\nline(eri9.x, eri9.y, eri10.x, eri10.y);\nline(eri10.x, eri10.y, eri11.x, eri11.y);\nline(eri11.x, eri11.y, eri12.x, eri12.y);\nline(eri12.x, eri12.y, eri13.x, eri13.y);\nline(eri13.x, eri13.y, eri14.x, eri14.y);\nline(eri14.x, eri14.y, eri8.x, eri8.y);\n}\n\npublic void Height(int v) {\nHeight2 = v;\n}\npublic void Waist(int v) {\nWaist2 = v;\nif(kosimawari&amp;gt;yuki+24){\nWaist2=yuki+24;\n}\n}\npublic void Arm(int v) {\nArm2 = v;\nif(kosimawari&amp;gt;yuki+24){\nArm2=kosimawari-24;\n}\n}\nvoid radioButton(int a) {\nmode=a;\n}\n\npublic void Save(int theValue) {\nsaveOneFrame = true;\n}\n}\n\n\/\/\u30b9\u30b1\u30eb\u30c8\u30f3\nvoid drawSkeleton(int userId) {\nstrokeWeight(1);\n\n\/\/ to get the 3d joint data\ndrawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);\n\ndrawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);\ndrawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);\ndrawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);\n\ndrawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);\ndrawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);\ndrawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);\n\ndrawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);\ndrawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);\n\ndrawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);\ndrawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);\ndrawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);\n\ndrawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);\ndrawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);\ndrawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);\n\nPVector torso = new PVector();\nPVector waistR = new PVector();\nPVector waistL = new PVector();\nPVector waistC = new PVector();\nPVector waistProj= new PVector();\nPVector head = new PVector();\nPVector footR = new PVector();\nPVector footL = new PVector();\nPVector footC = new PVector();\nPVector shoulderC = new PVector();\nPVector shoulderR = new PVector();\nPVector shoulderL = new PVector();\nPVector elbowR = new PVector();\nPVector handR = new PVector();\nPVector top = new PVector();\n\ncontext.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_TORSO, torso);\ncontext.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_HIP, waistR);\ncontext.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_HIP, waistL);\ncontext.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, head);\ncontext.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_FOOT, footR);\ncontext.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_FOOT, footL);\ncontext.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, shoulderR);\ncontext.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, shoulderL);\ncontext.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, elbowR);\ncontext.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_HAND, handR);\nwaistC.set(((waistR.x+waistL.x)\/2+torso.x)\/2,(waistR.y+waistL.y+torso.y)\/3,((waistR.z+waistL.z)\/2+torso.z)\/2);\n\ncontext.convertRealWorldToProjective(waistC,waistProj);\n\/\/println(waistProj.x+&quot;,&quot;+waistProj.y+&quot;,&quot;+waistProj.z);\n\ntopIndex=int(head.x)+int(head.y)*context.depthWidth();\n\nfor(int i=0;i&amp;lt;context.depthWidth()*context.depthHeight();i++){\nif(userMap&#x5B;i]!=0){\ntop = context.depthMapRealWorld()&#x5B;i];\nbreak;\n}\n}\nwaistIndex=int(waistProj.x)+int(waistProj.y)*context.depthWidth();\nif(waistIndex&amp;lt;0)waistIndex=1;\nif(waistIndex&amp;gt;307200)waistIndex=307200-1;\nwhile(userMap != null &amp;amp;&amp;amp; userMap&#x5B;waistIndex] != 0){\nwaistIndex++;\n}\nwaistIndex--;\nwaistR=context.depthMapRealWorld()&#x5B;waistIndex];\nwaistRightIndex=waistIndex;\npoint(waistR.x,waistR.y,waistR.z);\n\nwaistIndex=int(waistProj.x)+int(waistProj.y)*context.depthWidth();\nif(waistIndex&amp;lt;0)waistIndex=1;\nif(waistIndex&amp;gt;307200)waistIndex=307200-1;\nwhile(userMap != null &amp;amp;&amp;amp; userMap&#x5B;waistIndex] != 0){\nwaistIndex--;\n}\nwaistIndex++;\nwaistL=context.depthMapRealWorld()&#x5B;waistIndex];\nwaistLeftIndex=waistIndex;\npoint(waistL.x,waistL.y,waistL.z);\nstrokeWeight(2);\nWaist=0;\nfor(int i=waistLeftIndex;i&amp;lt;waistRightIndex-10;i=i+10){\nWaist+=context.depthMapRealWorld()&#x5B;i].dist(context.depthMapRealWorld()&#x5B;i+10]);\n}\nWaist*=0.2;\nif(Waist&amp;lt;60)Waist=60;\nif(Waist&amp;gt;100)Waist=100;\nif(Waist&amp;gt;Arm+24){\nArm=Waist-24;\n}\nprintln(Waist);\nfootC.set((footR.x+footL.x)\/2, (footR.y+footL.y)\/2, (footR.z+footL.z)\/2);\nHeight=top.dist(footC)*0.105;\nArm=(shoulderR.dist(shoulderL)\/2+shoulderR.dist(elbowR)+elbowR.dist(handR))*0.1;\n\/\/println(shoulderR.dist(shoulderL)\/2+&quot;,&quot;+shoulderR.dist(elbowR)+&quot;,&quot;+elbowR.dist(handR));\n\/\/\u4f53\u306e\u5411\u304d\ngetBodyDirection(userId, bodyCenter, bodyDir);\n\nbodyDir.mult(200);\u00a0 \/\/ 200mm length\nbodyDir.add(bodyCenter);\n\nstroke(255, 200, 200);\nline(bodyCenter.x, bodyCenter.y, bodyCenter.z, bodyDir.x, bodyDir.y, bodyDir.z);\nstrokeWeight(1);\n}\n\n\/\/\u9aa8\u683c\u7dda\nvoid drawLimb(int userId, int jointType1, int jointType2) {\nPVector jointPos1 = new PVector();\nPVector jointPos2 = new PVector();\nfloat\u00a0 confidence;\n\n\/\/ draw the joint position\nconfidence = context.getJointPositionSkeleton(userId, jointType1, jointPos1);\nconfidence = context.getJointPositionSkeleton(userId, jointType2, jointPos2);\n\nstroke(255, 0, 0, confidence * 200 + 55);\nline(jointPos1.x, jointPos1.y, jointPos1.z,\njointPos2.x, jointPos2.y, jointPos2.z);\n\ndrawJointOrientation(userId, jointType1, jointPos1, 50);\ndrawJointOrientation(userId, jointType2, jointPos2, 50);\n}\n\n\/\/RGB\u306e3\u8ef8\u8868\u793a\nvoid drawJointOrientation(int userId, int jointType, PVector pos, float length)\n{\n\/\/ draw the joint orientation\nPMatrix3D\u00a0 orientation = new PMatrix3D();\nfloat confidence = context.getJointOrientationSkeleton(userId, jointType, orientation);\nif (confidence &amp;lt; 0.001f)\n\/\/ nothing to draw, orientation data is useless\nreturn;\n\npushMatrix();\ntranslate(pos.x, pos.y, pos.z);\n\n\/\/ set the local coordsys\napplyMatrix(orientation);\n\n\/\/ coordsys lines are 100mm long\n\/\/ x - r\nstroke(255, 0, 0, confidence * 200 + 55);\nline(0, 0, 0,\nlength, 0, 0);\n\/\/ y - g\nstroke(0, 255, 0, confidence * 200 + 55);\nline(0, 0, 0,\n0, length, 0);\n\/\/ z - b\nstroke(0, 0, 255, confidence * 200 + 55);\nline(0, 0, 0,\n0, 0, length);\npopMatrix();\n}\n\n\/\/ \u3053\u3053\u304b\u3089\u304a\u307e\u3058\u306a\u3044\n\/\/ SimpleOpenNI user events\n\nvoid onNewUser(int userId)\n{\nprintln(&quot;onNewUser - userId: &quot; + userId);\nprintln(&quot;\u00a0 start pose detection&quot;);\n\nif (autoCalib)\ncontext.requestCalibrationSkeleton(userId, true);\nelse\ncontext.startPoseDetection(&quot;Psi&quot;, userId);\n}\n\nvoid onLostUser(int userId)\n{\nprintln(&quot;onLostUser - userId: &quot; + userId);\n}\n\nvoid onExitUser(int userId)\n{\nprintln(&quot;onExitUser - userId: &quot; + userId);\n}\n\nvoid onReEnterUser(int userId)\n{\nprintln(&quot;onReEnterUser - userId: &quot; + userId);\n}\n\nvoid onStartCalibration(int userId)\n{\nprintln(&quot;onStartCalibration - userId: &quot; + userId);\n}\n\nvoid onEndCalibration(int userId, boolean successfull)\n{\nprintln(&quot;onEndCalibration - userId: &quot; + userId + &quot;, successfull: &quot; + successfull);\nHeight=150;\nWaist=70;\nArm=60;\n\nif (successfull)\n{\nprintln(&quot;\u00a0 User calibrated !!!&quot;);\ncontext.startTrackingSkeleton(userId);\n}\nelse\n{\nprintln(&quot;\u00a0 Failed to calibrate user !!!&quot;);\nprintln(&quot;\u00a0 Start pose detection&quot;);\ncontext.startPoseDetection(&quot;Psi&quot;, userId);\n}\n}\n\nvoid onStartPose(String pose, int userId)\n{\nprintln(&quot;onStartdPose - userId: &quot; + userId + &quot;, pose: &quot; + pose);\nprintln(&quot; stop pose detection&quot;);\n\ncontext.stopPoseDetection(userId);\ncontext.requestCalibrationSkeleton(userId, true);\n}\n\nvoid onEndPose(String pose, int userId)\n{\nprintln(&quot;onEndPose - userId: &quot; + userId + &quot;, pose: &quot; + pose);\n}\n\n\/\/ -----------------------------------------------------------------\n\/\/ Keyboard events\n\nvoid keyPressed()\n{\nswitch(key)\n{\ncase ' ':\ncontext.setMirror(!context.mirror());\nbreak;\n}\n\nswitch(keyCode)\n{\ncase LEFT:\nrotY += 0.1f;\nbreak;\ncase RIGHT:\n\/\/ zoom out\nrotY -= 0.1f;\nbreak;\ncase UP:\nif (keyEvent.isShiftDown())\nzoomF += 0.01f;\nelse\nrotX += 0.1f;\nbreak;\ncase DOWN:\nif (keyEvent.isShiftDown())\n{\nzoomF -= 0.01f;\nif (zoomF &amp;lt; 0.01)\nzoomF = 0.01;\n}\nelse\nrotX -= 0.1f;\nbreak;\n}\n}\n\nvoid getBodyDirection(int userId, PVector centerPoint, PVector dir)\n{\nPVector jointL = new PVector();\nPVector jointH = new PVector();\nPVector jointR = new PVector();\nfloat\u00a0 confidence;\n\n\/\/ draw the joint position\nconfidence = context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, jointL);\nconfidence = context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, jointH);\nconfidence = context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, jointR);\n\n\/\/ take the neck as the center point\nconfidence = context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_NECK, centerPoint);\n\n\/*\u00a0 \/\/ manually calc the centerPoint\nPVector shoulderDist = PVector.sub(jointL,jointR);\ncenterPoint.set(PVector.mult(shoulderDist,.5));\ncenterPoint.add(jointR);\n*\/\n\nPVector up = new PVector();\nPVector left = new PVector();\n\nup.set(PVector.sub(jointH, centerPoint));\nleft.set(PVector.sub(jointR, centerPoint));\n\ndir.set(up.cross(left));\ndir.normalize();\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>ORF\u3067\u4f7f\u3063\u305f\u300c\u670d\u306e\u578b\u7d19\u3092\u81ea\u52d5\u3067\u30ea\u30b5\u30a4\u30ba\u3057\u3066\u304f\u308c\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u300d\u306e\u30b3\u30fc\u30c9\u3092\u3068\u308a\u3042\u3048&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/www.syuheiuda.com\/?p=552\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_locale":"","_original_post":""},"categories":[5,32,15],"tags":[],"views":6306,"_links":{"self":[{"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/posts\/552"}],"collection":[{"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=552"}],"version-history":[{"count":0,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/posts\/552\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}