Exemplo n.º 1
0
TextureObjChunk* SimpleFBO::depthTexObj() const
{
    TextureBuffer* texBuf = dynamic_cast<TextureBuffer*>(depthBuffer());
    if (texBuf)
        return texBuf->getTexture();

    return nullptr;
}
Exemplo n.º 2
0
Texture::Visualization::Visualization(const Any& a) {
    *this = Visualization();
    if (a.type() == Any::ARRAY) {
        if (a.nameEquals("bumpInAlpha")) {
            *this = bumpInAlpha();
        } else if (a.nameEquals("defaults")) {
            *this = defaults();
        } else if (a.nameEquals("linearRGB")) {
            *this = linearRGB();
        } else if (a.nameEquals("depthBuffer")) {
            *this = depthBuffer();
        } else if (a.nameEquals("packedUnitVector")) {
            *this = packedUnitVector();
        } else if (a.nameEquals("radiance")) {
            *this = radiance();
        } else if (a.nameEquals("reflectivity")) {
            *this = reflectivity();
        } else if (a.nameEquals("sRGB")) {
            *this = sRGB();
        } else if (a.nameEquals("unitVector")) {
            *this = unitVector();
        } else {
            a.verify(false, "Unrecognized Visualization factory method");
        }
    } else {
        a.verifyName("Texture::Visualization", "Visualization");

        AnyTableReader r(a);
        String c;

        if (r.getIfPresent("channels", c)) {
            channels = toChannels(c);
        }

        r.getIfPresent("documentGamma", documentGamma);
        r.getIfPresent("invertIntensity", invertIntensity);
        r.getIfPresent("max", max);
        r.getIfPresent("min", min);
        r.getIfPresent("layer", layer);
        r.getIfPresent("mipLevel", mipLevel);

        r.verifyDone();
    }
}
Exemplo n.º 3
0
void DepthBuffer::renderMeshGL()
{
    uint W = _pCamera->W();
    uint H = _pCamera->H();
    ncv::GlXOffscreenContextPtr context(new ncv::GlXOffscreenContext(W, H));

    context->makeActive();
    // Should be able to use openGL here..

    glViewport(0,0,W,H);
    glDisable(GL_LIGHTING);

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glLoadMatrix(_pCamera->getProjectionMatrix(_zMin, _zMax));

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glLoadMatrix(_pCamera->getModelViewMatrix());

    glEnable(GL_DEPTH_TEST);

    glClearDepth(1.0f);
    glDepthFunc(GL_LEQUAL);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Draw mesh..
    drawMeshGL();

    glFlush();

    double P[16];
    glGetDoublev(GL_PROJECTION_MATRIX, P);
    
    float a = - Map<Matrix4d>(P)(2,2);
    float b = - Map<Matrix4d>(P)(2,3);
    
    MatrixXfRow depthBuffer(H,W);
    MatrixXfRow depthBufferReverse(H,W);
    //    MatrixXfRow depthBufferReverseTest(H,W);
    glReadPixels(0, 0, W, H, GL_DEPTH_COMPONENT, GL_FLOAT, depthBuffer.data());
    depthBufferReverse = depthBuffer.colwise().reverse();
    
    for_each(depthBufferReverse.data(), depthBufferReverse.data() + W*H, DepthConverter(a,b));
    _depthBufferMin = depthBufferReverse;

    // output depth data to txt file
    // std::ofstream depthBufferFile;
    // depthBufferFile.open("/cs/research/vision/humanis3/Rui/data/newsequence_3_19/photo_metric/depthBuffer.txt",
    //     std::ofstream::trunc);
    // depthBufferFile << _depthBufferMin << endl;

    // // render again to get the maximum depth
    // glClearDepth(0.0f);
    // glDepthFunc(GL_GEQUAL);
    // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // drawMeshGL();

    // glFlush();

    // glReadPixels(0, 0, W, H, GL_DEPTH_COMPONENT, GL_FLOAT, depthBuffer.data());
    // depthBufferReverse = depthBuffer.colwise().reverse();
    // for_each(depthBufferReverse.data(), depthBufferReverse.data() + W*H, DepthConverter(a,b));
    // _depthBufferMax = depthBufferReverse;
    
}