--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/e57da29b-e68f-42b9-9b45-4137324d129b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Eric,The problem you describe should be solvable with Ceres. Do you have recent code to show what you are attempting? I am not sure what you mean by this statement: "the parameters in each cost function are not communicating with each other". Generally Ceres handles this case properly. My interpretation of the problem from the SO post is as follows:Minimize the difference between a given set of surface normals and the normals from a meshOptimizing over the Z-coordinate of the meshThe mesh starts as a flat patchThis raises a key question: How do you determine the surface normal of a mesh? There are many ways to do it- you could take a 1-neighborhood around each normal sample and fit a plane to the z-heights, then take the normal to the plane. You could do a sophisticated quadratic fit to any number of surrounding points, then take the tangent of the quadratic.With that said, here is how I would try to solve the problem:For each normal sample where we have a parameter (assume interior for now)Create a cost function taking 9 parameters - the current sample & neighborsFor each neighbor iterating *around* the center, compute a surface normal formed by the neighbor, the current sample, and the previous neighbor - store itAverage the 9 surface normals to get a normal estimate for the current pointSubtract the computed normal from the expected normal to form a 3-dimensional residualThis means you will have to create 5 cost functions implementations - one for each top/bottom/left/right/interior - due to the structure of Ceres' autodiff cost function. Hopefully you can reuse the normal computation code by factoring it out.Alternately, you could do something sneaky like create a 1-width border around your mesh, then set the border parameters to constant with Ceres. You could then use the interior-only cost function everywhere. That would save you the hassle of making 5 implementations at a minor increase to computation cost (since Ceres is smart about handling fixed parameters).
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/4a69f88e-5d3f-483c-aad0-d8ab1edebd75%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/0a90c5ab-6d60-46d6-8307-ee34c1f3b251%40googlegroups.com.
Hi,
Thanks for your advice, everyone! Real quick, how do I do this?
double* z_me = ... get mutable pointer to appropriate z value ...;
Would something like this work?
double* temp = new double[3];
temp = mesh.vertex(m);
double* z_me = temp;
Where inside the Mesh class...
double** X_; // Vertex coordinates [NV x 3]
...
double* vertex(int m) { return X_[m]; }
Additionally, is it possible to just create an array of mutable z coordinates (e.g., Z), which would allow me to replace (1) with (2)?
(1) problem.AddResidualBlock(new MyCostFunction(new MyCostFunctor), NULL, {z_me, z_nw, z_n, ...});
(2) problem.AddResidualBlock(new MyCostFunction(new MyCostFunctor), NULL, Z);
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/12d0fa9f-f126-45c0-b9c5-da0c9d2809cb%40googlegroups.com.
Thanks for the tip on the mutable coords.
"Do you mean something like having a single Z array containing (usually) 9 values? No, that's not possible - basically you've shattered your grid into a bunch of independent points. How can Ceres know that cost function A's third Z value is the same value (height as the same grid point) as cost function B's seventh?"
What if Z is an array of pointers to different points in the mesh? Wouldn't Ceres be able to function correctly as long as each cost function was given the correct memory addresses to the data? It is not necessary to separate them into different variables in the cost function call and declaration, right?
"You can use one of the "Dynamic" flavours of cost functions so that sometimes you pass in a 9-vector of Z pointers, sometimes a 6-vector, sometimes a 4-vector. But your cost function internally needs to know whether it's an interior, edge, or corner point (and which edge/corner it's on) so that it can properly use the values Ceres hands it."
Given that the connectivity pattern is uniform throughout the mesh, can we give the Dynamic cost function pointers to the mesh points in the same order every time (e.g., CW or CCW), and then just tell the cost function to iterate in one direction through the array? That seems like it would work without having to specify the different cases (4 corners, 4 edges, 1 interior).
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/a8a8a5e8-c754-4f87-9aa1-f30976d8d363%40googlegroups.com.
Solver log please
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/33c9f447-5403-4faa-af0d-a1eb6542dca7%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/35278cc7-96af-4687-8c0f-8087010871ca%40googlegroups.com.
...
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/7afeb664-bcee-4482-848a-895fd4ffe9fb%40googlegroups.com.
...