Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Never determined the real issue, but the following works as expected:

while( isRunning() && !myWindow.wasStopped() )
{   
    points3DFrame = points3DBuffer.waitNewFrame( lastFrameTime );
    lastFrameTime = points3DFrame->timestamp;

    cv::Vec3f* ptsPtr = std::const_pointer_cast<Points3DFrame>(points3DFrame)->points.ptr<cv::Vec3f>();

    int index = 0;
    for( int i = 0; i < height; ++i ) {         
        for( int j = 0; j < width; ++j, ++index ) {         
            if( ptsPtr[index][2] > 0.01 && ptsPtr[index][2] < 255 ) {
                pCloudPtr[index] = ptsPtr[index];
            } else {
                pCloudPtr[index] = cv::Vec3f();
            }
        }
    }

    cv::viz::WCloud cloud_widget = cv::viz::WCloud( pCloud, cv::viz::Color::green() );
    cloud_widget.setRenderingProperty( cv::viz::POINT_SIZE, 2 );

    myWindow.showWidget( "Depth", cloud_widget );

    myWindow.spinOnce( 30, true );
}

As you can see, I'm removing those points that I know are likely to be invalid ( negative depth or depth beyond 2.5 meters ).