Пример #1
0
void KinectMotion::setup(float _depthInW, float _depthInH, ofxFastFboReader & _fastFboReader)
{
    depthInW = _depthInW;
    depthInH = _depthInH;
	fastFboReader = &_fastFboReader;
    
    loadShaders();
    
    isDrawSlices = true;
    isDrawSliceImages = true;
    isDrawSliceContours = true;
    isDrawResampledPolylines = true;
    isDrawResampledPolylinePoints = true;
    isDrawResamplesPolylineInfo = true;
    isDrawMotionSmoothedPolylines = true;
    isDrawMotionSmoothedPolylinePoints = true;
    isDrawSmoothedPolylineBoundingBox = true;
    
    buildSlices();
    
    ofFbo::Settings settings;
    settings.width = depthInW * 0.25;
    settings.height = depthInH * 0.25;
    settings.internalformat = GL_RGB;
    depthMotionFbo.allocate(settings);
    
	//ofPixels pixxx;
	//depthMotionFbo.readToPixels(pixxx);	
	//imitate(previousDepthMap, pixxx);
	//imitate(differenceImage, pixxx);

	isUpdateSlices = false;
}
Пример #2
0
	MRI(char const *inputFileName, VolumeType::SpacingType spacing, VolumeType::SizeType size, double initialResizeFactor):
	  resamplerSpacing(spacing),
	  resamplerSize(size) {
		readFile(inputFileName);
		rescaleIntensity();
		resizeImage(initialResizeFactor);
		buildOriginalMaskVolume();
    initialiseFilters();
    buildSlices();
    buildMaskSlices();
	}
Пример #3
0
void KinectMotion::update(ofTexture & depthTex, bool isUpsideDown)
{
	if (isUpdateSlices)
	{
		isUpdateSlices = false;
		buildSlices();
	}
    
	depthSmallFbo.begin();
    ofPushMatrix();
	if (isUpsideDown)
	{
		ofTranslate(0, depthSmallFbo.getHeight());
		ofScale(1, -1);
	}
	else
	{
		ofTranslate(depthSmallFbo.getWidth(), 0);
		ofScale(-1, 1);
	}
    depthTex.draw(0, 0, depthSmallFbo.getWidth(), depthSmallFbo.getHeight());
    ofPopMatrix();
    depthSmallFbo.end();
    
    
    if (depthSlices.size() == 0) return;
    
	if (ofGetFrameNum() % 10 == 0)
	{
		int nearest = ofClamp(nearestGrey + 30, 120, 255);
		if (depthSlices[0].maxThreshold == -1 || abs(nearest - depthSlices[0].maxThreshold) > 30)
		{
			for (int i = 0; i < depthSlices.size(); i++)
			{
				float thresholdSection = nearest / depthSlices.size();
        
				// set the threshold of the depth slices - this limits the range e.g. 10 slices only tracking from 1m-4m - 30 cms per slice
				//int minThreshold = ofMap(255 - (i * thresholdSection + thresholdSection), 0, 255, sliceMinThreshold, sliceMaxThreshold);
				//int maxThreshold = ofMap(255 - (i * thresholdSection), 0, 255, sliceMinThreshold, sliceMaxThreshold);
			
				int minThreshold = nearest - (i * thresholdSection + thresholdSection);
				int maxThreshold = nearest - (i * thresholdSection);

				depthSlices[i].minThreshold = minThreshold;
				depthSlices[i].maxThreshold = maxThreshold;
			}
		}
	}
    
	
    for (int i = 0; i < depthSlices.size(); i++)
    {
        depthSlices[i].update(&depthSmallFbo.getTextureReference());
    }
    
    
//    for (int i = 0; i < 600; i += 3)
//    {
//        //ofVec3f v = ofVec3f(1.0, 1.0, 0.0);
//        ofVec3f v = ofVec3f(ofRandomuf(), ofRandomuf(), ofRandomuf());
//        //ofVec3f v = ofVec3f(ofRandom(255), ofRandom(255), ofRandom(255));
//        
//        motionData[i] = v.x;
//        motionData[i+1] = v.y;
//        motionData[i+2] = v.z;
//    }
    
//    depthMotionFbo.begin();
//    ofClear(1.0, 1.0, 1.0, 1.0);
//    depthMotionShader.begin();
//    depthMotionShader.setUniform1fv("motionData", motionData, 600);
//    depthTex.draw(0, 0, depthInW * 0.5, depthInH * 0.5);
//    depthMotionShader.end();
//    depthMotionFbo.end();

	
	// frame differencing
	//depthMotionFbo.begin();
 //   ofClear(1.0, 1.0, 1.0, 1.0);
	//depthTex.draw(0, 0, depthMotionFbo.getWidth(), depthMotionFbo.getHeight());
 //   depthMotionFbo.end();
	//depthMotionFbo.readToPixels(depthMotionPix);
	//absdiff(previousDepthMap, depthMotionPix, differenceImage);
	//differenceImage.update();
	//copy(depthMotionPix, previousDepthMap);
	//differenceMean = mean(toCv(differenceImage));
}
Пример #4
0
	void SetTransformParameters(TransformType::Pointer inputTransform) {
    transform->SetParameters( inputTransform->GetParameters() );
    transform->SetFixedParameters( inputTransform->GetFixedParameters() );
    buildSlices();
    buildMaskSlices();
	}