60 ArCameraParam* arCameraParamOBJ = MMgetPointer<ArCameraParam*>(m, MTOP(obj));
61 SAFE_DELETE(arCameraParamOBJ);
63 MMsetPointer<ArCameraParam*>(m, MTOP(obj), 0);
65 MMechostr(MSKDEBUG,
"ArCameraParam destroyed.\n");
86 MMechostr(MSKDEBUG,
"_CRarCameraParam\n");
89 int ifile = MMpull(m);
90 int ffarclip = MMpull(m);
91 int fnearclip = MMpull(m);
92 int sheight = MMpull(m);
93 int swidth = MMpull(m);
95 if ((swidth == NIL) || (sheight == NIL))
104 if (MTOI(swidth) > 1)
105 width = MTOI(swidth);
106 if (MTOI(sheight) > 1)
107 height = MTOI(sheight);
109 float nearclip = 0.01;
110 if (fnearclip != NIL)
111 nearclip = MTOF(fnearclip);
113 float farclip = 10000.0;
115 farclip = MTOF(ffarclip);
117 std::string yamlfile(
"");
119 yamlfile = MMstartstr(m, MTOP(ifile));
123 if (!ArCameraParamOBJ)
125 MMechostr(MSKDEBUG,
"Failed to create camera param\n");
130 if (MMpushPointer(m, ArCameraParamOBJ) != 0)
132 SAFE_DELETE(ArCameraParamOBJ);
138 MMechostr(MSKDEBUG,
"ok\n");
161 MMechostr(MSKDEBUG,
"_CRarCameraParamIntrinsics\n");
164 int icenter = MMpull(m);
165 int ifocal = MMpull(m);
166 int ffarclip = MMpull(m);
167 int fnearclip = MMpull(m);
168 int sheight = MMpull(m);
169 int swidth = MMpull(m);
171 if ((swidth == NIL) || (sheight == NIL))
180 if (MTOI(swidth) > 1)
181 width = MTOI(swidth);
182 if (MTOI(sheight) > 1)
183 height = MTOI(sheight);
185 float nearclip = 0.01;
186 if (fnearclip != NIL)
187 nearclip = MTOF(fnearclip);
189 float farclip = 10000.0;
191 farclip = MTOF(ffarclip);
193 float f = std::max(width, height);
195 int tfocal = MTOP(ifocal);
199 int fx = MMfetch(m, tfocal, 0);
200 int fy = MMfetch(m, tfocal, 1);
201 if ((fx != NIL) && (fy != NIL))
202 focal =
Vector2(MTOF(fx), MTOF(fy));
205 Vector2 center(
static_cast<float>(width) * 0.5f,
static_cast<float>(height) * 0.5f);
206 int tcenter = MTOP(icenter);
209 int cx = MMfetch(m, tcenter, 0);
210 int cy = MMfetch(m, tcenter, 1);
212 if ((cx != NIL) && (cy != NIL))
213 center =
Vector2(MTOF(cx), MTOF(cy));
218 if (!ArCameraParamOBJ)
220 MMechostr(MSKDEBUG,
"Failed to create camera param\n");
225 if (MMpushPointer(m, ArCameraParamOBJ) != 0)
227 SAFE_DELETE(ArCameraParamOBJ);
233 MMechostr(MSKDEBUG,
"ok\n");
250 MMechostr(MSKDEBUG,
"_DSarCameraParam\n");
253 int obj = MMget(m, 0);
262 MMset(m, 0, ITOM(0));
265 MMechostr(MSKDEBUG,
"ok\n");
281 MMechostr(MSKDEBUG,
"_SETcameraSensorsQuat\n");
284 int iquat = MMpull(m);
285 int obj = MMget(m, 0);
286 if ((obj == NIL) || (iquat == NIL))
292 ArCameraParam* cameraParamOBJ = MMgetPointer<ArCameraParam*>(m, MTOP(obj));
293 if (cameraParamOBJ == NULL)
299 int q1 = MTOP(iquat);
300 int x1 = MMfetch(m, q1, 0);
301 int y1 = MMfetch(m, q1, 1);
302 int z1 = MMfetch(m, q1, 2);
303 int w1 = MMfetch(m, q1, 3);
305 if ((x1 == NIL) || (y1 == NIL) || (z1 == NIL) || (w1 == NIL))
314 MMechostr(MSKDEBUG,
"ok\n");
331 MMechostr(MSKDEBUG,
"_GETarProjectionMatrix\n");
334 int iheight = MMpull(m);
335 int iwidth = MMpull(m);
336 int obj = MMget(m, 0);
337 if ((obj == NIL) || (iheight == NIL) || (iwidth == NIL))
343 ArCameraParam* cameraParamOBJ = MMgetPointer<ArCameraParam*>(m, MTOP(obj));
344 if (cameraParamOBJ == NULL)
353 int tupleMat = MMmalloc(m, 4, TYPETAB);
360 int tupleMat0 = MMmalloc(m, 4, TYPETAB);
361 int tupleMat1 = MMmalloc(m, 4, TYPETAB);
362 int tupleMat2 = MMmalloc(m, 4, TYPETAB);
363 int tupleMat3 = MMmalloc(m, 4, TYPETAB);
365 if ((tupleMat0 == NIL) || (tupleMat1 == NIL) || (tupleMat2 == NIL) || (tupleMat3 == NIL))
371 MMstore(m, tupleMat0, 0, FTOM(
static_cast<float>(proj_mat[0])));
372 MMstore(m, tupleMat0, 1, FTOM(
static_cast<float>(proj_mat[4])));
373 MMstore(m, tupleMat0, 2, FTOM(
static_cast<float>(proj_mat[8])));
374 MMstore(m, tupleMat0, 3, FTOM(
static_cast<float>(proj_mat[12])));
376 MMstore(m, tupleMat1, 0, FTOM(
static_cast<float>(proj_mat[1])));
377 MMstore(m, tupleMat1, 1, FTOM(
static_cast<float>(proj_mat[5])));
378 MMstore(m, tupleMat1, 2, FTOM(
static_cast<float>(proj_mat[9])));
379 MMstore(m, tupleMat1, 3, FTOM(
static_cast<float>(proj_mat[13])));
381 MMstore(m, tupleMat2, 0, FTOM(
static_cast<float>(proj_mat[2])));
382 MMstore(m, tupleMat2, 1, FTOM(
static_cast<float>(proj_mat[6])));
383 MMstore(m, tupleMat2, 2, FTOM(
static_cast<float>(proj_mat[10])));
384 MMstore(m, tupleMat2, 3, FTOM(
static_cast<float>(proj_mat[14])));
386 MMstore(m, tupleMat3, 0, FTOM(
static_cast<float>(proj_mat[3])));
387 MMstore(m, tupleMat3, 1, FTOM(
static_cast<float>(proj_mat[7])));
388 MMstore(m, tupleMat3, 2, FTOM(
static_cast<float>(proj_mat[11])));
389 MMstore(m, tupleMat3, 3, FTOM(
static_cast<float>(proj_mat[15])));
391 MMstore(m, tupleMat, 0, PTOM(tupleMat0));
392 MMstore(m, tupleMat, 1, PTOM(tupleMat1));
393 MMstore(m, tupleMat, 2, PTOM(tupleMat2));
394 MMstore(m, tupleMat, 3, PTOM(tupleMat3));
396 MMset(m, 0, PTOM(tupleMat));
399 MMechostr(MSKDEBUG,
"ok\n");
416 MMechostr(MSKDEBUG,
"_SETcameraOffset\n");
419 int ivec = MMpull(m);
420 int obj = MMget(m, 0);
421 if ((obj == NIL) || (ivec == NIL))
427 ArCameraParam* cameraParamOBJ = MMgetPointer<ArCameraParam*>(m, MTOP(obj));
428 if (cameraParamOBJ == NULL)
434 int vec = MTOP(ivec);
435 int x = MMfetch(m, vec, 0);
436 int y = MMfetch(m, vec, 1);
437 int z = MMfetch(m, vec, 2);
439 if ((x == NIL) || (y == NIL) || (z == NIL))
448 MMechostr(MSKDEBUG,
"ok\n");
464 MMechostr(MSKDEBUG,
"_GETcameraOffset\n");
467 int obj = MMget(m, 0);
474 ArCameraParam* cameraParamOBJ = MMgetPointer<ArCameraParam*>(m, MTOP(obj));
475 if (cameraParamOBJ == NULL)
483 int tuple = MMmalloc(m, 3, TYPETAB);
490 MMstore(m, tuple, 0, FTOM(offset.
x));
491 MMstore(m, tuple, 1, FTOM(offset.
y));
492 MMstore(m, tuple, 2, FTOM(offset.
z));
493 MMset(m, 0, PTOM(tuple));
496 MMechostr(MSKDEBUG,
"ok\n");
509 ArBlobDetector* blobDetector = MMgetPointer<ArBlobDetector*>(m, MTOP(obj));
512 MMsetPointer<ArBlobDetector*>(m, MTOP(obj), 0);
514 MMechostr(MSKDEBUG,
"BlobDetector destroyed.\n");
529 MMechostr(MSKDEBUG,
"_DSblobDetector\n");
532 int obj = MMget(m, 0);
541 MMset(m, 0, ITOM(0));
544 MMechostr(MSKDEBUG,
"ok\n");
579 MMechostr(MSKDEBUG,
"_CRblobDetector\n");
582 int iInertia = MMpull(m);
583 bool filterInertia =
false;
584 float minIntertia = 0.1f;
585 float maxIntertia = 1.0f;
589 int iFilterInertia = MMfetch(m, MTOP(iInertia), 0);
590 if (iFilterInertia != NIL)
591 filterInertia = (MTOI(iFilterInertia) > 0) ?
true :
false;
593 int iMinInertia = MMfetch(m, MTOP(iInertia), 1);
594 if (iMinInertia != NIL)
595 minIntertia = abs(MTOF(iMinInertia));
597 int iMaxInertia = MMfetch(m, MTOP(iInertia), 2);
598 if (iMaxInertia != NIL)
599 maxIntertia = abs(MTOF(iMaxInertia));
602 int iConvexcity = MMpull(m);
603 bool filterConvexcity =
false;
604 float minConvexcity = 0.95f;
605 float maxConvexcity = 1.0f;
607 if (iConvexcity != NIL)
609 int iFilterConvexcity = MMfetch(m, MTOP(iConvexcity), 0);
610 if (iFilterConvexcity != NIL)
611 filterConvexcity = (MTOI(iFilterConvexcity) > 0) ?
true :
false;
613 int iMinConvexcity = MMfetch(m, MTOP(iConvexcity), 1);
614 if (iMinConvexcity != NIL)
615 minConvexcity = abs(MTOF(iMinConvexcity));
617 int iMaxConvexcity = MMfetch(m, MTOP(iConvexcity), 2);
618 if (iMaxConvexcity != NIL)
619 maxConvexcity = abs(MTOF(iMaxConvexcity));
622 int iColor = MMpull(m);
623 bool filterColor =
false;
628 int iFilterColor = MMfetch(m, MTOP(iColor), 0);
629 if (iFilterColor != NIL)
630 filterColor = (MTOI(iFilterColor) > 0) ?
true :
false;
632 int iDetectColor = MMfetch(m, MTOP(iColor), 1);
633 if (iDetectColor != NIL)
634 color = abs(MTOI(iDetectColor));
637 int iCircularity = MMpull(m);
638 bool filterCircularity =
false;
639 float minCircularity = 0.8f;
640 float maxCircularity = 1.0f;
642 if (iCircularity != NIL)
644 int iFilterCircularity = MMfetch(m, MTOP(iCircularity), 0);
645 if (iFilterCircularity != NIL)
646 filterCircularity = (MTOI(iFilterCircularity) > 0) ?
true :
false;
648 int iMinCircularity = MMfetch(m, MTOP(iCircularity), 1);
649 if (iMinCircularity != NIL)
650 minCircularity = abs(MTOF(iMinCircularity));
652 int iMaxCircularity = MMfetch(m, MTOP(iCircularity), 2);
653 if (iMaxCircularity != NIL)
654 maxCircularity = abs(MTOF(iMaxCircularity));
657 int iArea = MMpull(m);
658 bool filterArea =
false;
664 int iFilterArea = MMfetch(m, MTOP(iArea), 0);
665 if (iFilterArea != NIL)
666 filterArea = (MTOI(iFilterArea) > 0) ?
true :
false;
668 int iMinArea = MMfetch(m, MTOP(iArea), 1);
670 minArea = abs(MTOI(iMinArea));
672 int iMaxArea = MMfetch(m, MTOP(iArea), 2);
674 maxArea = abs(MTOI(iMaxArea));
677 int iThreshold = MMpull(m);
678 int minThreshold = 50;
679 int maxThreshold = 220;
682 if (iThreshold != NIL)
684 int iStepThreshold = MMfetch(m, MTOP(iThreshold), 1);
685 if (iStepThreshold != NIL)
686 thStep = std::max(1, abs(MTOI(iStepThreshold)));
688 int iMinThreshold = MMfetch(m, MTOP(iThreshold), 1);
689 if (iMinThreshold != NIL)
690 minThreshold = abs(MTOI(iMinThreshold));
692 int iMaxThreshold = MMfetch(m, MTOP(iThreshold), 2);
693 if (iMaxThreshold != NIL)
694 maxThreshold = abs(MTOI(iMaxThreshold));
697 int iMinRepeat = MMpull(m);
700 if (minRepeat != NIL)
701 minRepeat = std::max(1, abs(MTOI(minRepeat)));
703 int iMinDist = MMpull(m);
707 minDist = abs(MTOI(iMinDist));
709 cv::SimpleBlobDetector::Params params;
710 params.filterByArea = filterArea;
711 params.minArea = (float)minArea;
712 params.maxArea = (float)maxArea;
714 params.filterByCircularity = filterCircularity;
715 params.minCircularity = minCircularity;
716 params.maxCircularity = maxCircularity;
718 params.filterByColor = filterColor;
719 params.blobColor = color;
721 params.filterByConvexity = filterConvexcity;
722 params.minConvexity = minConvexcity;
723 params.maxConvexity = maxConvexcity;
725 params.filterByInertia = filterInertia;
726 params.minInertiaRatio = minIntertia;
727 params.maxInertiaRatio = maxIntertia;
729 params.minThreshold = (float)minThreshold;
730 params.maxThreshold = (float)maxThreshold;
732 params.minDistBetweenBlobs = (float)minDist;
733 params.minRepeatability = minRepeat;
734 params.thresholdStep = (float)thStep;
740 MMechostr(MSKDEBUG,
"Failed to create blob detector\n");
745 if ((MMpushPointer(m, blobDetector) != 0))
753 MMechostr(MSKDEBUG,
"ok\n");
755 return OBJcreate(m,
OBJBLOBSCOL, SCOL_PTR blobDetector, NIL, 0);
770 MMechostr(MSKDEBUG,
"_GETdetectedBlobs\n");
773 int blobTab = MMpull(m);
780 ArBlobDetector* blobDetector = MMgetPointer<ArBlobDetector*>(m, MTOP(blobTab));
781 if (blobDetector == 0)
788 for (
unsigned int i = 0; i < ldots.size(); i++)
790 cv::Point3f data = ldots.at(i);
792 int ptuple = MMmalloc(m, 3, TYPETAB);
797 MMstore(m, ptuple, 0, ITOM((
int)data.x));
798 MMstore(m, ptuple, 1, ITOM((
int)data.y));
799 MMstore(m, ptuple, 2, FTOM(data.z));
801 MMpush(m, PTOM(ptuple));
807 for (
unsigned int i = 0; i < ldots.size(); i++)
809 if (MMpush(m, 2 * 2))
812 if (
int k = MBdeftab(m))
817 MMechostr(MSKDEBUG,
"ok\n");
834 MMechostr(MSKDEBUG,
"_GETblobDetectorSize\n");
837 int blobTab = MMpull(m);
844 ArBlobDetector* blobDetector = MMgetPointer<ArBlobDetector*>(m, MTOP(blobTab));
845 if (blobDetector == 0)
853 int ptuple = MMmalloc(m, 2, TYPETAB);
858 MMstore(m, ptuple, 0, ITOM(size.width));
859 MMstore(m, ptuple, 1, ITOM(size.height));
861 MMpush(m, PTOM(ptuple));
864 MMechostr(MSKDEBUG,
"ok\n");
887 MMechostr(MSKDEBUG,
"_AddcameraSensorsImu\n");
890 int idelta = MMpull(m);
891 int iaccel = MMpull(m);
892 int igyro = MMpull(m);
893 int obj = MMget(m, 0);
895 if ((obj == NIL) || (iaccel == NIL) || (igyro == NIL))
901 ArCameraParam* cameraParamOBJ = MMgetPointer<ArCameraParam*>(m, MTOP(obj));
902 if (cameraParamOBJ == NULL)
908 float delta = MTOF(idelta);
911 int gx = MMfetch(m, g, 0);
912 int gy = MMfetch(m, g, 1);
913 int gz = MMfetch(m, g, 2);
915 if ((gx == NIL) || (gy == NIL) || (gz == NIL))
921 int a = MTOP(iaccel);
922 int ax = MMfetch(m, a, 0);
923 int ay = MMfetch(m, a, 1);
924 int az = MMfetch(m, a, 2);
926 if ((ax == NIL) || (ay == NIL) || (az == NIL))
934 MMset(m, 0, ITOM(0));
936 MMechostr(MSKDEBUG,
"ok\n");
950int _SetSlamDetectorState(mmachine m)
953 MMechostr(MSKDEBUG,
"_SetSlamDetectorState\n");
956 int state = MTOI(MMget(m, 0));
960 MMset(m, 0, ITOM(0));
975int _SetSlamDetectorParams(mmachine m)
978 MMechostr(MSKDEBUG,
"_SetSlamDetectorParams\n");
981 int maxf = MTOI(MMpull(m));
982 int minf = MTOI(MMpull(m));
983 int nbimp = MTOI(MMpull(m));
984 int nbp = MTOI(MMget(m, 0));
997 MMset(m, 0, ITOM(0));
1008int _GetSlamCameraPosition(mmachine m)
1011 MMechostr(MSKDEBUG,
"_GetSlamCameraPosition\n");
1016 int tuplePos = MMmalloc(m, 3, TYPETAB);
1017 if (tuplePos == NIL)
1023 MMstore(m, tuplePos, 0, FTOM(pos.
x));
1024 MMstore(m, tuplePos, 1, FTOM(pos.
y));
1025 MMstore(m, tuplePos, 2, FTOM(pos.
z));
1026 MMpush(m, PTOM(tuplePos));
1037int _GetSlamCameraOrientation(mmachine m)
1040 MMechostr(MSKDEBUG,
"_GetSlamCameraOrientation\n");
1045 int tupleQuat = MMmalloc(m, 4, TYPETAB);
1046 if (tupleQuat == NIL)
1052 MMstore(m, tupleQuat, 0, FTOM(quat.
x));
1053 MMstore(m, tupleQuat, 1, FTOM(quat.
y));
1054 MMstore(m, tupleQuat, 2, FTOM(quat.
z));
1055 MMstore(m, tupleQuat, 3, FTOM(quat.
w));
1056 MMpush(m, PTOM(tupleQuat));
1067int _IsSlamFound(mmachine m)
1070 MMechostr(MSKDEBUG,
"_IsSlamFound\n");
1074 MMpush(m, ITOM((state) ? 1 : 0));
1086int _ResetSlamDetector(mmachine m)
1089 MMechostr(MSKDEBUG,
"_IsSlamFound\n");
1105 ArMarker* MarkerOBJ = MMgetPointer<ArMarker*>(m, MTOP(obj));
1108 MMsetPointer<ArMarker*>(m, MTOP(obj), 0);
1110 MMechostr(MSKDEBUG,
"ArMarker destroyed.\n");
1125 MMechostr(MSKDEBUG,
"_DSarMarker\n");
1128 int obj = MMget(m, 0);
1137 MMset(m, 0, ITOM(0));
1140 MMechostr(MSKDEBUG,
"ok\n");
1158 MMechostr(MSKDEBUG,
"_CRarMarker\n");
1161 int iSize = MMpull(m);
1162 int idx = MMpull(m);
1163 if ((idx == NIL) || (iSize == NIL) || (MTOI(idx) > 1022) || (MTOI(idx) < 0))
1170 int channel = MMget(m, 0);
1175 MMechostr(MSKRUNTIME,
"_CRarMarker : Channel NIL\n");
1183 MMechostr(MSKDEBUG,
"Failed to create marker\n");
1188 if ((MMpushPointer(m, MarkerOBJ) != 0))
1196 MMechostr(MSKDEBUG,
"ok\n");
1198 return OBJcreate(m,
OBJMARKERSCOL, SCOL_PTR MarkerOBJ, NIL, 0);
1214 MMechostr(MSKDEBUG,
"_CRarMarkerFromFile\n");
1217 int iSize = MMpull(m);
1218 int ifile = MMpull(m);
1219 if ((ifile == NIL) || (iSize == NIL))
1226 int channel = MMget(m, 0);
1231 MMechostr(MSKRUNTIME,
"_CRarMarkerFromFile : Channel NIL\n");
1239 MMechostr(MSKDEBUG,
"Failed to create marker\n");
1244 if ((MMpushPointer(m, MarkerOBJ) != 0))
1252 MMechostr(MSKDEBUG,
"ok\n");
1254 return OBJcreate(m,
OBJMARKERSCOL, SCOL_PTR MarkerOBJ, NIL, 0);
1271 MMechostr(MSKDEBUG,
"_CRarMarkerFromFileEx\n");
1274 int iMaxFeatures = MMpull(m);
1275 int iSize = MMpull(m);
1276 int ifile = MMpull(m);
1283 std::string path =
"";
1285 path = MMstartstr(m, MTOP(ifile));
1291 MMechostr(MSKDEBUG,
"Failed to create marker\n");
1296 if ((MMpushPointer(m, MarkerOBJ) != 0))
1304 MMechostr(MSKDEBUG,
"ok\n");
1306 return OBJcreate(m,
OBJMARKERSCOL, SCOL_PTR MarkerOBJ, NIL, 0);
1324 MMechostr(MSKDEBUG,
"_CRarMarkerFromFileEx2\n");
1327 int iuser = MMpull(m);
1328 int iCbk = MMpull(m);
1329 int iMaxFeatures = MMpull(m);
1330 int iSize = MMpull(m);
1331 int ifile = MMpull(m);
1332 if ((ifile == NIL) || (iSize == NIL))
1339 int channel = MMget(m, 0);
1344 MMechostr(MSKRUNTIME,
"_CRarMarkerFromFileEx2 : Channel NIL\n");
1352 MMechostr(MSKDEBUG,
"Failed to create marker\n");
1357 if ((MMpushPointer(m, MarkerOBJ) != 0))
1364 int k = OBJcreate(m,
OBJMARKERSCOL, SCOL_PTR MarkerOBJ, NIL, 0);
1366 if ((k = MMpush(m, iCbk)))
return k;
1367 if ((k = MMpush(m, iuser)))
return k;
1371 MMechostr(MSKDEBUG,
"ok\n");
1388 MMechostr(MSKDEBUG,
"_CRarMarkerFromFace\n");
1391 int iSize = MMpull(m);
1402 MMechostr(MSKDEBUG,
"Failed to create marker\n");
1407 if ((MMpushPointer(m, MarkerOBJ) != 0))
1415 MMechostr(MSKDEBUG,
"ok\n");
1417 return OBJcreate(m,
OBJMARKERSCOL, SCOL_PTR MarkerOBJ, NIL, 0);
1433 MMechostr(MSKDEBUG,
"_UPDATEarMarkers\n");
1436 int idebug = MMpull(m);
1437 int imirror = MMpull(m);
1438 int iarcameraparam = MMpull(m);
1439 int bitmap = MMget(m, 0);
1441 if ((bitmap == NIL) || (iarcameraparam == NIL))
1447 PtrObjVoid OB = (PtrObjVoid)MMstart(m, MTOP(bitmap));
1448 PtrObjBitmap B = (PtrObjBitmap)MMstart(m, MTOP(OB->Buffer));
1456 cv::Mat imagesrc(B->TailleH, B->TailleW, CV_8UC3);
1459 bool revert =
false;
1460 if ((imirror != NIL) && (MTOI(imirror) == 1))
1464 if ((idebug != NIL) && (MTOI(idebug) == 1))
1467 ArCameraParam* arcameraparam = MMgetPointer<ArCameraParam*>(m, MTOP(iarcameraparam));
1468 if (arcameraparam == 0)
1477 memcpy(B->bits, imagesrc.data, ((B->TailleW * B->TailleH) * 3));
1480 MMechostr(MSKDEBUG,
"ok\n");
1502 MMechostr(MSKDEBUG,
"_UPDATEarMarkersBuff\n");
1505 int idebug = MMpull(m);
1506 int imirror = MMpull(m);
1507 int iarcameraparam = MMpull(m);
1508 int ibitsperpixel = MMpull(m);
1509 int iheight = MMpull(m);
1510 int iwidth = MMpull(m);
1511 int iBuff = MMget(m, 0);
1513 if ((iBuff == NIL) || (iarcameraparam == NIL) || (iwidth == NIL) || (iheight == NIL) || (ibitsperpixel == NIL))
1519 unsigned char* buffer = MMgetPointer<unsigned char*>(m, MTOP(iBuff));
1528 bool revert =
false;
1529 if ((imirror != NIL) && (MTOI(imirror) == 1))
1533 if ((idebug != NIL) && (MTOI(idebug) == 1))
1536 ArCameraParam* arcameraparam = MMgetPointer<ArCameraParam*>(m, MTOP(iarcameraparam));
1537 if (arcameraparam == 0)
1546 MMechostr(MSKDEBUG,
"ok\n");
1563 MMechostr(MSKDEBUG,
"_GETarMarkerBitmap\n");
1566 int ssize = MMpull(m);
1567 int markerTab = MMpull(m);
1568 if (markerTab == NIL)
1574 ArMarker* arMarker = MMgetPointer<ArMarker*>(m, MTOP(markerTab));
1582 if ((ssize != NIL) && (MTOI(ssize) > 7))
1590 cv::resize(mbitmap, mbitmap, cv::Size(size, size));
1593 MMpush(m, ITOM(size));
1594 MMpush(m, ITOM(size));
1598 if ((MMpush(m, Msearchinsyspak(m,
"_CRbitmap"))) < 0)
1600 MMechostr(0,
"\n_GETarMarkerBitmap : error interpreting _CRbitmap");
1610 int objbmp = MMget(m, 0);
1617 PtrObjVoid OB = (PtrObjVoid)MMstart(m, MTOP(objbmp));
1618 PtrObjBitmap B = (PtrObjBitmap)MMstart(m, MTOP(OB->Buffer));
1633 for (y = 0; y < B->TailleH; y++)
1634 for (x = 0; x < B->TailleW; x++)
1636 byteSRC = x + y * B->TailleW;
1637 byteDST = x * B->BytesPP + y * B->BPL;
1640 B->bits[byteDST] = mbitmap.data[byteSRC];
1641 B->bits[byteDST + 1] = mbitmap.data[byteSRC];
1642 B->bits[byteDST + 2] = mbitmap.data[byteSRC];
1646 MMechostr(MSKDEBUG,
"ok\n");
1661 MMechostr(MSKDEBUG,
"_GETarMarkerPosition\n");
1664 int markerTab = MMget(m, 0);
1665 if (markerTab == NIL)
1671 ArMarker* arMarker = MMgetPointer<ArMarker*>(m, MTOP(markerTab));
1680 int tuplePos = MMmalloc(m, 3, TYPETAB);
1681 if (tuplePos == NIL)
1687 MMstore(m, tuplePos, 0, FTOM(markerPosition.
x));
1688 MMstore(m, tuplePos, 1, FTOM(markerPosition.
y));
1689 MMstore(m, tuplePos, 2, FTOM(markerPosition.
z));
1690 MMset(m, 0, PTOM(tuplePos));
1693 MMechostr(MSKDEBUG,
"ok\n");
1708 MMechostr(MSKDEBUG,
"_GETarMarkerPixelPosition\n");
1711 int markerTab = MMget(m, 0);
1712 if (markerTab == NIL)
1718 ArMarker* arMarker = MMgetPointer<ArMarker*>(m, MTOP(markerTab));
1727 int tuplePos = MMmalloc(m, 3, TYPETAB);
1728 if (tuplePos == NIL)
1734 MMstore(m, tuplePos, 0, ITOM((
int)markerPosition.
x));
1735 MMstore(m, tuplePos, 1, ITOM((
int)markerPosition.
y));
1736 MMstore(m, tuplePos, 2, ITOM((
int)markerPosition.
z));
1737 MMset(m, 0, PTOM(tuplePos));
1740 MMechostr(MSKDEBUG,
"ok\n");
1755 MMechostr(MSKDEBUG,
"_GETarMarkerOrientation\n");
1758 int markerTab = MMget(m, 0);
1759 if (markerTab == NIL)
1765 ArMarker* arMarker = MMgetPointer<ArMarker*>(m, MTOP(markerTab));
1774 int tupleQuat = MMmalloc(m, 4, TYPETAB);
1775 if (tupleQuat == NIL)
1781 MMstore(m, tupleQuat, 0, FTOM(markerOrientation.
x));
1782 MMstore(m, tupleQuat, 1, FTOM(markerOrientation.
y));
1783 MMstore(m, tupleQuat, 2, FTOM(markerOrientation.
z));
1784 MMstore(m, tupleQuat, 3, FTOM(markerOrientation.
w));
1785 MMset(m, 0, PTOM(tupleQuat));
1788 MMechostr(MSKDEBUG,
"ok\n");
1803 MMechostr(MSKDEBUG,
"_ISarMarkerVisible\n");
1806 int markerTab = MMget(m, 0);
1807 if (markerTab == NIL)
1813 ArMarker* arMarker = MMgetPointer<ArMarker*>(m, MTOP(markerTab));
1820 int visible = (arMarker->
IsVisible()) ? 1 : 0;
1822 MMset(m, 0, ITOM(visible));
1825 MMechostr(MSKDEBUG,
"ok\n");
1840 MMechostr(MSKDEBUG,
"_GETarMarkerSize\n");
1843 int markerTab = MMget(m, 0);
1844 if (markerTab == NIL)
1850 ArMarker* arMarker = MMgetPointer<ArMarker*>(m, MTOP(markerTab));
1857 float size = arMarker->
GetSize();
1859 MMset(m, 0, FTOM(size));
1862 MMechostr(MSKDEBUG,
"ok\n");
1878 MMechostr(MSKDEBUG,
"_SETarMarkerSize\n");
1881 int isize = MMpull(m);
1882 int markerTab = MMget(m, 0);
1883 if ((markerTab == NIL) || (isize == NIL))
1889 ArMarker* arMarker = MMgetPointer<ArMarker*>(m, MTOP(markerTab));
1896 float size = MTOF(isize);
1900 MMechostr(MSKRUNTIME,
"_SETarMarkerSize : The marker size can not be inferior or equal to 0.\n");
1906 MMset(m, 0, ITOM(0));
1909 MMechostr(MSKDEBUG,
"ok\n");
1929 MMechostr(MSKDEBUG,
"_SETarMarkerFromPictureZone\n");
1932 int iHeight = MMpull(m);
1933 int iWidth = MMpull(m);
1936 int markerTab = MMget(m, 0);
1938 if ((markerTab == NIL) || (iX == NIL) || (iY == NIL) || (iWidth == NIL) || (iHeight == NIL))
1944 ArMarker* arMarker = MMgetPointer<ArMarker*>(m, MTOP(markerTab));
1954 fftmarker->
RegisterNextFrame(cv::Point(MTOI(iX), MTOI(iY)), cv::Size(MTOI(iWidth), MTOI(iHeight)));
1959 fftmarker->
RegisterNextFrame(cv::Point(MTOI(iX), MTOI(iY)), cv::Size(MTOI(iWidth), MTOI(iHeight)));
1967 MMset(m, 0, ITOM(0));
1970 MMechostr(MSKDEBUG,
"ok\n");
1987 MMechostr(MSKDEBUG,
"_GETarMarkerWarpedBitmap\n");
1991 int bitmap = MMpull(m);
1992 int markerTab = MMget(m, 0);
1994 if ((bitmap == NIL) || (markerTab == NIL))
2000 ArMarker* arMarker = MMgetPointer<ArMarker*>(m, MTOP(markerTab));
2007 PtrObjVoid OB = (PtrObjVoid)MMstart(m, MTOP(bitmap));
2008 PtrObjBitmap B = (PtrObjBitmap)MMstart(m, MTOP(OB->Buffer));
2041 if (B->TailleW != warped.cols || B->TailleH != warped.rows)
2042 cv::resize(warped, warped, cv::Size(B->TailleW, B->TailleH), 0, 0, cv::INTER_LINEAR);
2046 MMset(m, 0, ITOM(0));
2049 MMechostr(MSKDEBUG,
"ok\n");
2065 MMechostr(MSKDEBUG,
"_SAVEarMarkerTrainnedData\n");
2069 int ifile = MMpull(m);
2070 int markerTab = MMget(m, 0);
2072 if ((ifile == NIL) || (markerTab == NIL))
2078 ArMarker* arMarker = MMgetPointer<ArMarker*>(m, MTOP(markerTab));
2084 std::string fpath = MMstartstr(m, MTOP(ifile));
2088 MMset(m, 0, ITOM(0));
2093 MMechostr(MSKDEBUG,
"ok\n");
2110 MMpush(m, ITOM((
int)param));
2112 k = OBJcallreflex(m, 1);
2124 {
"ObjArMarker", TYPTYPE, NULL, NULL },
2125 {
"ObjArCameraParam", TYPTYPE, NULL, NULL },
2126 {
"ObjBlobDetector", TYPTYPE, NULL, NULL },
2127 {
"_CRarMarker", 3,
"fun [Chn I F] ObjArMarker",
_CRarMarker },
2130 {
"_CRarMarkerFromFileEx2", 6,
"fun [Chn P F I fun[ObjArMarker u0 I] u1 u0] ObjArMarker",
_CRarMarkerFromFileEx2 },
2132 {
"_DSarMarker", 1,
"fun [ObjArMarker] I",
_DSarMarker },
2134 {
"_UPDATEarMarkers", 4,
"fun [ObjBitmap ObjArCameraParam I I] ObjBitmap",
_UPDATEarMarkers },
2135 {
"_UPDATEarMarkersBuff", 7,
"fun [ObjBuff I I I ObjArCameraParam I I] ObjBuff",
_UPDATEarMarkersBuff },
2136 {
"_GETarMarkerBitmap", 3,
"fun [Chn ObjArMarker I] ObjBitmap",
_GETarMarkerBitmap },
2141 {
"_CRarCameraParam", 6,
"fun [Chn I I F F P] ObjArCameraParam",
_CRarCameraParam },
2144 {
"_SETcameraSensorsQuat", 2,
"fun [ObjArCameraParam [F F F F]] ObjArCameraParam",
_SETcameraSensorsQuat },
2145 {
"_AddcameraSensorsImu", 4,
"fun [ObjArCameraParam [F F F] [F F F] F] ObjArCameraParam",
_AddcameraSensorsImu },
2146 {
"_SETcameraOffset", 2,
"fun [ObjArCameraParam [F F F]] ObjArCameraParam",
_SETcameraOffset },
2147 {
"_GETcameraOffset", 1,
"fun [ObjArCameraParam] [F F F]",
_GETcameraOffset },
2148 {
"_GETarProjectionMatrix", 3,
"fun [ObjArCameraParam I I] [[F F F F] [F F F F] [F F F F] [F F F F]]",
_GETarProjectionMatrix },
2153 {
"_CRblobDetector", 9,
"fun [Chn I I [I I I] [I I I] [I F F] [I I] [I F F] [I F F]] ObjBlobDetector",
_CRblobDetector },
2155 {
"_GETdetectedBlobs", 1,
"fun [ObjBlobDetector] [[I I F] r1]",
_GETdetectedBlobs },
2159 ,{
"_SetSlamDetectorState", 1,
"fun [I] I", _SetSlamDetectorState },
2160 {
"_GetSlamCameraPosition", 0,
"fun [] [F F F]", _GetSlamCameraPosition },
2161 {
"_GetSlamCameraOrientation", 0,
"fun [] [F F F F]", _GetSlamCameraOrientation },
2162 {
"_IsSlamFound", 0,
"fun [] I", _IsSlamFound },
2163 {
"_ResetSlamDetector", 0,
"fun [] I", _ResetSlamDetector },
2164 {
"_SetSlamDetectorParams", 4,
"fun [I I I I] I", _SetSlamDetectorParams }
2178 MMechostr(MSKDEBUG,
" > Loading ArToolkit\n");
2191 MMechostr(MSKDEBUG,
" > Successfully Loaded\n");
2201 MMechostr(MSKDEBUG,
"\n");
2202 MMechostr(MSKDEBUG,
" > Unloading ArToolkit\n");
2206 MMechostr(MSKDEBUG,
" > Successfully Unloaded\n\n");
int LoadArToolkit(mmachine m)
cv::Size GetLastBufferSize()
std::vector< cv::Point3f > GetLastDotList()
void SetCameraOffset(Vector3 offset)
void SetCameraQuat(BtQuaternion quat)
void GetProjectionMatrix(double m_proj[16], cv::Size screensize)
void AddCameraImu(Vector3 gyro, Vector3 accel, double delta)
Vector3 GetCameraOffset()
This class represents a marker. It is a vector of the fours corners ot the marker.
void RegisterNextFrame(cv::Point point, cv::Size size)
bool GetWarpedMarker(cv::Mat &image)
void RemoveBlobDetector(ArBlobDetector *detector)
ArMarker * AddFaceMarker(float size)
ArMarker * AddMarker(int index, float size)
ArBlobDetector * AddBlobDetector(cv::SimpleBlobDetector::Params params)
static ArManager * GetInstance()
void RemoveMarker(ArMarker *marker)
void UpdateMarkers(cv::Mat image, ArCameraParam *arCameraParam, bool reversedBitmap=false, bool debugDraw=false)
Vector3 GetPixelPosition()
cv::Mat GetMarkerBitmap(int size)
BtQuaternion GetOrientation()
This class represents a marker. It is a vector of the fours corners ot the marker.
bool GetWarpedMarker(cv::Mat &image)
bool SaveData(std::string path)
void RegisterNextFrame(cv::Point point, cv::Size size)