ARHandle *arCreateHandle( ARParamLT *paramLT ) { ARHandle *handle; arMalloc( handle, ARHandle, 1 ); handle->arDebug = AR_DEBUG_DISABLE; #if !AR_DISABLE_LABELING_DEBUG_MODE handle->labelInfo.bwImage = NULL; #endif handle->arImageProcInfo = NULL; handle->arPixelFormat = AR_PIXEL_FORMAT_INVALID; handle->arPixelSize = 0; handle->arLabelingMode = AR_DEFAULT_LABELING_MODE; handle->arLabelingThresh = AR_DEFAULT_LABELING_THRESH; handle->arImageProcMode = AR_DEFAULT_IMAGE_PROC_MODE; handle->arPatternDetectionMode = AR_DEFAULT_PATTERN_DETECTION_MODE; handle->arMarkerExtractionMode = AR_DEFAULT_MARKER_EXTRACTION_MODE; handle->pattRatio = AR_PATT_RATIO; handle->matrixCodeType = AR_MATRIX_CODE_TYPE_DEFAULT; handle->arParamLT = paramLT; handle->xsize = paramLT->param.xsize; handle->ysize = paramLT->param.ysize; handle->marker_num = 0; handle->marker2_num = 0; handle->labelInfo.label_num = 0; handle->history_num = 0; arMalloc( handle->labelInfo.labelImage, AR_LABELING_LABEL_TYPE, handle->xsize*handle->ysize ); handle->pattHandle = NULL; arSetDebugMode(handle, AR_DEFAULT_DEBUG_MODE); handle->arLabelingThreshMode = -1; arSetLabelingThreshMode(handle, AR_LABELING_THRESH_MODE_DEFAULT); arSetLabelingThreshModeAutoInterval(handle, AR_LABELING_THRESH_AUTO_INTERVAL_DEFAULT); return handle; }
static void Keyboard(unsigned char key, int x, int y) { int mode, threshChange = 0; AR_LABELING_THRESH_MODE modea; switch (key) { case 0x1B: // Quit. case 'Q': case 'q': cleanup(); exit(0); break; case 'X': case 'x': arGetImageProcMode(gARHandle, &mode); switch (mode) { case AR_IMAGE_PROC_FRAME_IMAGE: mode = AR_IMAGE_PROC_FIELD_IMAGE; break; case AR_IMAGE_PROC_FIELD_IMAGE: default: mode = AR_IMAGE_PROC_FRAME_IMAGE; break; } arSetImageProcMode(gARHandle, mode); break; case 'C': case 'c': ARLOGe("*** Camera - %f (frame/sec)\n", (double)gCallCountMarkerDetect/arUtilTimer()); gCallCountMarkerDetect = 0; arUtilTimerReset(); break; case 'a': case 'A': arGetLabelingThreshMode(gARHandle, &modea); switch (modea) { case AR_LABELING_THRESH_MODE_MANUAL: modea = AR_LABELING_THRESH_MODE_AUTO_MEDIAN; break; case AR_LABELING_THRESH_MODE_AUTO_MEDIAN: modea = AR_LABELING_THRESH_MODE_AUTO_OTSU; break; case AR_LABELING_THRESH_MODE_AUTO_OTSU: modea = AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE; break; case AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE: modea = AR_LABELING_THRESH_MODE_AUTO_BRACKETING; break; case AR_LABELING_THRESH_MODE_AUTO_BRACKETING: default: modea = AR_LABELING_THRESH_MODE_MANUAL; break; } arSetLabelingThreshMode(gARHandle, modea); break; case '-': threshChange = -5; break; case '+': case '=': threshChange = +5; break; case 'D': case 'd': arGetDebugMode(gARHandle, &mode); arSetDebugMode(gARHandle, !mode); break; case '?': case '/': gShowHelp++; if (gShowHelp > 1) gShowHelp = 0; break; case 'm': case 'M': gShowMode = !gShowMode; break; default: break; } if (threshChange) { int threshhold; arGetLabelingThresh(gARHandle, &threshhold); threshhold += threshChange; if (threshhold < 0) threshhold = 0; if (threshhold > 255) threshhold = 255; arSetLabelingThresh(gARHandle, threshhold); } }
static void Keyboard(unsigned char key, int x, int y) { int mode, threshChange = 0; AR_LABELING_THRESH_MODE modea; switch (key) { case 0x1B: // Quit. case 'Q': case 'q': cleanup(); exit(0); break; case ' ': gDrawRotate = !gDrawRotate; break; case 'X': case 'x': arGetImageProcMode(gARHandle, &mode); switch (mode) { case AR_IMAGE_PROC_FRAME_IMAGE: mode = AR_IMAGE_PROC_FIELD_IMAGE; break; case AR_IMAGE_PROC_FIELD_IMAGE: default: mode = AR_IMAGE_PROC_FRAME_IMAGE; break; } arSetImageProcMode(gARHandle, mode); break; case 'C': case 'c': mode = arglDrawModeGet(gArglSettings); if (mode == AR_DRAW_BY_GL_DRAW_PIXELS) { arglDrawModeSet(gArglSettings, AR_DRAW_BY_TEXTURE_MAPPING); arglTexmapModeSet(gArglSettings, AR_DRAW_TEXTURE_FULL_IMAGE); } else { mode = arglTexmapModeGet(gArglSettings); if (mode == AR_DRAW_TEXTURE_FULL_IMAGE) arglTexmapModeSet(gArglSettings, AR_DRAW_TEXTURE_HALF_IMAGE); else arglDrawModeSet(gArglSettings, AR_DRAW_BY_GL_DRAW_PIXELS); } ARLOGe("*** Camera - %f (frame/sec)\n", (double)gCallCountMarkerDetect/arUtilTimer()); gCallCountMarkerDetect = 0; arUtilTimerReset(); break; case 'a': case 'A': arGetLabelingThreshMode(gARHandle, &modea); switch (modea) { case AR_LABELING_THRESH_MODE_MANUAL: modea = AR_LABELING_THRESH_MODE_AUTO_MEDIAN; break; case AR_LABELING_THRESH_MODE_AUTO_MEDIAN: modea = AR_LABELING_THRESH_MODE_AUTO_OTSU; break; case AR_LABELING_THRESH_MODE_AUTO_OTSU: modea = AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE; break; case AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE: modea = AR_LABELING_THRESH_MODE_AUTO_BRACKETING; break; case AR_LABELING_THRESH_MODE_AUTO_BRACKETING: default: modea = AR_LABELING_THRESH_MODE_MANUAL; break; } arSetLabelingThreshMode(gARHandle, modea); break; case '-': threshChange = -5; break; case '+': case '=': threshChange = +5; break; case 'D': case 'd': arGetDebugMode(gARHandle, &mode); arSetDebugMode(gARHandle, !mode); break; case 's': case 'S': if (!gARTImageSavePlease) gARTImageSavePlease = TRUE; break; case '?': case '/': gShowHelp++; if (gShowHelp > 1) gShowHelp = 0; break; case 'm': case 'M': gShowMode = !gShowMode; break; default: break; } if (threshChange) { int threshhold; arGetLabelingThresh(gARHandle, &threshhold); threshhold += threshChange; if (threshhold < 0) threshhold = 0; if (threshhold > 255) threshhold = 255; arSetLabelingThresh(gARHandle, threshhold); } }