ceres::CostFunction* cost_function = new ceres::NumericDiffCostFunction<func,ceres::CENTRAL, n_pts, 4>(new func(point));
Obviously func and point are propperly defined and their type match, n_pts is an integer. However, when I compile I get the following error:
the value of 'n_pts' is not usable in a constant expression ceres::CostFunction* cost_function = new ceres::NumericDiffCostFunction<func,ceres::CENTRAL, n_pts, 4>
note: 'n_pts' was not initialized with a constant expression int n_pts(10);
Any idea on how can I make the cos_function variable in size on runtime?
Thank you.
Cheers!
Hello,I have the following problem: I am trying to solve a non-linear least squares problem (problem 1) where the size of the residual block is not known at the compiling time.My cost function (the one used to solve problem 1) works on 3D points but, to be able to get the error, I need to solve a non-linear least squares problem (problem 2) within the operand() function.
For some of the 3D points this non-linear least squares problem is the same.
This means that I can either 1) add a residual block for each point and then solve problem 2 one time for each 3D point (although for some I already have it solved), or 2) make residuals bigger by grouping all the points that will use the same problem 2 and compute a residual for all the points with the same problem 2 at once.
I can do as in 1) and add a residual block for each 3D point, however, solving problem 2 is time-consuming. When I try to do it as in 2), I want to do something like:
ceres::CostFunction* cost_function = new ceres::NumericDiffCostFunction<func,ceres::CENTRAL, n_pts, 4>(new func(point));Obviously func and point are propperly defined and their type match, n_pts is an integer. However, when I compile I get the following error:
the value of 'n_pts' is not usable in a constant expression ceres::CostFunction* cost_function = new ceres::NumericDiffCostFunction<func,ceres::CENTRAL, n_pts, 4>
note: 'n_pts' was not initialized with a constant expression int n_pts(10);
Any idea on how can I make the cos_function variable in size on runtime?
Thank you.
Cheers!
--
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/5fac85d6-934c-428a-bcf1-456ca70d9784%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/5fac85d6-934c-428a-bcf1-456ca70d9784%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUBNL8q%3DGacpY336%2Bg3A_3b23DLFTBp-9mb2WTCmDCUACg%40mail.gmail.com.
Thank you Adita and Sameer for your reply. Addressing Sameer's questions:1- If I understand your problem, you have a two stage optimization, where the residual of one stage depends on the optimal value of the second optimization problem.Yes.2- I do not understand what you are trying to say here. Could you be more precise in your description.The solution of the second optimization is common to many observations (each observation is size 3 since it is a 3D point). To solve the first optimization, I could either 1) add a residual block of size 3 for each point,
or 2) add a residual block of size 3*n, beeing n the number of points that share the same second optimization. If I do the first, I wold end up solving the second optimization many times with the same initial values and the same final result. If I can do the second, I could compute the second optimization problem only once per group of points.
3- If you are worried about performance, why are you doing numerical differentiation?If you could point me to how to get the jacobian of the solution of an optimization problem I could change NumericDiffCostFunction (although that I've seen that if I want the number of residuals to not be known at compiling time I should use DynamicNumericDiffCostFunction) to CostFunction. However, I do not know how to make its size unknown at compiling time. Every time I've used CostFunction I already knew the residuals size.
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/5fac85d6-934c-428a-bcf1-456ca70d9784%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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/CABqdRUBNL8q%3DGacpY336%2Bg3A_3b23DLFTBp-9mb2WTCmDCUACg%40mail.gmail.com.
--
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/CAD3_OrWUfw-2GPXXW0NLHgzpio5y0LGmZ8bdpHnfaw8hy3KSnQ%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/5fac85d6-934c-428a-bcf1-456ca70d9784%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUBNL8q%3DGacpY336%2Bg3A_3b23DLFTBp-9mb2WTCmDCUACg%40mail.gmail.com.--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CAD3_OrWUfw-2GPXXW0NLHgzpio5y0LGmZ8bdpHnfaw8hy3KSnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUA8Mxq5qd2V5Bh3JnHYB3nYMraAVmcFdteCYaF_T-nLoA%40mail.gmail.com.