bool DepthVisualizerInput::update(){ bool isFrameNew = false; /*if(useKinect) { kinect.update(); if(kinect.isFrameNew()) { isFrameNew = true; depthImage.setFromPixels(kinect.getDepthPixels(), camWidth, camHeight); depthImage.flagImageChanged(); } } else */ { if(panel->getValueB("playbackPause") ) { animation.setPlaySpeed(0); } else { animation.setPlaySpeed(panel->getValueF("playSpeed")); } if(animation.isFrameNew()) { isFrameNew = true; ofImage& cur = animation.getAlpha(); depthImage.setFromPixels(cur.getPixels(), cur.getWidth(), cur.getHeight()); depthImage.flagImageChanged(); colorPixels = animation.get().getPixels(); } } if(isFrameNew) { thresholdDepthImage(); buildPointCloud(); } return isFrameNew; }
/** * Grab a new frame and process it */ void VitalsModel::processFrame() { cout << "ProcessFrame"; ImageBundle images = imGrab.getLatestImages(); Mat threshDepth = thresholdDepthImage(images.getDepth()); heartTracker.track(images.getColor(), threshDepth); breathTracker.track(images.getColor(), threshDepth); Rect forehead = getForeheadFromHead(heartTracker.getTrackedRegion()); Mat foreheadDepth = threshDepth(forehead); imageTimer.expires_at(imageTimer.expires_at() + boost::posix_time::milliseconds(imInterval)); imageTimer.async_wait(bind(&VitalsModel::processFrame, this)); }