//-------------------------------------------------------------- vector<ofxMagneticBlob> ofxMagneticApp::getBlobs(bool bReturnPoints) { // Get blob without points, but no peak data return getBlobs(bReturnPoints, false); }
//-------------------------------------------------------------- vector<ofxMagneticBlob> ofxMagneticApp::getBlobs() { // Get blob without point or peak data return getBlobs(false, false); }
/****************************************************************************** * The update function runs continuously. Use it to update states and variables *****************************************************************************/ void ofxNCoreVision::_update(ofEventArgs &e) { if(debugMode) if((stream = freopen(fileName, "a", stdout)) == NULL){} bNewFrame = false; if (bcamera) { #ifdef TARGET_WIN32 if (calib.calibrating) { if (calib.shouldStart) { multiplexerManager->startCalibration(); calib.shouldStart = false; } else multiplexerManager->updateCalibrationStatus(); } multiplexer->updateStitchedFrame(); bNewFrame = true; #endif } else //if video { vidPlayer->idleMovie(); bNewFrame = vidPlayer->isFrameNew(); } //if no new frame, return if(!bNewFrame) { return; } else//else process camera frame { // Main Application BG Color //ofBackground(0, 0, 0); //ofBackground(255, 255, 255); // Calculate FPS of Camera frames++; float time = ofGetElapsedTimeMillis(); if (time > (lastFPSlog + 1000)) { fps = frames; frames = 0; lastFPSlog = time; }//End calculation float beforeTime = ofGetElapsedTimeMillis(); if (bGPUMode) { grabFrameToGPU(filter->gpuSourceTex); filter->applyGPUFilters(); contourFinder.findContours(filter->gpuReadBackImageGS, (MIN_BLOB_SIZE * 2) + 1, ((camWidth * camHeight) * .4) * (MAX_BLOB_SIZE * .001), maxBlobs, false); if(contourFinder.bTrackFiducials || bFidtrackInterface) { grabFrameToGPU(filter_fiducial->gpuSourceTex); filter_fiducial->applyGPUFilters(); if (contourFinder.bTrackFiducials) fidfinder.findFiducials( filter_fiducial->gpuReadBackImageGS ); } } else { grabFrameToCPU(); filter->applyCPUFilters( processedImg ); contourFinder.findContours(processedImg, (MIN_BLOB_SIZE * 2) + 1, ((camWidth * camHeight) * .4) * (MAX_BLOB_SIZE * .001), maxBlobs, false); if(contourFinder.bTrackFiducials || bFidtrackInterface) { filter_fiducial->applyCPUFilters( processedImg_fiducial ); if (contourFinder.bTrackFiducials) fidfinder.findFiducials( processedImg_fiducial ); } } //If Object tracking or Finger tracking is enabled if(contourFinder.bTrackFingers || contourFinder.bTrackObjects) { tracker.track(&contourFinder); } //Map Fiducials from camera to screen position if(contourFinder.bTrackFiducials) { tracker.doFiducialCalculation(); } //get DSP time differenceTime = ofGetElapsedTimeMillis() - beforeTime; //Dynamic Background subtraction LearRate if (filter->bDynamicBG) { filter->fLearnRate = backgroundLearnRate * .0001; //If there are no blobs, add the background faster. if (contourFinder.nBlobs > 0) //If there ARE blobs, add the background slower. { filter->fLearnRate = backgroundLearnRate * .0001; } }//End Background Learning rate //Sending TUIO messages if (myTUIO.bOSCMode || myTUIO.bTCPMode || myTUIO.bBinaryMode) { //printf("sending data osc : %d TCP : %d binary : %d\n", myTUIO.bOSCMode, myTUIO.bTCPMode, myTUIO.bBinaryMode); myTUIO.setMode(contourFinder.bTrackFingers , contourFinder.bTrackObjects, contourFinder.bTrackFiducials); myTUIO.sendTUIO(&getBlobs(),&getObjects(),&fidfinder.fiducialsList); } } }