66const ARPose ARPoseUnity = {{1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}};
89void newMarkers(
const char *markersConfigDataFilePathC, ARPattHandle *arPattHandle,
ARMarkerSquare **markersSquare_out,
int *markersSquareCount_out,
int *patternDetectionMode_out)
92 char buf[MAXPATHLEN], buf1[MAXPATHLEN];
95 int markersSquareCount;
98 char markersConfigDataDirC[MAXPATHLEN];
99 size_t markersConfigDataDirCLen;
102 if (!markersConfigDataFilePathC || markersConfigDataFilePathC[0] ==
'\0' || !markersSquareCount_out || !markersSquare_out)
return;
105 ARLOGd(
"Opening marker config. data file from path '%s'.\n", markersConfigDataFilePathC);
106 arUtilGetDirectoryNameFromPath(markersConfigDataDirC, markersConfigDataFilePathC, MAXPATHLEN, 1);
107 markersConfigDataDirCLen = strlen(markersConfigDataDirC);
108 if ((fp = fopen(markersConfigDataFilePathC,
"r")) == NULL) {
109 ARLOGe(
"Error: unable to locate marker config data file '%s'.\n", markersConfigDataFilePathC);
114 get_buff(buf, MAXPATHLEN, fp, 1);
115 if (sscanf(buf,
"%d", &tempI) != 1 ) {
116 ARLOGe(
"Error in marker configuration data file; expected marker count.\n");
122 markersSquareCount = tempI;
124 ARLOGd(
"Reading %d marker configuration(s).\n", markersSquareCount);
126 for (i = 0; i < markersSquareCount; i++) {
129 if (!get_buff(buf, MAXPATHLEN, fp, 1)) {
130 ARLOGe(
"Error in marker configuration data file; expected marker name.\n");
135 if (!get_buff(buf1, MAXPATHLEN, fp, 1)) {
136 ARLOGe(
"Error in marker configuration data file; expected marker type.\n");
141 if (strcmp(buf1,
"SINGLE") == 0) {
145 if (!get_buff(buf1, MAXPATHLEN, fp, 1) || sscanf(buf1,
146#ifdef ARDOUBLE_IS_FLOAT
152 ARLOGe(
"Error in marker configuration data file; expected marker width.\n");
157 if (sscanf(buf,
"%d", &tempI) != 1) {
159 ARLOGe(
"Error: Marker pattern file '%s' specified but only barcodes allowed.\n", markersSquare[i].patternPathname);
162 arMalloc(markersSquare[i].patternPathname,
char, markersConfigDataDirCLen + strlen(buf) + 1);
163 strcpy(markersSquare[i].patternPathname, markersConfigDataDirC);
164 strcpy(markersSquare[i].patternPathname + markersConfigDataDirCLen, buf);
167 if ((markersSquare[i].patt_id = arPattLoad(arPattHandle, markersSquare[i].patternPathname)) < 0 ) {
168 ARLOGe(
"Error: Unable to load marker pattern from file'%s'.\n", markersSquare[i].patternPathname);
176 markersSquare[i].
patt_id = tempI;
184 }
else if (strcmp(buf1,
"MULTI") == 0) {
185 ARLOGe(
"Error in marker configuration data file; MULTI markers not supported in this build.\n");
186 }
else if (strcmp(buf1,
"NFT") == 0) {
187 ARLOGe(
"Error in marker configuration data file; NFT markers not supported in this build.\n");
189 ARLOGe(
"Error in marker configuration data file; unsupported marker type %s.\n", buf1);
193 while (get_buff(buf, MAXPATHLEN, fp, 0) && (buf[0] !=
'\0')) {
194 if (strncmp(buf,
"FILTER", 6) == 0) {
196 markersSquare[i].
filterSampleRate = AR_FILTER_TRANS_MAT_SAMPLE_RATE_DEFAULT;
197 if (strlen(buf) != 6) {
199#ifdef ARDOUBLE_IS_FLOAT
206 markersSquare[i].
ftmi = arFilterTransMatInit(markersSquare[i].filterSampleRate, markersSquare[i].filterCutoffFrequency);
214 if (i < markersSquareCount) {
217 for (; i >= 0; i--) {
218 if (markersSquare[i].patt_type ==
AR_PATTERN_TYPE_TEMPLATE && markersSquare[i].patt_id && arPattHandle) arPattFree(arPattHandle, markersSquare[i].patt_id);
219 if (markersSquare[i].patternPathname) free(markersSquare[i].patternPathname);
220 if (markersSquare[i].ftmi) arFilterTransMatFinal(markersSquare[i].ftmi);
224 *markersSquareCount_out = 0;
225 *markersSquare_out = NULL;
226 if (patternDetectionMode_out) *patternDetectionMode_out = -1;
230 *markersSquareCount_out = markersSquareCount;
231 *markersSquare_out = markersSquare;
233 if (patternDetectionMode_out) {
236 if ((patt_type & 0x03) == 0x03) {*patternDetectionMode_out = AR_TEMPLATE_MATCHING_COLOR_AND_MATRIX; }
237 else if (patt_type & 0x02) {*patternDetectionMode_out = AR_MATRIX_CODE_DETECTION;}
238 else {*patternDetectionMode_out = AR_TEMPLATE_MATCHING_COLOR;}
246 if (!markersSquare_p || !*markersSquare_p || !*markersSquareCount_p || *markersSquareCount_p < 1)
return;
248 for (i = 0; i < *markersSquareCount_p; i++) {
249 if ((*markersSquare_p)[i].patt_type ==
AR_PATTERN_TYPE_TEMPLATE && (*markersSquare_p)[i].patt_id && arPattHandle) arPattFree(arPattHandle, (*markersSquare_p)[i].patt_id);
250 if ((*markersSquare_p)[i].patternPathname) {
251 free((*markersSquare_p)[i].patternPathname);
252 (*markersSquare_p)[i].patternPathname = NULL;
254 if ((*markersSquare_p)[i].ftmi) {
255 arFilterTransMatFinal((*markersSquare_p)[i].ftmi);
256 (*markersSquare_p)[i].ftmi = NULL;
259 free(*markersSquare_p);
260 *markersSquare_p = NULL;
261 *markersSquareCount_p = 0;