Ask Your Question
1

How can I represent point cloud in Voxel opencv?

asked 2013-03-27 01:09:08 -0600

Nihad gravatar image

I am working with point cloud. The following data are from my coordinate file. There are eight coordinates, and each coordinate is represented by position vector x,y,z. How can I represent this point cloud in Voxel opencv?

0.270598 0.254439 0.471311
0.270598 0.254439 0.518814
0.270598 0.282268 0.518814
0.270598 0.282268 0.471311
0.396951 0.254439 0.471311
0.396951 0.282268 0.471311
0.396951 0.282268 0.518814
0.396951 0.254439 0.518814
edit retag flag offensive close merge delete

Comments

Hi! What are you really need? Do you want to put this data in Mat or what?

Daniil Osokin gravatar imageDaniil Osokin ( 2013-03-27 07:51:40 -0600 )edit

Yes, I want to store it in Mat, and access from Mat.

Nihad gravatar imageNihad ( 2013-03-27 20:16:51 -0600 )edit

Hi Nihad. can u send full code?

hakanozturk gravatar imagehakanozturk ( 2017-05-09 17:44:06 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2013-03-27 09:56:55 -0600

berak gravatar image

updated 2013-03-27 10:13:54 -0600

  1. please have a look at the pointcloud library .
  2. you could save your points as an ascii file, and view it with a plain 3d viewer, meshlab, blender, etc.

  3. check, if your opencv libraries were build with opengl support:

    cout << cv::getBuildInformation() << endl;

if so, you can use opengl commands to draw your 3d points:

#include <opencv2/opencv.hpp>

// shame, needs windows.h on win, else problem with APIENTRY
//#include <windows.h>   
#include <GL/gl.h>

using namespace std;
using namespace cv;

float pts[8*3] = {
    0.270598,0.254439,0.471311,
    0.270598,0.254439,0.518814,
    0.270598,0.282268,0.518814,
    0.270598,0.282268,0.471311,
    0.396951,0.254439,0.471311,
    0.396951,0.282268,0.471311,
    0.396951,0.282268,0.518814,
    0.396951,0.254439,0.518814
};

void on_opengl(void* param)
{
    glLoadIdentity();
    glPointSize(3);
    glBegin(GL_POINTS);
    for ( int i=0; i<8; i++ )
    {
        glColor3ub( i*20, 100+i*10, i*42 );
        glVertex3fv(&pts[i*3]);
    }
    glEnd();
}

int main(int argc, char *argv[]) 
{
    namedWindow("3d",CV_WINDOW_OPENGL|CV_WINDOW_NORMAL);
    setOpenGlDrawCallback("3d",on_opengl,0);
    waitKey(0);
    return 0;
}
edit flag offensive delete link more

Comments

Thank you for try. I don`t use OpenGL. Actually I want to store it in voxel grid/mat, access data from grid/mat.

Nihad gravatar imageNihad ( 2013-03-27 20:38:35 -0600 )edit
1

answered 2013-03-28 02:02:19 -0600

Daniil Osokin gravatar image

You can try this:


float pts[rows*dim] = {
    0.270598,0.254439,0.471311,
    0.270598,0.254439,0.518814,
    0.270598,0.282268,0.518814,
    0.270598,0.282268,0.471311,
    0.396951,0.254439,0.471311,
    0.396951,0.282268,0.471311,
    0.396951,0.282268,0.518814,
    0.396951,0.254439,0.518814
};

Mat points(rows, 1, CV_32FC3, pts);

Also, may be this would be useful: Working with pixels.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-03-27 01:09:08 -0600

Seen: 5,016 times

Last updated: May 09 '17