title: OpenCV::LMSolver getting a simple example to run
body: <p><strong>PROBLEM</strong>: The documentation for <code>cv::LMSolver</code> at <a href="https://docs.opencv.org/4.x/d3/d6d/classcv_1_1LMSolver.html" rel="nofollow noreferrer">opencv.org</a> is very thin, to say the least. Finding some useful examples on the internet, also, was not possible.</p>
  <p><strong>APPROACH</strong>: So, I did write some simple code:</p>
  <pre><code>#include &lt;opencv2/calib3d.hpp&gt;
  #include &lt;iostream&gt;
  
  using namespace cv;
  using namespace std;
  
  struct Easy : public LMSolver::Callback {
     Easy() = default;
  
     virtual bool compute(InputArray f_param, OutputArray f_error, OutputArray f_jacobian) const override
     { 
          Mat  param = f_param.getMat();
  
          if( f_error.empty() ) f_error.create(1, 1, CV_64F);             // dim(error) = 1
          Mat  error = f_error.getMat();                          
  
          vector&lt;double&gt; x{param.at&lt;double&gt;(0,0), param.at&lt;double&gt;(1,0)}; // dim(param) = 2
          double         error0 = calc(x);
          error.at&lt;double&gt;(0,0) = error0;
  
          if( ! f_jacobian.needed() ) return true; 
          else if( f_jacobian.empty() ) f_jacobian.create(1, 2, CV_64F); 
          Mat  jacobian = f_jacobian.getMat();
  
          double e = 1e-10; // estimate derivatives in epsilon environment       
          jacobian.at&lt;double&gt;(0, 0) = (calc({x[0] + e, x[1]    }) - error0) / e; // d/dx0 (error)
          jacobian.at&lt;double&gt;(0, 1) = (calc({x[0],     x[1] + e}) - error0) / e; // d/dx1 (error)
          return true;
     }
  
     double calc(const vector&lt;double&gt; x) const { return x[0]*x[0] + x[1]*x[1]; }
  };
  
  int main(int argc, char** argv) 
  {
      Ptr&lt;Easy&gt;      callback   = makePtr&lt;Easy&gt;();
      Ptr&lt;LMSolver&gt;  solver     = LMSolver::create(callback, 100000, 1e-37);
      Mat            parameters = (Mat_&lt;double&gt;(2,1) &lt;&lt; 5, 100);
      solver-&gt;run(parameters);
      cout &lt;&lt; parameters &lt;&lt; endl;
  }
  </code></pre>
  <p><strong>QUESTIONS</strong>:</p>
  <ul>
  <li>What does the return value of <code>LMSolver::Callback::compute()</code> report to the caller?</li>
  <li>Currently, it finds the minimum at (-9e-07,4e-5), instead of the expected (0.0, 0.0). How can the precision be improved?</li>
  </ul>