32 #include "DeviceManager.h" 33 #include "core/DataSkeleton.h" 34 #include "objects/KinectDevice.h" 35 #include "generator/User.h" 37 #include <ScolPlugin.h> 38 #include <scolMemoryHelper.hpp> 53 int SCOL_KINECT_CONNECTED_CB = 0;
54 int KINECT_CONNECTED_CB;
57 int SCOL_KINECT_DISCONNECTED_CB = 1;
58 int KINECT_DISCONNECTED_CB;
62 int OBJ_KINECT_USER_SCOL;
65 int SCOL_KINECT_USER_CALIBRATION_START_CB = 0;
66 int KINECT_USER_CALIBRATION_START_CB;
69 int SCOL_KINECT_USER_CALIBRATION_END_CB = 1;
70 int KINECT_USER_CALIBRATION_END_CB;
73 int SCOL_KINECT_USER_POSE_DETECTED_CB = 2;
74 int KINECT_USER_POSE_DETECTED_CB;
77 int SCOL_KINECT_USER_POSE_LOST_CB = 3;
78 int KINECT_USER_POSE_LOST_CB;
81 int SCOL_KINECT_NEW_USER_CB = 4;
82 int KINECT_NEW_USER_CB;
85 int SCOL_KINECT_LOST_USER_CB = 5;
86 int KINECT_LOST_USER_CB;
89 int SCOL_KINECT_USER_HAND_FOUND_CB = 6;
90 int KINECT_USER_HAND_FOUND_CB;
93 int SCOL_KINECT_USER_HAND_LOST_CB = 7;
94 int KINECT_USER_HAND_LOST_CB;
97 int SCOL_KINECT_USER_HAND_MOVE_CB = 8;
98 int KINECT_USER_HAND_MOVE_CB;
123 int destroyKinectUserObj(mmachine m, SCOL_PTR_TYPE handsys,
int objTab)
126 KinectUser* kinectUserObject = MMgetPointer<KinectUser*>(m, MTOP(objTab));
128 if (kinectUserObject != 0)
129 kinectUserObject->GetParentDevice()->DestroyKinectUser(kinectUserObject);
131 MMsetPointer(m, MTOP(objTab), NULL);
134 MMechostr(MSKDEBUG,
"ObjKinectUser destroyed.\n");
148 int destroyKinectObj(mmachine m, SCOL_PTR_TYPE handsys,
int objTab)
151 KinectDevice* kinectObject = MMgetPointer<KinectDevice*>(m, MTOP(objTab));
153 if (kinectObject != 0)
154 DeviceManager::GetSingletonPtr()->DestroyKinectDevice(kinectObject);
156 MMsetPointer(m, MTOP(objTab), NULL);
159 MMechostr(MSKDEBUG,
"ObjKinect destroyed.\n");
176 MMechostr(MSKDEBUG,
"_CRKinectDevice\n");
182 if ((DeviceManager::GetSingletonPtr()) == 0)
189 KinectDevice* newKinectDevice = DeviceManager::GetSingletonPtr()->CreateKinectDevice();
190 if (newKinectDevice == 0)
192 MMechostr(MSKDEBUG,
"_CRobjKinect ...creation failed\n");
193 SAFE_DELETE(newKinectDevice);
197 MMechostr(MSKDEBUG,
"_CRobjKinect ...creation successful\n");
199 if ((MMpushPointer(m, newKinectDevice) != 0))
201 SAFE_DELETE(newKinectDevice);
207 k = OBJcreate(m, OBJ_KINECT_SCOL, SCOL_PTR newKinectDevice, NIL, 0);
208 MMechostr(MSKDEBUG,
"_CRobjKinectDevice ...object creation successful\n");
211 MMechostr(MSKDEBUG,
"ok\n");
229 MMechostr(MSKDEBUG,
"_DSKinectDevice\n");
232 int objTab = MMget(m, 0);
239 OBJdelTM( m, OBJ_KINECT_SCOL, objTab);
240 MMset(m, 0, ITOM(1));
243 MMechostr(MSKDEBUG,
"ok\n");
260 MMechostr(MSKDEBUG,
"_GETKinectDeviceById\n");
264 int kId = MMget(m, 0);
271 KinectDevice* newKinectDevice = DeviceManager::GetSingletonPtr()->GetKinectDevice(kId);
272 if (newKinectDevice == 0)
274 MMechostr(MSKDEBUG,
"_GETKinectDeviceById ... not found\n");
279 int kin = OBJfindTH(m, OBJ_KINECT_SCOL, SCOL_PTR newKinectDevice);
281 kin = MMfetch(m, kin, OFFOBJMAG);
286 MMechostr(MSKDEBUG,
"ok\n");
302 MMechostr(MSKDEBUG,
"_GETKinectDeviceId\n");
305 int objTab = MMget(m, 0);
312 KinectDevice* kinectObject = MMgetPointer<KinectDevice*>(m, MTOP(objTab));
313 if(kinectObject==NULL)
319 MMset(m, 0, ITOM(kinectObject->GetId()));
322 MMechostr(MSKDEBUG,
"ok\n");
338 MMechostr(MSKDEBUG,
"_GETKinectDeviceSize\n");
341 int objTab = MMget(m, 0);
348 KinectDevice* kinectObject = MMgetPointer<KinectDevice*>(m, MTOP(objTab));
349 if(kinectObject==NULL)
355 int tuple = MMmalloc(m, 2, TYPETAB);
366 kinectObject->GetGeneratorsSize(width, height);
367 MMstore(m, tuple, 0, ITOM(width));
368 MMstore(m, tuple, 1, ITOM(height));
369 MMset(m, 0, PTOM(tuple));
373 MMechostr(MSKDEBUG,
"ok\n");
390 MMechostr(MSKDEBUG,
"_BLTKinectDeviceDepth\n");
393 int bitmap = MMpull(m);
394 int kinect = MMget(m, 0);
395 if (kinect == NIL || bitmap == NIL)
401 KinectDevice* KinectOBJ = MMgetPointer<KinectDevice*>(m, MTOP(kinect));
402 if (KinectOBJ == NULL)
408 if(!KinectOBJ->IsConnected())
415 PtrObjVoid OB = (PtrObjVoid) MMstart(m, MTOP(bitmap));
416 PtrObjBitmap B = (PtrObjBitmap) MMstart(m, MTOP(OB->Buffer));
418 KinectOBJ->GetDepthBuffer(B);
424 MMechostr(MSKDEBUG,
"ok\n");
440 MMechostr(MSKDEBUG,
"_BLTKinectDeviceRGB\n");
443 int bitmap = MMpull(m);
444 int kinect = MMget(m, 0);
445 if (kinect == NIL || bitmap == NIL)
452 KinectDevice* KinectOBJ = MMgetPointer<KinectDevice*>(m, MTOP(kinect));
453 if (KinectOBJ == NULL)
459 if(!KinectOBJ->IsConnected())
466 PtrObjVoid OB = (PtrObjVoid) MMstart(m, MTOP(bitmap));
467 PtrObjBitmap B = (PtrObjBitmap) MMstart(m, MTOP(OB->Buffer));
469 KinectOBJ->GetImageBuffer(B);
474 MMechostr(MSKDEBUG,
"ok\n");
490 MMechostr(MSKDEBUG,
"_BLTKinectDeviceGrayscale\n");
493 int bitmap = MMpull(m);
494 int kinect = MMget(m, 0);
495 if (kinect == NIL || bitmap == NIL)
502 KinectDevice* KinectOBJ = MMgetPointer<KinectDevice*>(m, MTOP(kinect));
503 if (KinectOBJ == NULL)
509 if(!KinectOBJ->IsConnected())
516 PtrObjVoid OB = (PtrObjVoid) MMstart(m, MTOP(bitmap));
517 PtrObjBitmap B = (PtrObjBitmap) MMstart(m, MTOP(OB->Buffer));
519 KinectOBJ->GetImageGreyBuffer(B);
521 MMset(m, 0, PTOM(bitmap));
524 MMechostr(MSKDEBUG,
"ok\n");
540 MMechostr(MSKDEBUG,
"_BLTKinectDeviceRGB\n");
543 int bitmap = MMpull(m);
544 int kinect = MMget(m, 0);
545 if (kinect == NIL || bitmap == NIL)
552 KinectDevice* KinectOBJ = MMgetPointer<KinectDevice*>(m, MTOP(kinect));
553 if (KinectOBJ == NULL)
559 if(!KinectOBJ->IsConnected())
566 int colorLayer = MMfetch(m, MTOP(bitmap), 0);
567 int alphaLayer = MMfetch(m, MTOP(bitmap), 1);
571 OBcolor = (PtrObjVoid) MMstart(m, MTOP(colorLayer));
572 if(OBcolor->Type != OBJ_TYPE_BITMAP << 1)
577 Bcolor = (PtrObjBitmap) MMstart(m, MTOP(OBcolor->Buffer));
581 OBalpha = (PtrObjVoid) MMstart(m, MTOP(alphaLayer));
582 if(OBalpha->Type != OBJ_TYPE_BITMAP << 1)
587 Balpha = (PtrObjBitmap) MMstart(m,MTOP(OBalpha->Buffer));
589 KinectOBJ->GetValidUserPixels(Bcolor, Balpha);
594 MMechostr(MSKDEBUG,
"ok\n");
610 MMechostr(MSKDEBUG,
"_BLTKinectDeviceUsersRGB\n");
613 int bitmap = MMpull(m);
614 int kinect = MMget(m, 0);
615 if (kinect == NIL || bitmap == NIL)
622 KinectDevice* KinectOBJ = MMgetPointer<KinectDevice*>(m, MTOP(kinect));
623 if (KinectOBJ == NULL)
629 if(!KinectOBJ->IsConnected())
636 int colorLayer = MMfetch(m, MTOP(bitmap), 0);
637 int alphaLayer = MMfetch(m, MTOP(bitmap), 1);
641 OBcolor = (PtrObjVoid) MMstart(m, MTOP(colorLayer));
642 if(OBcolor->Type != OBJ_TYPE_BITMAP << 1)
647 Bcolor = (PtrObjBitmap) MMstart(m, MTOP(OBcolor->Buffer));
651 OBalpha = (PtrObjVoid) MMstart(m, MTOP(alphaLayer));
652 if(OBalpha->Type != OBJ_TYPE_BITMAP << 1)
657 Balpha = (PtrObjBitmap) MMstart(m,MTOP(OBalpha->Buffer));
659 KinectOBJ->GetValidUserPixelsRGB(Bcolor, Balpha);
664 MMechostr(MSKDEBUG,
"ok\n");
680 MMechostr(MSKDEBUG,
"_BLTKinectDeviceHands\n");
683 int bitmap = MMpull(m);
684 int kinect = MMget(m, 0);
685 if (kinect == NIL || bitmap == NIL)
692 KinectDevice* KinectOBJ = MMgetPointer<KinectDevice*>(m, MTOP(kinect));
693 if (KinectOBJ == NULL)
699 if(!KinectOBJ->IsConnected())
706 int colorLayer = MMfetch(m, MTOP(bitmap), 0);
707 int alphaLayer = MMfetch(m, MTOP(bitmap), 1);
711 OBcolor = (PtrObjVoid) MMstart(m, MTOP(colorLayer));
712 if(OBcolor->Type != OBJ_TYPE_BITMAP << 1)
717 Bcolor = (PtrObjBitmap) MMstart(m, MTOP(OBcolor->Buffer));
721 OBalpha = (PtrObjVoid) MMstart(m, MTOP(alphaLayer));
722 if(OBalpha->Type != OBJ_TYPE_BITMAP << 1)
727 Balpha = (PtrObjBitmap) MMstart(m, MTOP(OBalpha->Buffer));
729 KinectOBJ->GetHandsPixels(Bcolor, Balpha);
734 MMechostr(MSKDEBUG,
"ok\n");
750 MMechostr(MSKDEBUG,
"_SETKinectDeviceMirror\n");
753 int mode = MMpull(m);
754 int kinect = MMget(m, 0);
762 KinectDevice* KinectOBJ = MMgetPointer<KinectDevice*>(m, MTOP(kinect));
763 if (KinectOBJ == NULL)
773 KinectOBJ->SetMirrorMode(bMode);
775 MMset(m, 0, ITOM(1));
778 MMechostr(MSKDEBUG,
"ok\n");
793 MMechostr(MSKDEBUG,
"_GETKinectDeviceMirror\n");
796 int kinect = MMget(m, 0);
804 KinectDevice* KinectOBJ = MMgetPointer<KinectDevice*>(m, MTOP(kinect));
805 if (KinectOBJ == NULL)
811 bool bMode = KinectOBJ->GetMirrorMode();;
813 MMset(m, 0, ITOM(bMode ==
true ? 1 : 0));
816 MMechostr(MSKDEBUG,
"ok\n");
834 MMechostr(MSKDEBUG,
"_SETKinectDeviceSkeletonSmoothing\n");
837 int ismooth = MMpull(m);
838 int kinect = MMget(m, 0);
846 KinectDevice* KinectOBJ = MMgetPointer<KinectDevice*>(m, MTOP(kinect));
847 if (KinectOBJ == NULL)
853 float fsmooth = 0.0f;
854 if ((ismooth != NIL) && (MTOF(ismooth) > 0.0f))
855 fsmooth = MTOF(ismooth);
857 if ((fsmooth) > 1.0f)
860 KinectOBJ->SetSkeletonSmoothing(fsmooth);
862 MMset(m, 0, ITOM(1));
865 MMechostr(MSKDEBUG,
"ok\n");
882 MMechostr(MSKDEBUG,
"_GETKinectDeviceSkeletonSmoothing\n");
885 int kinect = MMget(m, 0);
893 KinectDevice* KinectOBJ = MMgetPointer<KinectDevice*>(m, MTOP(kinect));
894 if (KinectOBJ == NULL)
900 float smooth = KinectOBJ->GetSkeletonSmoothing();
902 MMset(m, 0, FTOM(smooth));
905 MMechostr(MSKDEBUG,
"ok\n");
923 MMechostr(MSKDEBUG,
"_SETKinectDeviceDetectionDistance\n");
926 int idist = MMpull(m);
927 int kinect = MMget(m, 0);
935 KinectDevice* KinectOBJ = MMgetPointer<KinectDevice*>(m, MTOP(kinect));
936 if (KinectOBJ == NULL)
943 if ((idist != NIL) && (MTOI(idist) > 0))
944 dist = MTOI(idist) * 10;
946 KinectOBJ->SetDistCutoff(dist);
948 MMset(m, 0, ITOM(1));
951 MMechostr(MSKDEBUG,
"ok\n");
968 MMechostr(MSKDEBUG,
"_GETKinectDeviceDetectionDistance\n");
971 int kinect = MMget(m, 0);
979 KinectDevice* KinectOBJ = MMgetPointer<KinectDevice*>(m, MTOP(kinect));
980 if (KinectOBJ == NULL)
986 int dist = KinectOBJ->GetDistCutoff();
988 MMset(m, 0, ITOM(dist / 10));
991 MMechostr(MSKDEBUG,
"ok\n");
1009 MMechostr(MSKDEBUG,
"_SETKinectDeviceDetectionAngle\n");
1012 int iangle = MMpull(m);
1013 int kinect = MMget(m, 0);
1021 KinectDevice* KinectOBJ = MMgetPointer<KinectDevice*>(m, MTOP(kinect));
1022 if (KinectOBJ == NULL)
1029 if ((iangle != NIL) && (MTOF(iangle) > 0))
1030 fang = MTOF(iangle);
1032 KinectOBJ->SetAngCutoff(fang);
1034 MMset(m, 0, ITOM(1));
1037 MMechostr(MSKDEBUG,
"ok\n");
1054 MMechostr(MSKDEBUG,
"_GETKinectDeviceDetectionAngle\n");
1057 int kinect = MMget(m, 0);
1065 KinectDevice* KinectOBJ = MMgetPointer<KinectDevice*>(m, MTOP(kinect));
1066 if (KinectOBJ == NULL)
1072 float fdist = KinectOBJ->GetAngCutoff();
1074 MMset(m, 0, FTOM(fdist));
1077 MMechostr(MSKDEBUG,
"ok\n");
1095 return OBJaddreflex(m, OBJ_KINECT_SCOL, SCOL_KINECT_CONNECTED_CB);
1098 int getKinectConnectedCb(mmachine m, SCOL_PTR_TYPE
id, LONG param)
1103 if (OBJbeginreflex(m, OBJ_KINECT_SCOL, SCOL_PTR mKinectObj, SCOL_KINECT_CONNECTED_CB))
1105 if ((k=OBJcallreflex(m, 0)))
return k;
1122 return OBJaddreflex(m, OBJ_KINECT_SCOL, SCOL_KINECT_DISCONNECTED_CB);
1125 int getKinectDisconnectedCb(mmachine m, SCOL_PTR_TYPE
id, LONG param)
1130 if (OBJbeginreflex(m, OBJ_KINECT_SCOL, SCOL_PTR mKinectObj, SCOL_KINECT_DISCONNECTED_CB))
1132 if ((k=OBJcallreflex(m, 0)))
return k;
1149 MMechostr(MSKDEBUG,
"_CRKinectUser\n");
1154 int ikindevice = MMpull(m);
1155 if (ikindevice == NIL)
1162 KinectDevice* kinectDevice = MMgetPointer<KinectDevice*>(m, MTOP(ikindevice));
1163 if(kinectDevice==NULL)
1165 MMechostr(MSKDEBUG,
"Device NIL\n");
1171 KinectUser* newKinectUser = kinectDevice->CreateKinectUser();
1172 if (newKinectUser == 0)
1174 MMechostr(MSKDEBUG,
"_CRKinectUser ...creation failed\n");
1175 SAFE_DELETE(newKinectUser);
1179 MMechostr(MSKDEBUG,
"_CRKinectUser ...creation successful\n");
1182 if ((MMpushPointer(m, newKinectUser) != 0))
1184 SAFE_DELETE(newKinectUser);
1190 k = OBJcreate(m, OBJ_KINECT_USER_SCOL, SCOL_PTR newKinectUser, OBJ_KINECT_SCOL, (
int)kinectDevice);
1191 MMechostr(MSKDEBUG,
"_CRKinectUser ...object creation successful\n");
1194 MMechostr(MSKDEBUG,
"ok\n");
1212 MMechostr(MSKDEBUG,
"_DSKinectUser\n");
1215 int objTab = MMget(m, 0);
1222 OBJdelTM( m, OBJ_KINECT_USER_SCOL, objTab);
1223 MMset(m, 0, ITOM(1));
1226 MMechostr(MSKDEBUG,
"ok\n");
1244 return OBJaddreflex(m, OBJ_KINECT_USER_SCOL, SCOL_KINECT_NEW_USER_CB);
1247 int getKinectNewUserCb(mmachine m, SCOL_PTR_TYPE
id, LONG param)
1252 if (OBJbeginreflex(m, OBJ_KINECT_USER_SCOL, SCOL_PTR mKinectUserObj, SCOL_KINECT_NEW_USER_CB))
1254 if ((k=OBJcallreflex(m, 0)))
return k;
1271 return OBJaddreflex(m, OBJ_KINECT_USER_SCOL, SCOL_KINECT_LOST_USER_CB);
1274 int getKinectLostUserCb(mmachine m, SCOL_PTR_TYPE
id, LONG param)
1279 if (OBJbeginreflex(m, OBJ_KINECT_USER_SCOL, SCOL_PTR mKinectUserObj, SCOL_KINECT_LOST_USER_CB))
1281 if ((k=OBJcallreflex(m, 0)))
return k;
1298 return OBJaddreflex(m, OBJ_KINECT_USER_SCOL, SCOL_KINECT_USER_CALIBRATION_START_CB);
1301 int getKinectUserCalibrationStartCb(mmachine m, SCOL_PTR_TYPE
id, LONG param)
1306 if (OBJbeginreflex(m, OBJ_KINECT_USER_SCOL, SCOL_PTR mKinectUserObj, SCOL_KINECT_USER_CALIBRATION_START_CB))
1308 if ((k=OBJcallreflex(m, 0)))
return k;
1325 return OBJaddreflex(m, OBJ_KINECT_USER_SCOL, SCOL_KINECT_USER_CALIBRATION_END_CB);
1328 int getKinectUserCalibrationEndCb(mmachine m, SCOL_PTR_TYPE
id, LONG param)
1333 if (OBJbeginreflex(m, OBJ_KINECT_USER_SCOL, SCOL_PTR mKinectUserObj, SCOL_KINECT_USER_CALIBRATION_END_CB))
1335 if ((k=OBJcallreflex(m, 0)))
return k;
1352 return OBJaddreflex(m, OBJ_KINECT_USER_SCOL, SCOL_KINECT_USER_POSE_DETECTED_CB);
1355 int getKinectUserPoseDetectedCb(mmachine m, SCOL_PTR_TYPE
id, LONG param)
1360 if (OBJbeginreflex(m, OBJ_KINECT_USER_SCOL, SCOL_PTR mKinectUserObj, SCOL_KINECT_USER_POSE_DETECTED_CB))
1362 if ((k=OBJcallreflex(m, 0)))
return k;
1379 return OBJaddreflex(m, OBJ_KINECT_USER_SCOL, SCOL_KINECT_USER_POSE_LOST_CB);
1382 int getKinectUserPoseLostCb(mmachine m, SCOL_PTR_TYPE
id, LONG param)
1387 if (OBJbeginreflex(m, OBJ_KINECT_USER_SCOL, SCOL_PTR mKinectUserObj, SCOL_KINECT_USER_POSE_LOST_CB))
1389 if ((k=OBJcallreflex(m, 0)))
return k;
1407 return OBJaddreflex(m, OBJ_KINECT_USER_SCOL, SCOL_KINECT_USER_HAND_FOUND_CB);
1410 int getKinectUserHandFoundCb(mmachine m, SCOL_PTR_TYPE
id, LONG param)
1415 if (OBJbeginreflex(m, OBJ_KINECT_USER_SCOL, SCOL_PTR mKinectUserObj, SCOL_KINECT_USER_HAND_FOUND_CB))
1418 MMpush(m, ITOM((
int)param));
1420 if ((k=OBJcallreflex(m, 1)))
return k;
1438 return OBJaddreflex(m, OBJ_KINECT_USER_SCOL, SCOL_KINECT_USER_HAND_LOST_CB);
1441 int getKinectUserHandLostCb(mmachine m, SCOL_PTR_TYPE
id, LONG param)
1446 if (OBJbeginreflex(m, OBJ_KINECT_USER_SCOL, SCOL_PTR mKinectUserObj, SCOL_KINECT_USER_HAND_LOST_CB))
1449 MMpush(m, ITOM((
int)param));
1451 if ((k=OBJcallreflex(m, 1)))
return k;
1470 return OBJaddreflex(m, OBJ_KINECT_USER_SCOL, SCOL_KINECT_USER_HAND_MOVE_CB);
1473 int getKinectUserHandMoveCb(mmachine m, SCOL_PTR_TYPE
id, LONG param)
1479 if (OBJbeginreflex(m, OBJ_KINECT_USER_SCOL, SCOL_PTR mKinectUserObj, SCOL_KINECT_USER_HAND_MOVE_CB))
1482 nite::Point3f transVec = mKinectUserHand->GetLastTransVec();
1484 MMpush(m, ITOM((
int)mKinectUserHand->GetType()));
1486 int tuple = MMmalloc(m, 3, TYPETAB);
1490 MMstore(m, tuple, 0, ITOM((
int)transVec.x));
1491 MMstore(m, tuple, 1, ITOM((
int)transVec.y));
1492 MMstore(m, tuple, 2, ITOM((
int)transVec.z));
1493 MMpush(m, PTOM(tuple));
1495 if ((k=OBJcallreflex(m, 2)))
return k;
1514 MMechostr(MSKDEBUG,
"_GETKinectUserJointPixelPosition\n");
1517 int iConfidence = MMpull(m);
1518 int bId = MMpull(m);
1519 int objTab = MMget(m, 0);
1520 if ((objTab == NIL) || (bId == NIL))
1525 KinectUser* KinectUserOBJ = MMgetPointer<KinectUser*>(m, MTOP(objTab));
1533 float fConfidence = 0.0f;
1534 if ((iConfidence != NIL) || (MTOF(iConfidence) > 0.0f))
1535 fConfidence = MTOF(iConfidence);
1537 nite::Point3f result;
1538 if(KinectUserOBJ->GetBoneImgCoordinates((nite::JointType)(MTOI(bId)), result, fConfidence))
1540 int tuple = MMmalloc(m, 3, TYPETAB);
1544 MMstore(m, tuple, 0, ITOM((
int)result.x));
1545 MMstore(m, tuple, 1, ITOM((
int)result.y));
1546 MMstore(m, tuple, 2, ITOM((
int)result.z));
1547 MMset(m, 0, PTOM(tuple));
1555 MMechostr(MSKDEBUG,
"ok\n");
1573 MMechostr(MSKDEBUG,
"_GETKinectUserHandVisible\n");
1576 int bId = MMpull(m);
1577 int objTab = MMget(m, 0);
1578 if ((objTab == NIL) || (bId == NIL))
1583 KinectUser* KinectUserOBJ = MMgetPointer<KinectUser*>(m, MTOP(objTab));
1591 if (KinectUserOBJ->IsHandVisible((nite::JointType)(MTOI(bId))))
1592 MMset(m, 0, ITOM(1));
1594 MMset(m, 0, ITOM(0));
1597 MMechostr(MSKDEBUG,
"ok\n");
1616 MMechostr(MSKDEBUG,
"_GETKinectUserFingersPixelPosition\n");
1619 int bId = MMpull(m);
1620 int objTab = MMget(m, 0);
1621 if ((objTab == NIL) || (bId == NIL))
1626 KinectUser* KinectUserOBJ = MMgetPointer<KinectUser*>(m, MTOP(objTab));
1637 vector<cv::Point> result;
1638 if(KinectUserOBJ->GetFingersPixelPosition((nite::JointType)(MTOI(bId)), result))
1640 for (
int i=0; i<(int)result.size(); i++)
1642 int tuple = MMmalloc(m, 2, TYPETAB);
1646 MMstore(m, tuple, 0, ITOM((
int)result[i].x));
1647 MMstore(m, tuple, 1, ITOM((
int)result[i].y));
1648 MMpush(m, PTOM(tuple));
1654 for(
size_t j=0; j<result.size(); j++)
1659 if(
int k=MBdeftab(m))
1669 MMechostr(MSKDEBUG,
"ok\n");
1688 MMechostr(MSKDEBUG,
"_GETKinectUserJointPosition\n");
1691 int iConfidence = MMpull(m);
1692 int bId = MMpull(m);
1693 int objTab = MMget(m, 0);
1694 if ((objTab == NIL) || (bId == NIL))
1699 KinectUser* KinectUserOBJ = MMgetPointer<KinectUser*>(m, MTOP(objTab));
1707 float fConfidence = 0.0f;
1708 if ((iConfidence != NIL) || (MTOF(iConfidence) > 0.0f))
1709 fConfidence = MTOF(iConfidence);
1711 nite::Point3f result;
1712 if(KinectUserOBJ->GetBoneCurrentPosition((nite::JointType)(MTOI(bId)), result, fConfidence))
1714 int tuple = MMmalloc(m, 3, TYPETAB);
1721 MMstore(m, tuple, 0, FTOM((result.x * 0.1f)));
1722 MMstore(m, tuple, 1, FTOM((result.y * 0.1f)));
1723 MMstore(m, tuple, 2, FTOM((result.z * 0.1f)));
1724 MMset(m, 0, PTOM(tuple));
1733 MMechostr(MSKDEBUG,
"ok\n");
1752 MMechostr(MSKDEBUG,
"_GETKinectUserJointOrientation\n");
1755 int iConfidence = MMpull(m);
1756 int bId = MMpull(m);
1757 int objTab = MMget(m, 0);
1758 if ((objTab == NIL) || (bId == NIL))
1764 KinectUser* KinectUserOBJ = MMgetPointer<KinectUser*>(m, MTOP(objTab));
1772 float fConfidence = 0.0f;
1773 if ((iConfidence != NIL) || (MTOF(iConfidence) > 0.0f))
1774 fConfidence = MTOF(iConfidence);
1777 if(KinectUserOBJ->GetBoneCurrentOrientation((nite::JointType)(MTOI(bId)), &result, fConfidence))
1779 int tuple = MMmalloc(m, 4, TYPETAB);
1786 MMstore(m, tuple, 0, FTOM(result.x));
1787 MMstore(m, tuple, 1, FTOM(result.y));
1788 MMstore(m, tuple, 2, FTOM(result.z));
1789 MMstore(m, tuple, 3, FTOM(result.w));
1790 MMset(m, 0, PTOM(tuple));
1799 MMechostr(MSKDEBUG,
"ok\n");
1806 #define NbKinectPKG 63 1811 char *KinectName[NbKinectPKG] =
1817 "_GETKinectDeviceById",
1818 "_GETKinectDeviceId",
1819 "_GETKinectDeviceSize",
1820 "_BLTKinectDeviceDepth",
1821 "_BLTKinectDeviceRGB",
1822 "_BLTKinectDeviceGrayscale",
1823 "_BLTKinectDeviceUsers",
1824 "_BLTKinectDeviceUsersRGB",
1825 "_BLTKinectDeviceHands",
1826 "_SETKinectDeviceMirror",
1827 "_GETKinectDeviceMirror",
1828 "_SETKinectDeviceSkeletonSmoothing",
1829 "_GETKinectDeviceSkeletonSmoothing",
1830 "_SETKinectDeviceDetectionDistance",
1831 "_GETKinectDeviceDetectionDistance",
1832 "_SETKinectDeviceDetectionAngle",
1833 "_GETKinectDeviceDetectionAngle",
1837 "_CBKinectConnected",
1838 "_CBKinectDisconnected",
1839 "_CBKinectUserFound",
1840 "_CBKinectUserLost",
1841 "_CBKinectUserCalibrationStart",
1842 "_CBKinectUserCalibrationEnd",
1843 "_CBKinectUserPoseDetected",
1844 "_CBKinectUserPoseLost",
1845 "_CBKinectUserHandFound",
1846 "_CBKinectUserHandLost",
1847 "_CBKinectUserHandMove",
1849 "_GETKinectUserJointPosition",
1850 "_GETKinectUserJointOrientation",
1851 "_GETKinectUserJointPixelPosition",
1852 "_GETKinectUserFingersPixelPosition",
1853 "_GETKinectUserHandVisible",
1855 "USER_SKEL_HEAD",
"USER_SKEL_NECK",
"USER_SKEL_TORSO",
1856 "USER_SKEL_WAIST",
"USER_SKEL_L_COLLAR",
"USER_SKEL_L_SHOULDER",
1857 "USER_SKEL_L_ELBOW",
"USER_SKEL_L_WRIST",
"USER_SKEL_L_HAND",
1858 "USER_SKEL_L_FINGERTIP",
"USER_SKEL_R_COLLAR",
"USER_SKEL_R_SHOULDER",
1859 "USER_SKEL_R_ELBOW",
"USER_SKEL_R_WRIST",
"USER_SKEL_R_HAND",
1860 "USER_SKEL_R_FINGERTIP",
"USER_SKEL_L_HIP",
"USER_SKEL_L_KNEE",
1861 "USER_SKEL_L_ANKLE",
"USER_SKEL_L_FOOT",
"USER_SKEL_R_HIP",
1862 "USER_SKEL_R_KNEE",
"USER_SKEL_R_ANKLE",
"USER_SKEL_R_FOOT" 1868 int (*KinectFunc[NbKinectPKG])(mmachine m)=
1912 SCOL_TYPTYPE(nite::JOINT_HEAD), SCOL_TYPTYPE(nite::JOINT_NECK), SCOL_TYPTYPE(nite::JOINT_TORSO),
1913 SCOL_TYPTYPE(0), SCOL_TYPTYPE(0), SCOL_TYPTYPE(nite::JOINT_LEFT_SHOULDER),
1914 SCOL_TYPTYPE(nite::JOINT_LEFT_ELBOW), SCOL_TYPTYPE(0), SCOL_TYPTYPE(nite::JOINT_LEFT_HAND),
1915 SCOL_TYPTYPE(0), SCOL_TYPTYPE(0), SCOL_TYPTYPE(nite::JOINT_RIGHT_SHOULDER),
1916 SCOL_TYPTYPE(nite::JOINT_RIGHT_ELBOW), SCOL_TYPTYPE(0), SCOL_TYPTYPE(nite::JOINT_RIGHT_HAND),
1917 SCOL_TYPTYPE(0), SCOL_TYPTYPE(nite::JOINT_LEFT_HIP), SCOL_TYPTYPE(nite::JOINT_LEFT_KNEE),
1918 SCOL_TYPTYPE(0), SCOL_TYPTYPE(nite::JOINT_LEFT_FOOT), SCOL_TYPTYPE(nite::JOINT_RIGHT_HIP),
1919 SCOL_TYPTYPE(nite::JOINT_RIGHT_KNEE), SCOL_TYPTYPE(0), SCOL_TYPTYPE(nite::JOINT_RIGHT_FOOT)
1925 int KinectNArg[NbKinectPKG]=
1969 TYPVAR,TYPVAR,TYPVAR,
1970 TYPVAR,TYPVAR,TYPVAR,
1971 TYPVAR,TYPVAR,TYPVAR,
1972 TYPVAR,TYPVAR,TYPVAR,
1973 TYPVAR,TYPVAR,TYPVAR,
1974 TYPVAR,TYPVAR,TYPVAR,
1975 TYPVAR,TYPVAR,TYPVAR,
1976 TYPVAR,TYPVAR,TYPVAR
1982 char* KinectType[NbKinectPKG]=
1986 "fun [Chn] ObjKinect",
1987 "fun [ObjKinect] I",
1988 "fun [I] ObjKinect",
1989 "fun [ObjKinect] I",
1990 "fun [ObjKinect] [I I]",
1991 "fun [ObjKinect ObjBitmap] ObjBitmap",
1992 "fun [ObjKinect ObjBitmap] ObjBitmap",
1993 "fun [ObjKinect ObjBitmap] ObjBitmap",
1994 "fun [ObjKinect AlphaBitmap] AlphaBitmap",
1995 "fun [ObjKinect AlphaBitmap] AlphaBitmap",
1996 "fun [ObjKinect AlphaBitmap] AlphaBitmap",
1997 "fun [ObjKinect I] I",
1998 "fun [ObjKinect] I",
1999 "fun [ObjKinect F] I",
2000 "fun [ObjKinect] F",
2001 "fun [ObjKinect I] I",
2002 "fun [ObjKinect] I",
2003 "fun [ObjKinect F] I",
2004 "fun [ObjKinect] F",
2005 "fun [Chn ObjKinect] ObjKinectUser",
2006 "fun [ObjKinectUser] I",
2008 "fun [ObjKinect fun [ObjKinect u0] u1 u0] ObjKinect",
2009 "fun [ObjKinect fun [ObjKinect u0] u1 u0] ObjKinect",
2010 "fun [ObjKinectUser fun [ObjKinectUser u0] u1 u0] ObjKinect",
2011 "fun [ObjKinectUser fun [ObjKinectUser u0] u1 u0] ObjKinect",
2012 "fun [ObjKinectUser fun [ObjKinectUser u0] u1 u0] ObjKinectUser",
2013 "fun [ObjKinectUser fun [ObjKinectUser u0] u1 u0] ObjKinectUser",
2014 "fun [ObjKinectUser fun [ObjKinectUser u0] u1 u0] ObjKinectUser",
2015 "fun [ObjKinectUser fun [ObjKinectUser u0] u1 u0] ObjKinectUser",
2016 "fun [ObjKinectUser fun [ObjKinectUser u0 I] u1 u0] ObjKinectUser",
2017 "fun [ObjKinectUser fun [ObjKinectUser u0 I] u1 u0] ObjKinectUser",
2018 "fun [ObjKinectUser fun [ObjKinectUser u0 I [I I I]] u1 u0] ObjKinectUser",
2020 "fun [ObjKinectUser I F] [F F F]",
2021 "fun [ObjKinectUser I F] [F F F F]",
2022 "fun [ObjKinectUser I F] [I I I]",
2023 "fun [ObjKinectUser I] [[I I] r1]",
2024 "fun [ObjKinectUser I] I",
2043 int LoadOpenNiPlugin(mmachine m)
2048 OBJ_KINECT_SCOL = OBJregister(2 , 1, destroyKinectObj,
"OBJ_KINECT_SCOL");
2051 KINECT_CONNECTED_CB = OBJgetUserEvent();
2052 OBJdefEvent( KINECT_CONNECTED_CB, (
int (__cdecl*)(
struct Mmachine*, SCOL_PTR_TYPE, LONG))getKinectConnectedCb );
2054 KINECT_DISCONNECTED_CB = OBJgetUserEvent();
2055 OBJdefEvent( KINECT_DISCONNECTED_CB, (
int (__cdecl *)(
struct Mmachine*, SCOL_PTR_TYPE, LONG))getKinectDisconnectedCb );
2058 OBJ_KINECT_USER_SCOL = OBJregister(9 , 1, destroyKinectUserObj,
"OBJ_KINECT_USER_SCOL");
2060 KINECT_NEW_USER_CB = OBJgetUserEvent();
2061 OBJdefEvent( KINECT_NEW_USER_CB, (
int (__cdecl *)(
struct Mmachine*, SCOL_PTR_TYPE, LONG))getKinectNewUserCb );
2063 KINECT_LOST_USER_CB = OBJgetUserEvent();
2064 OBJdefEvent( KINECT_LOST_USER_CB, (
int (__cdecl *)(
struct Mmachine*, SCOL_PTR_TYPE, LONG))getKinectLostUserCb );
2066 KINECT_USER_CALIBRATION_START_CB = OBJgetUserEvent();
2067 OBJdefEvent( KINECT_USER_CALIBRATION_START_CB, (
int (__cdecl *)(
struct Mmachine*, SCOL_PTR_TYPE, LONG))getKinectUserCalibrationStartCb );
2069 KINECT_USER_CALIBRATION_END_CB = OBJgetUserEvent();
2070 OBJdefEvent( KINECT_USER_CALIBRATION_END_CB, (
int (__cdecl *)(
struct Mmachine*, SCOL_PTR_TYPE, LONG))getKinectUserCalibrationEndCb );
2072 KINECT_USER_POSE_DETECTED_CB = OBJgetUserEvent();
2073 OBJdefEvent( KINECT_USER_POSE_DETECTED_CB, (
int (__cdecl *)(
struct Mmachine*, SCOL_PTR_TYPE, LONG))getKinectUserPoseDetectedCb );
2075 KINECT_USER_POSE_LOST_CB = OBJgetUserEvent();
2076 OBJdefEvent( KINECT_USER_POSE_LOST_CB, (
int (__cdecl *)(
struct Mmachine*, SCOL_PTR_TYPE, LONG))getKinectUserPoseLostCb );
2078 KINECT_USER_HAND_FOUND_CB = OBJgetUserEvent();
2079 OBJdefEvent( KINECT_USER_HAND_FOUND_CB, (
int (__cdecl *)(
struct Mmachine*, SCOL_PTR_TYPE, LONG))getKinectUserHandFoundCb );
2081 KINECT_USER_HAND_LOST_CB = OBJgetUserEvent();
2082 OBJdefEvent( KINECT_USER_HAND_LOST_CB, (
int (__cdecl *)(
struct Mmachine*, SCOL_PTR_TYPE, LONG))getKinectUserHandLostCb );
2084 KINECT_USER_HAND_MOVE_CB = OBJgetUserEvent();
2085 OBJdefEvent( KINECT_USER_HAND_MOVE_CB, (
int (__cdecl *)(
struct Mmachine*, SCOL_PTR_TYPE, LONG))getKinectUserHandMoveCb );
2088 k = PKhardpak(m,
"KinectEngine", NbKinectPKG, KinectName, KinectFunc, KinectNArg, KinectType);
2102 extern "C" SCOL_EXPORT
int ScolLoadPlugin(mmachine m, cbmachine w)
2107 srand((
int)time(0));
2109 LoadOpenNiPlugin(m);
2116 extern "C" SCOL_EXPORT
int ScolUnloadPlugin()
2120 SAFE_DELETE(sManager);
2128 extern "C" SCOL_EXPORT
int ScolOpenNILoadPlugin(mmachine m, cbmachine w)
2133 srand((
int)time(0));
2135 LoadOpenNiPlugin(m);
2142 extern "C" SCOL_EXPORT
int ScolOpenNIUnloadPlugin()
2146 SAFE_DELETE(sManager);
2150 #endif //SCOL_STATIC int _SETKinectDeviceDetectionDistance(mmachine m)
_SETKinectDeviceDetectionDistance : Set the ObjKinect user detection distance
int _CBKinectUserHandLost(mmachine m)
_CBKinectUserHandLost : This function set the Callback for hand lost from Kinect User ...
int _GETKinectUserJointPixelPosition(mmachine m)
_GETKinectUserJointPixelPosition : Get a objKinectUser hand position in pixel
int _BLTKinectDeviceRGB(mmachine m)
_BLTKinectDeviceRGB : Blit RGB image from Kinect device into a Scol Bitmap object Prototype: fun [Obj...
int _CBKinectConnected(mmachine m)
_CBKinectConnected : This function set the Callback for Connection from kinect device ...
int _GETKinectDeviceDetectionAngle(mmachine m)
_GETKinectDeviceDetectionAngle : Get the ObjKinect user detection angle
int _SETKinectDeviceMirror(mmachine m)
_SETKinectDeviceMirror : Change the mirror mode of th kinect device Prototype: fun [ObjKinect I] I ...
int _CBKinectUserHandMove(mmachine m)
_CBKinectUserHandMove : This function set the Callback for hand move from Kinect User ...
int _CBKinectUserHandFound(mmachine m)
_CBKinectUserHandFound : This function set the Callback for hand found from Kinect User ...
int _GETKinectDeviceDetectionDistance(mmachine m)
_GETKinectDeviceDetectionDistance : Get the ObjKinect user detection distance
int _GETKinectDeviceSkeletonSmoothing(mmachine m)
_GETKinectDeviceSkeletonSmoothing : Get a ObjKinect skeleton smoothing coefficient ...
int _SETKinectDeviceDetectionAngle(mmachine m)
_SETKinectDeviceDetectionAngle : Set the ObjKinect user detection angle
int _BLTKinectDeviceHands(mmachine m)
_BLTKinectDeviceHands : Blit users hands and fingers image from Kinect device into a Scol Bitmap obje...
int _BLTKinectDeviceGrayscale(mmachine m)
_BLTKinectDeviceGrayscale : Blit grayscale image from Kinect device into a Scol Bitmap object Prototy...
int _DSKinectUser(mmachine m)
_DSKinectUser : Destroy objKinectUser object
int _GETKinectUserFingersPixelPosition(mmachine m)
_GETKinectUserFingersPixelPosition : Get a objKinectUser fingers position in pixel ...
int _CBKinectUserFound(mmachine m)
_CBKinectUserFound : This function set the Callback for New User from Kinect
Kinect user hand handling. .
int _CBKinectDisconnected(mmachine m)
_CBKinectDisconnected : This function set the Callback for Disconnection from Kinect ...
int _SETKinectDeviceSkeletonSmoothing(mmachine m)
_SETKinectDeviceSkeletonSmoothing : Set a ObjKinect skeleton smoothing coefficient ...
int _CBKinectUserPoseDetected(mmachine m)
_CBKinectUserPoseDetected : This function set the Callback for detection pose from Kinect User ...
int _GETKinectDeviceById(mmachine m)
_GETKinectDeviceById : retrieve a kinect Device by name
int _GETKinectDeviceSize(mmachine m)
_GETKinectDeviceSize : retrieve a kinect Device picture size
int _CRKinectUser(mmachine m)
_CRKinectUser : Open, initialize objKinectUser
int _GETKinectUserJointPosition(mmachine m)
_GETKinectUserJointPosition : Get a objKinectUser skeleton joint position
int _CBKinectUserLost(mmachine m)
_CBKinectUserLost : This function set the Callback for Lost User from Kinect
Kinect device handling. .
int _BLTKinectDeviceDepth(mmachine m)
_BLTKinectDeviceDepth : Blit the device depth picture into a bitmap Prototype: fun [ObjKinect ObjBitm...
int _DSKinectDevice(mmachine m)
_DSKinectDevice : Destroy objKinectDevice object
int _GETKinectUserJointOrientation(mmachine m)
_GETKinectUserJointOrientation : Get a objKinectUser skeleton joint orientation
Handle DeviceManager type. .
int _CBKinectUserCalibrationStart(mmachine m)
_CBKinectUserCalibrationStart : This function set the Callback for Calibration start from Kinect User...
int _GETKinectUserHandVisible(mmachine m)
_GETKinectUserHandVisible : Get a objKinectUser hand visibility
int _GETKinectDeviceMirror(mmachine m)
_GETKinectDeviceMirror : Get the mirror mode of th kinect device Prototype: fun [ObjKinect] I ...
int _GETKinectDeviceId(mmachine m)
_GETKinectDeviceId : retrieve a kinect Device by name
int _BLTKinectDeviceUsers(mmachine m)
_BLTKinectDeviceUsers : Blit users image from Kinect device into a Scol Bitmap object Prototype: fun ...
int _CBKinectUserPoseLost(mmachine m)
_CBKinectUserPoseLost : This function set the Callback for lost pose from Kinect User ...
int _CBKinectUserCalibrationEnd(mmachine m)
_CBKinectUserCalibrationEnd : This function set the Callback for Calibration end from Kinect User ...
int _CRKinectDevice(mmachine m)
_CRKinectDevice : Open, initialize objKinect
int _BLTKinectDeviceUsersRGB(mmachine m)
_BLTKinectDeviceUsersRGB : Blit users image from RGB camera from Kinect device into a Scol Bitmap obj...