static void keyEvent( unsigned char key, int x, int y) { int value; /* quit if the ESC key is pressed */ if( key == 0x1b ) { cleanup(); exit(0); } if( key == '1' ) { arGetLabelingThresh( arHandle, &value ); value -= 5; if( value < 0 ) value = 0; arSetLabelingThresh( arHandle, value ); ARLOG("thresh = %d\n", value); } if( key == '2' ) { arGetLabelingThresh( arHandle, &value ); value += 5; if( value > 255 ) value = 255; arSetLabelingThresh( arHandle, value ); ARLOG("thresh = %d\n", value); } if( key == 'd' ) { arGetDebugMode( arHandle, &value ); value = 1 - value; arSetDebugMode( arHandle, value ); } }
int ofxArtool5::getThreshold(){ int thr=0; if(getThreshMode()==AR_LABELING_THRESH_MODE_MANUAL){ arGetLabelingThresh(gARHandle, &thr); } return thr; }
static void printMode() { int len, thresh, line, mode, xsize, ysize; AR_LABELING_THRESH_MODE threshMode; ARdouble tempF; char text[256], *text_p; float hMargin = 2.0f; float vMargin = 2.0f; glColor4ub(255, 255, 255, 255); line = 1; // Image size and processing mode. arVideoGetSize(&xsize, &ysize); arGetImageProcMode(gARHandle, &mode); if (mode == AR_IMAGE_PROC_FRAME_IMAGE) text_p = "full frame"; else text_p = "even field only"; snprintf(text, sizeof(text), "Processing %dx%d video frames %s", xsize, ysize, text_p); print(text, hMargin, (line - 1)*(FONT_SIZE + FONT_LINE_SPACING) + vMargin, 0, 1); line++; // Threshold mode, and threshold, if applicable. arGetLabelingThreshMode(gARHandle, &threshMode); switch (threshMode) { case AR_LABELING_THRESH_MODE_MANUAL: text_p = "MANUAL"; break; case AR_LABELING_THRESH_MODE_AUTO_MEDIAN: text_p = "AUTO_MEDIAN"; break; case AR_LABELING_THRESH_MODE_AUTO_OTSU: text_p = "AUTO_OTSU"; break; case AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE: text_p = "AUTO_ADAPTIVE"; break; case AR_LABELING_THRESH_MODE_AUTO_BRACKETING: text_p = "AUTO_BRACKETING"; break; default: text_p = "UNKNOWN"; break; } snprintf(text, sizeof(text), "Threshold mode: %s", text_p); if (threshMode != AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE) { arGetLabelingThresh(gARHandle, &thresh); len = (int)strlen(text); snprintf(text + len, sizeof(text) - len, ", thresh=%d", thresh); } print(text, hMargin, (line - 1)*(FONT_SIZE + FONT_LINE_SPACING) + vMargin, 0, 1); line++; // Border size, image processing mode, pattern detection mode. arGetBorderSize(gARHandle, &tempF); snprintf(text, sizeof(text), "Border: %0.1f%%", tempF*100.0); arGetPatternDetectionMode(gARHandle, &mode); switch (mode) { case AR_TEMPLATE_MATCHING_COLOR: text_p = "Colour template (pattern)"; break; case AR_TEMPLATE_MATCHING_MONO: text_p = "Mono template (pattern)"; break; case AR_MATRIX_CODE_DETECTION: text_p = "Matrix (barcode)"; break; case AR_TEMPLATE_MATCHING_COLOR_AND_MATRIX: text_p = "Colour template + Matrix (2 pass, pattern + barcode)"; break; case AR_TEMPLATE_MATCHING_MONO_AND_MATRIX: text_p = "Mono template + Matrix (2 pass, pattern + barcode "; break; default: text_p = "UNKNOWN"; break; } len = (int)strlen(text); snprintf(text + len, sizeof(text) - len, ", Pattern detection mode: %s", text_p); print(text, hMargin, (line - 1)*(FONT_SIZE + FONT_LINE_SPACING) + vMargin, 0, 1); line++; // Window size. snprintf(text, sizeof(text), "Drawing into %dx%d window", gWindowW, gWindowH); print(text, hMargin, (line - 1)*(FONT_SIZE + FONT_LINE_SPACING) + vMargin, 0, 1); line++; }
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; switch (key) { case 0x1B: // Quit. case 'Q': case 'q': cleanup(); exit(0); break; case ' ': gDrawRotate = !gDrawRotate; break; case 'C': case 'c': ARLOGe("*** Camera - %f (frame/sec)\n", (double)gCallCountMarkerDetect/arUtilTimer()); gCallCountMarkerDetect = 0; arUtilTimerReset(); debugReportMode(gARHandle); break; case '-': threshChange = -5; break; case '+': case '=': threshChange = +5; break; case 'D': case 'd': arGetDebugMode(gARHandle, &mode); arSetDebugMode(gARHandle, !mode); break; case 'B': case 'b': arGetLabelingMode(gARHandle, &mode); if (mode == AR_LABELING_BLACK_REGION) arSetLabelingMode(gARHandle, AR_LABELING_WHITE_REGION); else arSetLabelingMode(gARHandle, AR_LABELING_BLACK_REGION); break; case '?': case '/': ARLOG("Keys:\n"); ARLOG(" q or [esc] Quit demo.\n"); ARLOG(" c Calulcate frame rate.\n"); ARLOG(" - and + Adjust threshhold.\n"); ARLOG(" d Activate / deactivate debug mode.\n"); ARLOG(" b Toggle between detection of black markers and white markers.\n"); ARLOG(" ? or / Show this help.\n"); ARLOG("\nAdditionally, the ARVideo library supplied the following help text:\n"); arVideoDispOption(); 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); ARLOG("Threshhold changed to %d.\n", threshhold); } }
static void printMode() { int len, thresh, line, mode, xsize, ysize; AR_LABELING_THRESH_MODE threshMode; ARdouble tempF; char text[256], *text_p; glColor3ub(255, 255, 255); line = 1; // Image size and processing mode. arVideoGetSize(&xsize, &ysize); arGetImageProcMode(gARHandle, &mode); if (mode == AR_IMAGE_PROC_FRAME_IMAGE) text_p = "full frame"; else text_p = "even field only"; snprintf(text, sizeof(text), "Processing %dx%d video frames %s", xsize, ysize, text_p); print(text, 2.0f, (line - 1)*12.0f + 2.0f, 0, 1); line++; // Threshold mode, and threshold, if applicable. arGetLabelingThreshMode(gARHandle, &threshMode); switch (threshMode) { case AR_LABELING_THRESH_MODE_MANUAL: text_p = "MANUAL"; break; case AR_LABELING_THRESH_MODE_AUTO_MEDIAN: text_p = "AUTO_MEDIAN"; break; case AR_LABELING_THRESH_MODE_AUTO_OTSU: text_p = "AUTO_OTSU"; break; case AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE: text_p = "AUTO_ADAPTIVE"; break; case AR_LABELING_THRESH_MODE_AUTO_BRACKETING: text_p = "AUTO_BRACKETING"; break; default: text_p = "UNKNOWN"; break; } snprintf(text, sizeof(text), "Threshold mode: %s", text_p); if (threshMode != AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE) { arGetLabelingThresh(gARHandle, &thresh); len = (int)strlen(text); snprintf(text + len, sizeof(text) - len, ", thresh=%d", thresh); } print(text, 2.0f, (line - 1)*12.0f + 2.0f, 0, 1); line++; // Border size, image processing mode, pattern detection mode. arGetBorderSize(gARHandle, &tempF); snprintf(text, sizeof(text), "Border: %0.1f%%", tempF*100.0); arGetPatternDetectionMode(gARHandle, &mode); switch (mode) { case AR_TEMPLATE_MATCHING_COLOR: text_p = "Colour template (pattern)"; break; case AR_TEMPLATE_MATCHING_MONO: text_p = "Mono template (pattern)"; break; case AR_MATRIX_CODE_DETECTION: text_p = "Matrix (barcode)"; break; case AR_TEMPLATE_MATCHING_COLOR_AND_MATRIX: text_p = "Colour template + Matrix (2 pass, pattern + barcode)"; break; case AR_TEMPLATE_MATCHING_MONO_AND_MATRIX: text_p = "Mono template + Matrix (2 pass, pattern + barcode "; break; default: text_p = "UNKNOWN"; break; } len = (int)strlen(text); snprintf(text + len, sizeof(text) - len, ", Pattern detection mode: %s", text_p); print(text, 2.0f, (line - 1)*12.0f + 2.0f, 0, 1); line++; // Draw mode. if (arglDrawModeGet(gArglSettings) == AR_DRAW_BY_GL_DRAW_PIXELS) text_p = "GL_DRAW_PIXELS"; else { if (arglTexmapModeGet(gArglSettings) == AR_DRAW_TEXTURE_FULL_IMAGE) text_p = "texture mapping"; else text_p = "texture mapping (even field only)"; } snprintf(text, sizeof(text), "Drawing using %s into %dx%d window", text_p, windowWidth, windowHeight); print(text, 2.0f, (line - 1)*12.0f + 2.0f, 0, 1); line++; }
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); } }
static void printMode() { int len, thresh, line, mode, xsize, ysize, textPatternCount; AR_LABELING_THRESH_MODE threshMode; ARdouble tempF; char text[256], *text_p; glColor3ub(255, 255, 255); line = 1; // Image size and processing mode. arVideoGetSize(&xsize, &ysize); arGetImageProcMode(gARHandle, &mode); if (mode == AR_IMAGE_PROC_FRAME_IMAGE) text_p = "full frame"; else text_p = "even field only"; snprintf(text, sizeof(text), "Processing %dx%d video frames %s", xsize, ysize, text_p); print(text, 2.0f, (line - 1) * 12.0f + 2.0f, 0, 1); line++; // Threshold mode, and threshold, if applicable. arGetLabelingThreshMode(gARHandle, &threshMode); switch (threshMode) { case AR_LABELING_THRESH_MODE_MANUAL: text_p = "MANUAL"; break; case AR_LABELING_THRESH_MODE_AUTO_MEDIAN: text_p = "AUTO_MEDIAN"; break; case AR_LABELING_THRESH_MODE_AUTO_OTSU: text_p = "AUTO_OTSU"; break; case AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE: text_p = "AUTO_ADAPTIVE"; break; case AR_LABELING_THRESH_MODE_AUTO_BRACKETING: text_p = "AUTO_BRACKETING"; break; default: text_p = "UNKNOWN"; break; } snprintf(text, sizeof(text), "Threshold mode: %s", text_p); if (threshMode != AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE) { arGetLabelingThresh(gARHandle, &thresh); len = (int)strlen(text); snprintf(text + len, sizeof(text) - len, ", thresh=%d", thresh); } print(text, 2.0f, (line - 1) * 12.0f + 2.0f, 0, 1); line++; // Border size, image processing mode, pattern detection mode. arGetBorderSize(gARHandle, &tempF); snprintf(text, sizeof(text), "Border: %0.2f%%", tempF * 100.0); arGetPatternDetectionMode(gARHandle, &mode); textPatternCount = 0; switch (mode) { case AR_TEMPLATE_MATCHING_COLOR: text_p = "Colour template (pattern)"; break; case AR_TEMPLATE_MATCHING_MONO: text_p = "Mono template (pattern)"; break; case AR_MATRIX_CODE_DETECTION: text_p = "Matrix (barcode)"; textPatternCount = -1; break; case AR_TEMPLATE_MATCHING_COLOR_AND_MATRIX: text_p = "Colour template + Matrix (2 pass, pattern + barcode)"; break; case AR_TEMPLATE_MATCHING_MONO_AND_MATRIX: text_p = "Mono template + Matrix (2 pass, pattern + barcode "; break; default: text_p = "UNKNOWN"; textPatternCount = -1; break; } if (textPatternCount != -1) textPatternCount = gARPattHandle->patt_num; len = (int)strlen(text); if (textPatternCount != -1) snprintf(text + len, sizeof(text) - len, ", Pattern detection mode: %s, %d patterns loaded", text_p, textPatternCount); else snprintf(text + len, sizeof(text) - len, ", Pattern detection mode: %s", text_p); print(text, 2.0f, (line - 1) * 12.0f + 2.0f, 0, 1); line++; // Robust mode. if (gMultiConfigCount) { snprintf(text, sizeof(text), "Robust multi-marker pose estimation %s", (gRobustFlag ? "ON" : "OFF")); if (gRobustFlag) { icpGetInlierProbability(gAR3DHandle->icpHandle, &tempF); len = (int)strlen(text); snprintf(text + len, sizeof(text) - len, ", inliner prob. %0.1f%%", tempF * 100.0f); } print(text, 2.0f, (line - 1) * 12.0f + 2.0f, 0, 1); line++; } // Window size. snprintf(text, sizeof(text), "Drawing into %dx%d window", windowWidth, windowHeight); print(text, 2.0f, (line - 1) * 12.0f + 2.0f, 0, 1); line++; }