bool ofxArtool5::initNFT(ARParamLT * cparamLT, AR_PIXEL_FORMAT pixFormat){ kpmHandle = kpmCreateHandle(cparamLT, pixFormat); if (!kpmHandle) { ofLogError("ofxArtool5::initNFT","kpmCreateHandle"); return false; } if((ar2Handle = ar2CreateHandle(cparamLT, pixFormat, AR2_TRACKING_DEFAULT_THREAD_NUM))==NULL){ ofLogError("ofxArtool5::initNFT","ar2CreateHandle"); kpmDeleteHandle(&kpmHandle); return false; } if(threadGetCPU()<=1){ ofLogWarning("ofxArtool5::initNFT","Using NFT settings for a single CPU"); ar2SetTrackingThresh(ar2Handle, 5.0); ar2SetSimThresh(ar2Handle, 0.50); ar2SetSearchFeatureNum(ar2Handle, 16); ar2SetSearchSize(ar2Handle, 6); ar2SetTemplateSize1(ar2Handle, 6); ar2SetTemplateSize2(ar2Handle, 6); }else{ cout<<"ofxArtool5::initNFT: Using NFT settings for multi CPU"<<endl; ar2SetTrackingThresh(ar2Handle, 5.0); ar2SetSimThresh(ar2Handle, 0.50); ar2SetSearchFeatureNum(ar2Handle, 16); ar2SetSearchSize(ar2Handle, 12); ar2SetTemplateSize1(ar2Handle, 6); ar2SetTemplateSize2(ar2Handle, 6); } return true; }
// cleanup(); JNIEXPORT jboolean JNICALL JNIFUNCTION_NATIVE(nativeStop(JNIEnv* env, jobject object)) { #ifdef DEBUG LOGI("nativeStop\n"); #endif int i, j; // Can't call arglCleanup() here, because nativeStop is not called on rendering thread. // NFT cleanup. if (trackingThreadHandle) { #ifdef DEBUG LOGI("Stopping NFT2 tracking thread."); #endif trackingInitQuit(&trackingThreadHandle); detectedPage = -2; } j = 0; for (i = 0; i < surfaceSetCount; i++) { if (surfaceSet[i]) { #ifdef DEBUG if (j == 0) LOGI("Unloading NFT tracking surfaces."); #endif ar2FreeSurfaceSet(&surfaceSet[i]); // Sets surfaceSet[i] to NULL. j++; } } #ifdef DEBUG if (j > 0) LOGI("Unloaded %d NFT tracking surfaces.", j); #endif surfaceSetCount = 0; nftDataLoaded = false; #ifdef DEBUG LOGI("Cleaning up ARToolKit NFT handles."); #endif ar2DeleteHandle(&ar2Handle); kpmDeleteHandle(&kpmHandle); arParamLTFree(&gCparamLT); // OpenGL cleanup -- not done here. // Video cleanup. if (gVideoFrame) { free(gVideoFrame); gVideoFrame = NULL; gVideoFrameSize = 0; pthread_mutex_destroy(&gVideoFrameLock); } ar2VideoClose(gVid); gVid = NULL; videoInited = false; return (true); }
// Modifies globals: kpmHandle, ar2Handle. static int initNFT(ARParamLT *cparamLT, AR_PIXEL_FORMAT pixFormat) { #ifdef DEBUG LOGE("Initialising NFT.\n"); #endif // // NFT init. // // KPM init. kpmHandle = kpmCreateHandle(cparamLT, pixFormat); if (!kpmHandle) { LOGE("Error: kpmCreatHandle.\n"); return (false); } //kpmSetProcMode( kpmHandle, KpmProcHalfSize ); // AR2 init. if( (ar2Handle = ar2CreateHandle(cparamLT, pixFormat, AR2_TRACKING_DEFAULT_THREAD_NUM)) == NULL ) { LOGE("Error: ar2CreateHandle.\n"); kpmDeleteHandle(&kpmHandle); return (false); } if (threadGetCPU() <= 1) { #ifdef DEBUG LOGE("Using NFT tracking settings for a single CPU.\n"); #endif ar2SetTrackingThresh( ar2Handle, 5.0 ); ar2SetSimThresh( ar2Handle, 0.50 ); ar2SetSearchFeatureNum(ar2Handle, 16); ar2SetSearchSize(ar2Handle, 6); ar2SetTemplateSize1(ar2Handle, 6); ar2SetTemplateSize2(ar2Handle, 6); } else { #ifdef DEBUG LOGE("Using NFT tracking settings for more than one CPU.\n"); #endif ar2SetTrackingThresh( ar2Handle, 5.0 ); ar2SetSimThresh( ar2Handle, 0.50 ); ar2SetSearchFeatureNum(ar2Handle, 16); ar2SetSearchSize(ar2Handle, 12); ar2SetTemplateSize1(ar2Handle, 6); ar2SetTemplateSize2(ar2Handle, 6); } // NFT dataset loading will happen later. #ifdef DEBUG LOGE("NFT initialised OK.\n"); #endif return (true); }
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); } }
static void cleanup(void) { VirtualEnvironmentFinal(); if (markersNFT) deleteMarkers(&markersNFT, &markersNFTCount); // NFT cleanup. unloadNFTData(); ARLOGd("Cleaning up ARToolKit NFT handles.\n"); ar2DeleteHandle(&ar2Handle); kpmDeleteHandle(&kpmHandle); arParamLTFree(&gCparamLT); // OpenGL cleanup. arglCleanup(gArglSettings); gArglSettings = NULL; // Camera cleanup. arVideoCapStop(); arVideoClose(); }
static void cleanup(void) { if (markersNFT) deleteMarkers(&markersNFT, &markersNFTCount); // NFT cleanup. unloadNFTData(); ARLOGd("Cleaning up ARToolKit NFT handles.\n"); ar2DeleteHandle(&ar2Handle); kpmDeleteHandle(&kpmHandle); arParamLTFree(&gCparamLT); // OpenGL cleanup. arglCleanup(gArglSettings); gArglSettings = NULL; // Camera cleanup. arVideoCapStop(); arVideoClose(); #ifdef _WIN32 CoUninitialize(); #endif }