Esempio n. 1
0
bool ARMarkerMulti::updateWithDetectedMarkers(ARMarkerInfo* markerInfo, int markerNum, AR3DHandle *ar3DHandle)
{
	if (!m_loaded || !config) return false;			// Can't update without multimarker config

    visiblePrev = visible;

	if (markerInfo) {
	
		ARdouble err;

		if (robustFlag) {
			err = arGetTransMatMultiSquareRobust(ar3DHandle, markerInfo, markerNum, config);		
		} else {
			err = arGetTransMatMultiSquare(ar3DHandle, markerInfo, markerNum, config);
		}
		
		// Marker is visible if a match was found.
        if (err >= 0) {
            visible = true;
            for (int j = 0; j < 3; j++) for (int k = 0; k < 4; k++) trans[j][k] = config->trans[j][k];
        } else visible = false;

	} else visible = false;

	return (ARMarker::update()); // Parent class will finish update.
}
Esempio n. 2
0
static void mainLoop(void)
{
    int        i;
    static int imageNumber = 0;
    static int ms_prev;
    int        ms;
    float      s_elapsed;
    ARUint8    *image;

    // Find out how long since mainLoop() last ran.
    ms        = glutGet(GLUT_ELAPSED_TIME);
    s_elapsed = (float)(ms - ms_prev) * 0.001f;
    if (s_elapsed < 0.01f)
        return;                        // Don't update more often than 100 Hz.

    ms_prev = ms;

    // Grab a video frame.
    if ((image = arVideoGetImage()) != NULL)
    {
        gARTImage = image;              // Save the fetched image.

        if (gARTImageSavePlease)
        {
            char imageNumberText[15];
            sprintf(imageNumberText, "image-%04d.jpg", imageNumber++);
            if (arVideoSaveImageJPEG(gARHandle->xsize, gARHandle->ysize, gARHandle->arPixelFormat, gARTImage, imageNumberText, 75, 0) < 0)
            {
                ARLOGe("Error saving video image.\n");
            }

            gARTImageSavePlease = FALSE;
        }

        gCallCountMarkerDetect++;         // Increment ARToolKit FPS counter.

        // Detect the markers in the video frame.
        if (arDetectMarker(gARHandle, gARTImage) < 0)
        {
            exit(-1);
        }

        // If  marker config files were specified, evaluate detected patterns against them now.
        for (i = 0; i < gMultiConfigCount; i++)
        {
            if (gRobustFlag)
                gMultiErrs[i] = arGetTransMatMultiSquareRobust(gAR3DHandle, arGetMarker(gARHandle), arGetMarkerNum(gARHandle), gMultiConfigs[i]);
            else
                gMultiErrs[i] = arGetTransMatMultiSquare(gAR3DHandle, arGetMarker(gARHandle), arGetMarkerNum(gARHandle), gMultiConfigs[i]);

            // if (gMultiConfigs[i]->prevF != 0) ARLOGe("Found multimarker set %d, err=%0.3f\n", i, gMultiErrs[i]);
        }

        // Tell GLUT the display has changed.
        glutPostRedisplay();
    }
}
Esempio n. 3
0
static void mainLoop(void)
{
	static int ms_prev;
	int ms;
	float s_elapsed;
	ARUint8 *image;
	ARdouble err;

    int             j, k;
	
	// Find out how long since mainLoop() last ran.
	ms = glutGet(GLUT_ELAPSED_TIME);
	s_elapsed = (float)(ms - ms_prev) * 0.001f;
	if (s_elapsed < 0.01f) return; // Don't update more often than 100 Hz.
	ms_prev = ms;
	
	// Update drawing.
	DrawCubeUpdate(s_elapsed);
	
	// Grab a video frame.
	if ((image = arVideoGetImage()) != NULL) {
		gARTImage = image;	// Save the fetched image.
		
		gCallCountMarkerDetect++; // Increment ARToolKit FPS counter.
		
		// Detect the markers in the video frame.
		if (arDetectMarker(gARHandle, gARTImage) < 0) {
			exit(-1);
		}

		err = arGetTransMatMultiSquare( gAR3DHandle, arGetMarker( gARHandle ), arGetMarkerNum( gARHandle ), gMultiConfig);
		if( gMultiConfig->prevF != 0 ) {
			gPatt_found = TRUE;
			for (k = 0; k < 3; k++) {
				for (j = 0; j < 4; j++) {
					gPatt_trans[k][j] = gMultiConfig->trans[k][j];
				}
			}
		} else {
			gPatt_found = FALSE;
		}
		// Tell GLUT the display has changed.
		glutPostRedisplay();
	}
}