Ejemplo n.º 1
0
JNIEXPORT jboolean JNICALL JNIFUNCTION_NATIVE(nativeCreate(JNIEnv* env, jobject object, jobject instanceOfAndroidContext))
{
    int err_i;
#ifdef DEBUG
    LOGI("nativeCreate\n");
#endif

    // Change working directory for the native process, so relative paths can be used for file access.
    arUtilChangeToResourcesDirectory(AR_UTIL_RESOURCES_DIRECTORY_BEHAVIOR_BEST, NULL, instanceOfAndroidContext);

    // Load marker(s).
    arPattHandle = arPattCreateHandle();
	if (arPattHandle == NULL) {
		LOGE("Error creating pattern handle");
		return false;
	}
    newMarkers(markerConfigDataFilename, arPattHandle, &markersSquare, &markersSquareCount, &arPattDetectionMode);
    if (!markersSquareCount) {
        LOGE("Error loading markers from config. file '%s'.", markerConfigDataFilename);
        arPattDeleteHandle(arPattHandle);
        arPattHandle = NULL;
        return false;
    }
#ifdef DEBUG
    LOGE("Marker count = %d\n", markersSquareCount);
#endif
    
	return (true);
}
Ejemplo n.º 2
0
static void cleanup(void)
{
	arglCleanup(gArglSettings);
    gArglSettings = NULL;
	arPattDetach(gARHandle);
	arPattDeleteHandle(gARPattHandle);
	arVideoCapStop();
	ar3DDeleteHandle(&gAR3DHandle);
	arDeleteHandle(gARHandle);
    arParamLTFree(&gCparamLT);
	arVideoClose();
}
Ejemplo n.º 3
0
JNIEXPORT jboolean JNICALL JNIFUNCTION_NATIVE(nativeDestroy(JNIEnv* env, jobject object))
{
#ifdef DEBUG
    LOGI("nativeDestroy\n");
#endif        
    if (markersSquare) deleteMarkers(&markersSquare, &markersSquareCount, arPattHandle);
    if (arPattHandle) {
        arPattDeleteHandle(arPattHandle);
        arPattHandle = NULL;
    }
   
    return (true);
}
Ejemplo n.º 4
0
ARTApp::~ARTApp()
{
	arPattDetach(arHandle);
	arPattDeleteHandle(pattHandle);
	arVideoCapStop();
	ar3DDeleteHandle(&ar3DHandle);
	arDeleteHandle(arHandle);
	arParamLTFree(&cParam);
	arVideoClose();

	if (objModel)
		glmDelete(objModel);
}
Ejemplo n.º 5
0
void ofxArtool5::cleanup(){
    if(artMode==ART_PATTERN){
        arPattDetach(gARHandle);
        arPattDeleteHandle(gARPattHandle);
        ar3DDeleteHandle(&gAR3DHandle);
        arDeleteHandle(gARHandle);
        arParamLTFree(&gCparamLT);
    }else if(artMode==ART_NFT){
        if(markersNFT)deleteMarkers(&markersNFT, &markersNFTCount);
        unloadNFTData();
        ar2DeleteHandle(&ar2Handle);
        kpmDeleteHandle(&kpmHandle);
        arParamLTFree(&gCparamLT);
    }
}
Ejemplo n.º 6
0
static void cleanup(void)
{
    if (gObjectData) {
        arPattDetach(gARHandle);
        arPattDeleteHandle(gObjectData->pattHandle);
    }
    arglCleanup(gArglSettings);
    gArglSettings = NULL;
    arVideoCapStop();
    ar3DDeleteHandle(&gAR3DHandle);
    arDeleteHandle(gARHandle);
    arParamLTFree(&gCparamLT);
    arVideoClose();
#ifdef _WIN32
    CoUninitialize();
#endif
}
Ejemplo n.º 7
0
static int setupMarker(const char *patt_name, int *patt_id, ARHandle *arhandle, ARPattHandle **pattHandle_p)
{	
    if ((*pattHandle_p = arPattCreateHandle()) == NULL) {
        ARLOGe("setupMarker(): Error: arPattCreateHandle.\n");
        return (FALSE);
    }
    
	// Loading only 1 pattern in this example.
	if ((*patt_id = arPattLoad(*pattHandle_p, patt_name)) < 0) {
		ARLOGe("setupMarker(): Error loading pattern file %s.\n", patt_name);
		arPattDeleteHandle(*pattHandle_p);
		return (FALSE);
	}
    
    arPattAttach(arhandle, *pattHandle_p);
	
	return (TRUE);
}
Ejemplo n.º 8
0
bool ofxArtool5::setupMarker(string pthMarker){
    const char * cPthMarker = ofToDataPath(pthMarker).c_str();
    
    if((gARPattHandle = arPattCreateHandle())==NULL){
        ofLogError("ofxArtool5::setupMarker()","Error arPattCreateHandle");
        return false;
    }
    
    if((pattId = arPattLoad(gARPattHandle, cPthMarker))<0){
        ofLogError("ofxArtool5::setupMarker()","Error arPattLoad");
        arPattDeleteHandle(gARPattHandle);
        return false;
    }
    
    arPattAttach(gARHandle, gARPattHandle);
    
    return true;
}
Ejemplo n.º 9
0
static void cleanup(void)
{
    // Dispose of movie drawing structures, and stop and close the movie file.
    arglCleanup(gMovieArglSettings);
    gMovieArglSettings = NULL;
    if (gMovieVideo) {
        ar2VideoCapStop(gMovieVideo);
        ar2VideoClose(gMovieVideo);
    }    
	arglCleanup(gArglSettings);
    gArglSettings = NULL;
	arPattDetach(gARHandle);
	arPattDeleteHandle(gARPattHandle);
	arVideoCapStop();
	ar3DDeleteHandle(&gAR3DHandle);
	arDeleteHandle(gARHandle);
    arParamLTFree(&gCparamLT);
	arVideoClose();
}
Ejemplo n.º 10
0
static void cleanup(void)
{
    int i;

    arglCleanup(gArglSettings);
    gArglSettings = NULL;

    arPattDetach(gARHandle);

    for (i = 0; i < gMultiConfigCount; i++)
    {
        arMultiFreeConfig(gMultiConfigs[i]);
    }

    if (gARPattHandle)
        arPattDeleteHandle(gARPattHandle);

    arVideoCapStop();
    arDeleteHandle(gARHandle);
    arParamLTFree(&gCparamLT);
    arVideoClose();
}
Ejemplo n.º 11
0
static void cleanup(void)
{
	VirtualEnvironmentFinal();

    if (markersSquare) deleteMarkers(&markersSquare, &markersSquareCount, gARPattHandle);
    
    // Tracking cleanup.
    if (gARPattHandle) {
        arPattDetach(gARHandle);
		arPattDeleteHandle(gARPattHandle);
	}
	ar3DDeleteHandle(&gAR3DHandle);
	arDeleteHandle(gARHandle);
    arParamLTFree(&gCparamLT);

    // OpenGL cleanup.
    arglCleanup(gArglSettings);
    gArglSettings = NULL;
    
    // Camera cleanup.
	arVideoCapStop();
	arVideoClose();
}
Ejemplo n.º 12
0
static int setupCubeMarker(const char *patt_name, ARMultiMarkerInfoT **multiConfig_p, ARHandle *arhandle, ARPattHandle **pattHandle_p)
{	
    if ((*pattHandle_p = arPattCreateHandle()) == NULL) {
        ARLOGe("setupCubeMarker(): Error: arPattCreateHandle.\n");
        return (FALSE);
    }
    
	if (((*multiConfig_p) = arMultiReadConfigFile(patt_name, *pattHandle_p)) == NULL) {
		ARLOGe("setupCubeMarker(): Error reading multimarker config file '%s'.\n", patt_name);
		arPattDeleteHandle(*pattHandle_p);
		return (FALSE);
	}
	if( (*multiConfig_p)->patt_type == AR_MULTI_PATTERN_DETECTION_MODE_TEMPLATE ) {
        arSetPatternDetectionMode( arhandle, AR_TEMPLATE_MATCHING_COLOR );
    } else if( (*multiConfig_p)->patt_type == AR_MULTI_PATTERN_DETECTION_MODE_MATRIX ) {
        arSetPatternDetectionMode( arhandle, AR_MATRIX_CODE_DETECTION );
    } else { // AR_MULTI_PATTERN_DETECTION_MODE_TEMPLATE_AND_MATRIX
        arSetPatternDetectionMode( arhandle, AR_TEMPLATE_MATCHING_COLOR_AND_MATRIX );
    }	
    
    arPattAttach(arhandle, *pattHandle_p);
	
	return (TRUE);
}
Ejemplo n.º 13
0
static int setupMarkers(const int patt_count, const char *patt_names[], ARMultiMarkerInfoT *multiConfigs[], ARHandle *arhandle, ARPattHandle **pattHandle_p)
{
    int i;

    if (!patt_count)
    {
        // Default behaviour is to default to matrix mode.
        *pattHandle_p = NULL;
        arSetPatternDetectionMode(arhandle, AR_MATRIX_CODE_DETECTION);   // If no markers specified, default to matrix mode.
    }
    else
    {
        // If marker configs have been specified, attempt to load them.

        int mode = -1, nextMode;

        // Need a pattern handle because the config file could specify matrix or template markers.
        if ((*pattHandle_p = arPattCreateHandle2(gPattSize, gPattCountMax)) == NULL)
        {
            ARLOGe("setupMarkers(): Error: arPattCreateHandle2.\n");
            return (FALSE);
        }

        for (i = 0; i < patt_count; i++)
        {
            if (!(multiConfigs[i] = arMultiReadConfigFile(patt_names[i], *pattHandle_p)))
            {
                ARLOGe("setupMarkers(): Error reading multimarker config file '%s'.\n", patt_names[i]);

                for (i--; i >= 0; i--)
                {
                    arMultiFreeConfig(multiConfigs[i]);
                }

                arPattDeleteHandle(*pattHandle_p);
                return (FALSE);
            }

            if (multiConfigs[i]->patt_type == AR_MULTI_PATTERN_DETECTION_MODE_TEMPLATE)
            {
                nextMode = AR_TEMPLATE_MATCHING_COLOR;
            }
            else if (multiConfigs[i]->patt_type == AR_MULTI_PATTERN_DETECTION_MODE_MATRIX)
            {
                nextMode = AR_MATRIX_CODE_DETECTION;
            }
            else     // AR_MULTI_PATTERN_DETECTION_MODE_TEMPLATE_AND_MATRIX or mixed.
            {
                nextMode = AR_TEMPLATE_MATCHING_COLOR_AND_MATRIX;
            }

            if (mode == -1)
            {
                mode = nextMode;
            }
            else if (mode != nextMode)
            {
                mode = AR_TEMPLATE_MATCHING_COLOR_AND_MATRIX;
            }
        }

        arSetPatternDetectionMode(arhandle, mode);

        arPattAttach(arhandle, *pattHandle_p);
    }

    return (TRUE);
}