Exemplo n.º 1
0
void ofxRGBDCaptureGui::updateDepthImage(ofShortPixels& pixels){
    
    if(!pixels.isAllocated()){
        return;
    }
    
    int max_depth = depthImageProvider->maxDepth();    
    if(max_depth == 0){
    	max_depth = 5000;
    }
//    cout << "updating depth image with max depth of " << max_depth << " render: " << (currentRenderMode == RenderRainbow ? "rainbow" : "b&w") <<  endl;
    if(currentRenderMode == RenderRainbow){
        for(int i = 0; i < 640*480; i++){
            int lookup = pixels.getPixels()[i] / (max_depth / 256);
            //int lookup = ofMap( depthPixels.getPixels()[i], 0, max_depth, 0, 255, true);
            depthImage.getPixels()[(i*3)+0] = LUTR[lookup];
            depthImage.getPixels()[(i*3)+1] = LUTG[lookup];
            depthImage.getPixels()[(i*3)+2] = LUTB[lookup];
        }
    }
    else{
        recorder.compressorRef().convertTo8BitImage(pixels, depthImage);
    }
    
    depthImage.update();
	
}
Exemplo n.º 2
0
void ofxRGBDCaptureGui::drawPointcloud(ofShortPixels& pix, bool fullscreen){

	glEnable(GL_DEPTH_TEST);
	ofMesh mesh;
	ofRectangle rect = fullscreen ? ofRectangle(0,0, ofGetWidth(), ofGetHeight()) : previewRect;
    //glEnable(GL_POINT_SMOOTH);
    //glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB);	// allows per-point size
    glPointSize(2);
	for(int y = 0; y < 480; y++){
		for(int x = 0; x < 640; x++){
			//0.104200 ref dist 120.000000
			double ref_pix_size = 0.104200;
			double ref_distance = 120.000000;
			double wz = pix.getPixels()[y*640+x];
			double factor = 2 * ref_pix_size * wz / ref_distance;
			double wx = (double)(x - 640/2) * factor;
			double wy = (double)(y - 480/2) * factor;
            mesh.addVertex(ofVec3f(wx,-wy,-wz));
		}
	}
    
    cam.begin(rect);
	mesh.drawVertices();
	cam.end();
    
	glDisable(GL_DEPTH_TEST);	
}
Exemplo n.º 3
0
//----------------------------------------------------------
void ofTexture::readToPixels(ofShortPixels & pixels){
#ifndef TARGET_OPENGLES
	pixels.allocate(texData.width,texData.height,ofGetImageTypeFromGLType(texData.glTypeInternal));
	bind();
	glGetTexImage(texData.textureTarget,0,ofGetGlFormat(pixels),GL_UNSIGNED_SHORT,pixels.getPixels());
	unbind();
#endif
}
Exemplo n.º 4
0
void ofFbo::readToPixels(ofShortPixels & pixels, int attachmentPoint){
#ifndef TARGET_OPENGLES
	getTextureReference(attachmentPoint).readToPixels(pixels);
#else
	bind();
	int format,type;
	ofGetGlFormatAndType(settings.internalformat,format,type);
	glReadPixels(0,0,settings.width, settings.height, format, GL_UNSIGNED_SHORT, pixels.getPixels());
	unbind();
#endif
}
Exemplo n.º 5
0
void ofFbo::readToPixels(ofShortPixels & pixels, int attachmentPoint){
	if(!bIsAllocated) return;
#ifndef TARGET_OPENGLES
	getTextureReference(attachmentPoint).readToPixels(pixels);
#else
	pixels.allocate(settings.width,settings.height,ofGetImageTypeFromGLType(settings.internalformat));
	bind();
	int format = ofGetGLFormatFromInternal(settings.internalformat);
	glReadPixels(0,0,settings.width, settings.height, format, GL_UNSIGNED_SHORT, pixels.getPixels());
	unbind();
#endif
}
void ofxDepthImageCompressor::convertTo8BitImage(ofShortPixels& pix, ofImage& image){
	convertTo8BitImage(pix.getPixels(), image);
}
ofImage ofxDepthImageCompressor::convertTo8BitImage(ofShortPixels& pix, bool createTexture){
	return convertTo8BitImage(pix.getPixels(), createTexture);
}
void ofxDepthImageCompressor::readCompressedPng(string filename, ofShortPixels& pix){
	if(!pix.isAllocated()){
		pix.allocate(640, 480, 1);
	}
	readCompressedPng(filename, pix.getPixels());
}
Exemplo n.º 9
0
//----------------------------------------------------------
void ofTexture::loadData(const ofShortPixels & pix, int glFormat){
	ofSetPixelStorei(pix.getWidth(),pix.getBytesPerChannel(),ofGetNumChannelsFromGLFormat(glFormat));
	loadData(pix.getPixels(), pix.getWidth(), pix.getHeight(), glFormat, ofGetGlType(pix));
}
Exemplo n.º 10
0
//----------------------------------------------------------
void ofTexture::loadData(const ofShortPixels & pix){
	ofSetPixelStorei(pix.getBytesStride());
	loadData(pix.getPixels(), pix.getWidth(), pix.getHeight(), ofGetGlFormat(pix), ofGetGlType(pix));
}
Exemplo n.º 11
0
bool ofxDepthImageRecorder::addImage(ofShortPixels& image){
	return addImage(image.getPixels());
}
Exemplo n.º 12
0
//----------------------------------------------------------
void ofTexture::loadData(const ofShortPixels & pix){
	loadData(pix.getPixels(), pix.getWidth(), pix.getHeight(), ofGetGlFormat(pix));
}