gabyx / ApproxMVBB

Fast algorithms to compute an approximation of the minimal volume oriented bounding box of a point cloud in 3D.
Mozilla Public License 2.0
441 stars 93 forks source link

Stable min/max points ? #34

Closed federicatrozzi closed 4 years ago

federicatrozzi commented 5 years ago

Hi gabyx, first of all thanks for your amazing work about this libraries :) . For second: i'm trying to compile your libraries for windows using vs2017 but i have a lot of compiling errors that i think are due to the compiler but i don't know how to manage it. Can you help me?

i have attached logs both from cmake-gui and from vs2017, i'm using windows 10 64bit.

The most important i think is "error MSB6006: "CL.exe" exited with code 2."

Thank you for you reply

Federica

gabyx commented 4 years ago

First of all thanks fot the note. I have never tried to compile is yet under MSVC. I should do this once. But my support is limited. Help is very welcome, basically it should be enought std compliant that it should work.

First: Dont post Logs from your machine with all path and such. Obfuscate them! Second: Could you provide a Log in English :-)??

federicatrozzi commented 4 years ago

Hi gabyx! What a pleasure to read you :) i have a demo on the next friday so in these days i'm spending time on this repo more than spending it with my friends and my social life XD.

Anyway: there are a lot of updates since my last post:

-i found out that using MSVC17 + the platform toolset v140 (visual studio 2015) in Debug mode for x64 ApproxMVBB.sln compiles correctly, generating dlls+lib+pdb , the same for ApproxMVBBExample.sln

-i tried to compile the remaining solutions such tests but nothing compiles with this configuration (i can provide english logs of corse if you want :)

Now using your libraries i have very strange result. Let me explain better: i need to measure dimensions of the bounding box surrounding a parcel and then i need to draw the box with opengl. Using this code:

    coord_min=oobb.m_minPoint.transpose(); 
    coord_max=oobb.m_maxPoint.transpose();

    dimx = coord_max .x - coord_min .x;
    dimy = coord_max .y - coord_min .y;
    dimz = coord_max .z - coord_min .z;

i'm able to find coordinates of the minimum and the maximum point in the world reference frame K of the OBB(as you explained in the dscription) but i don't know why coordinates rotates! x components switch with y and z and so on! For example in the first frame dimx=56, dimy=10, dimz=30 and in the second frame randomly dimx=30,dimy=56,dimz=10.

That is annoying because i can't measure height width and length. How can i manage it?

Thank you :)

Federica

gabyx commented 4 years ago

I think you have some trouble with coordinate systems. The members min/max of the result box oobb are represented in the local coordinate system (that the box coordinate system, K)

You can do oobb.extent() (see here) to get the extent of the box in each direction of the basis vectors of the coordinate system K of the OOBB (this Box can be rotated its not generally aligned with the world system I) . The world reference frame is denoted always with I. (its not K!!).

The min/max points in the world reference frame are:

auto I_min = oobb.m_q_KI * oobb.m_minPoint         // I_min = A_IK * K_min (1)
auto I_max = oobb.m_q_KI * oobb.m_maxPoint        // I_max = A_IK * K_max

oobb.m_q_KI is the quaternion of a rotation matrix R_KI which is exactly equivalent to a coordinate transformation A_IK which transforms coordinate tuples in coordinate system K to the world system I as in (1) above.

federicatrozzi commented 4 years ago

Ok, thank you for the reply! But my issue is still there also using obb.extent() method.

components of the resultant extent vector are: first frame array=0x000000fbd16fe3c8 {0.15221579966246129, 0.023088804776168370, 0.15327768399314351} another frame: array = 0x000000fbd16fe3c8 {0.15468049461822514, 0.15562215447225061, 0.023117925343654311}

the cloud is not moving but it seems that system reference is rotating, but i don't do any kind of rotation. Do you mean this when you wrote me " (this Box can be rotated its not generally aligned with the world system I) ."? If yes how can i know which are height width and length of the box?

gabyx commented 4 years ago

Ah ok, understood. The thing is the algorithm is not deterministic. Since it uses random sampling and such. Meaning the output can be different from run to run. But hopefully a close enough MVBB, thats all it does. So the coordinate system is flipped. Why do you need exactly this dimensions? The box is fully defined by the OOBB class in world space.

federicatrozzi commented 4 years ago

I tryed also this kindo of workaround but no good results obtained.

` auto coord_min = oobb.m_q_KI oobb.m_minPoint; auto coord_max = oobb.m_q_KI oobb.m_maxPoint;

float* truemin_val_x; float* truemin_val_y; float* truemin_val_z;
float* truemax_val_x; float* truemax_val_y; float* truemax_val_z;

float x_vals[]{ coord_min.x() ,coord_max.x() };
float y_vals[]{ coord_min.y() ,coord_max.y() };
float z_vals[]{ coord_min.z() ,coord_max.z() };
truemin_val_x = min_element(begin(x_vals), end(x_vals));
truemax_val_x = max_element(begin(x_vals), end(x_vals));
truemin_val_y = min_element(begin(y_vals), end(y_vals));
truemax_val_y = max_element(begin(y_vals), end(y_vals));
truemin_val_z = min_element(begin(z_vals), end(z_vals));
truemax_val_z = max_element(begin(z_vals), end(z_vals));

min_pt.x = *truemin_val_x;
min_pt.y = *truemin_val_y;
min_pt.z = *truemin_val_z;
max_pt.x = *truemax_val_x;
max_pt.y = *truemax_val_y;
max_pt.z = *truemax_val_z;`

I need stable coordinates of max and min 3d points of the box, because in my project there is another sw that asks me variables containing height width and length informations and must not be switched between themselves.

gabyx commented 4 years ago

Ok, since the computation is randomized, you probably need functionality to set the seed or something of the random algorithm. So for a given input set of point clouds-> for each point cloud you need to reset the seed to some value, to probably get more deterministic output. so far this functionality is not implemented, but this funtionality is probably not solving your problem:

I am really questioning what your goal is. You say you have another software which needs height,width length information, but that is not enough to describe a object oriented bounding box. What expects your other software and where is the coordinate system information ( is it an axis aligned bounding box??)

gabyx commented 4 years ago

So meaning, with only height width and length informations for your other software , I unfortunately dont see anykind of workaround which makes sense. Maybe you can describe a little bit better what you want to achieve? Whats the name of that software?

gabyx commented 4 years ago

Ok, I see the seed is already implemented :-) : https://github.com/gabyx/ApproxMVBB/blob/471b5211e2aee99bf50049f67b3f37b5fb118c20/include/ApproxMVBB/ComputeApproxMVBB.hpp#L412 And it uses already a default seed for each run... so the problem is not solved by doing this... obvisouly...

gabyx commented 4 years ago

Reopen if you need.