Consult the module API page at
https://engineering.purdue.edu/kak/distNonlinearLeastSquares/NonlinearLeastSquares-2.0.2.html
for all information related to this module, including
information regarding the latest changes to the code. The
page at the URL shown above lists all of the module
functionality you can invoke in your own code.
With regard to the basic purpose of this module, it provides
a domain agnostic implementation of nonlinear least-squares
algorithms (gradient-descent and Levenberg-Marquardt) for
fitting a model to observed data. Typically, a model
involves several parameters and each observed data element
can be expressed as a function of those parameters plus
noise. The goal of nonlinear least-squares is to estimate
the best values for the parameters given all of the observed
data. In order to illustrate how to use the
NonlinearLeastSquares class, the module also comes with two
additional classes: **OptimizedSurfaceFit** and
**ProjectiveCamera.**
The job of **OptimizedSurfaceFit** is to fit the best surface to noisy
height data over an XY-plane. The model in this case would
be an analytical expression for the height surface and the
goal of nonlinear least-squares would be to estimate the
best values for the parameters in the model.
And the job of **ProjectiveCamera** is to demonstrate how
nonlinear least-squares can be used for estimating scene
structure from camera motion. The underlying ideas is that
you take multiple images of a scene with a camera ---
something that you can simulate with **ProjectiveCamera**.
You feed the pixels thus recorded into the
NonlinearLeastSquares class to estimate the coordinates of
the scene structure points and, when using uncalibrated
cameras, to also estimate the extrinsic parameters of the
camera at each of its positions.
Starting with Version 2.0.0, the module includes code for
the sparse-bundle-adjustment variant of the
Levenberg-Marquardt algorithm.
Typical usage syntax for invoking the domain-agnostic
NonlinearLeastSquares through your own domain-specific class
such as OptimizedSurfaceFit or ProjectiveCamera is shown below:
::
optimizer = NonlinearLeastSquares(
max_iterations = 200,
delta_for_jacobian = 0.000001,
delta_for_step_size = 0.0001,
)
surface_fitter = OptimizedSurfaceFit(
gen_data_synthetically = True,
datagen_functional = "7.8*(x - 0.5)**4 + 2.2*(y - 0.5)**2",
data_dimensions = (16,16),
how_much_noise_for_synthetic_data = 0.3,
model_functional = "a*(x-b)**4 + c*(y-d)**2",
initial_param_values = {'a':2.0, 'b':0.4, 'c':0.8, 'd':0.4},
display_needed = True,
debug = True,
)
surface_fitter.set_constructor_options_for_optimizer(optimizer)
result = surface_fitter.calculate_best_fitting_surface('lm')
or
result = surface_fitter.calculate_best_fitting_surface('gd')
OR
optimizer = NonlinearLeastSquares.NonlinearLeastSquares(
max_iterations = 400,
delta_for_jacobian = 0.000001,
delta_for_step_size = 0.0001,
)
camera = ProjectiveCamera.ProjectiveCamera(
camera_type = 'projective',
alpha_x = 1000.0,
alpha_y = 1000.0,
x0 = 300.0,
y0 = 250.0,
)
camera.initialize()
world_points = camera.make_world_points_for_triangle()
world_points_xformed = camera.apply_transformation_to_generic_world_points(world_points, ..... )
## Now move the camera to different positions and orientations and then
result = camera.get_scene_structure_from_camera_motion('lm')
OR
result = camera.get_scene_structure_from_camera_motion_with_bundle_adjustment()
Raw data
{
"_id": null,
"home_page": "https://engineering.purdue.edu/kak/distNonlinearLeastSquares/NonlinearLeastSquares-2.0.2.html",
"name": "NonlinearLeastSquares",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "gradient descent",
"author": "Avinash Kak",
"author_email": "kak@purdue.edu",
"download_url": "https://files.pythonhosted.org/packages/40/9f/0541af0c9292cb0d34a0a4adc7e0e6d19962a61d74ad6b01c2374396fcbb/NonlinearLeastSquares-2.0.2.tar.gz",
"platform": "All platforms",
"description": " \n\nConsult the module API page at \n\n https://engineering.purdue.edu/kak/distNonlinearLeastSquares/NonlinearLeastSquares-2.0.2.html\n\nfor all information related to this module, including\ninformation regarding the latest changes to the code. The\npage at the URL shown above lists all of the module\nfunctionality you can invoke in your own code. \n\nWith regard to the basic purpose of this module, it provides\na domain agnostic implementation of nonlinear least-squares\nalgorithms (gradient-descent and Levenberg-Marquardt) for\nfitting a model to observed data. Typically, a model\ninvolves several parameters and each observed data element\ncan be expressed as a function of those parameters plus\nnoise. The goal of nonlinear least-squares is to estimate\nthe best values for the parameters given all of the observed\ndata. In order to illustrate how to use the\nNonlinearLeastSquares class, the module also comes with two\nadditional classes: **OptimizedSurfaceFit** and\n**ProjectiveCamera.** \n\nThe job of **OptimizedSurfaceFit** is to fit the best surface to noisy\nheight data over an XY-plane. The model in this case would\nbe an analytical expression for the height surface and the\ngoal of nonlinear least-squares would be to estimate the\nbest values for the parameters in the model. \n\nAnd the job of **ProjectiveCamera** is to demonstrate how\nnonlinear least-squares can be used for estimating scene\nstructure from camera motion. The underlying ideas is that\nyou take multiple images of a scene with a camera ---\nsomething that you can simulate with **ProjectiveCamera**.\nYou feed the pixels thus recorded into the\nNonlinearLeastSquares class to estimate the coordinates of\nthe scene structure points and, when using uncalibrated\ncameras, to also estimate the extrinsic parameters of the\ncamera at each of its positions.\n\nStarting with Version 2.0.0, the module includes code for\nthe sparse-bundle-adjustment variant of the\nLevenberg-Marquardt algorithm.\n\nTypical usage syntax for invoking the domain-agnostic\nNonlinearLeastSquares through your own domain-specific class\nsuch as OptimizedSurfaceFit or ProjectiveCamera is shown below:\n\n::\n\n optimizer = NonlinearLeastSquares( \n max_iterations = 200,\n delta_for_jacobian = 0.000001,\n delta_for_step_size = 0.0001,\n )\n \n surface_fitter = OptimizedSurfaceFit( \n gen_data_synthetically = True,\n datagen_functional = \"7.8*(x - 0.5)**4 + 2.2*(y - 0.5)**2\",\n data_dimensions = (16,16), \n how_much_noise_for_synthetic_data = 0.3, \n model_functional = \"a*(x-b)**4 + c*(y-d)**2\",\n initial_param_values = {'a':2.0, 'b':0.4, 'c':0.8, 'd':0.4},\n display_needed = True,\n debug = True,\n )\n\n surface_fitter.set_constructor_options_for_optimizer(optimizer) \n\n result = surface_fitter.calculate_best_fitting_surface('lm') \n or \n result = surface_fitter.calculate_best_fitting_surface('gd') \n\n\n OR\n\n\n optimizer = NonlinearLeastSquares.NonlinearLeastSquares(\n max_iterations = 400,\n delta_for_jacobian = 0.000001,\n delta_for_step_size = 0.0001,\n )\n \n camera = ProjectiveCamera.ProjectiveCamera(\n camera_type = 'projective',\n alpha_x = 1000.0,\n alpha_y = 1000.0,\n x0 = 300.0,\n y0 = 250.0,\n )\n camera.initialize()\n\n world_points = camera.make_world_points_for_triangle()\n world_points_xformed = camera.apply_transformation_to_generic_world_points(world_points, ..... )\n\n ## Now move the camera to different positions and orientations and then\n\n result = camera.get_scene_structure_from_camera_motion('lm')\n\n OR\n\n result = camera.get_scene_structure_from_camera_motion_with_bundle_adjustment()\n\n ",
"bugtrack_url": null,
"license": "Python Software Foundation License",
"summary": "A Python module for solving optimization problems with nonlinear least-squares",
"version": "2.0.2",
"project_urls": {
"Download": "https://engineering.purdue.edu/kak/distNonlinearLeastSquares/NonlinearLeastSquares-2.0.2.tar.gz",
"Homepage": "https://engineering.purdue.edu/kak/distNonlinearLeastSquares/NonlinearLeastSquares-2.0.2.html"
},
"split_keywords": [
"gradient",
"descent"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "409f0541af0c9292cb0d34a0a4adc7e0e6d19962a61d74ad6b01c2374396fcbb",
"md5": "0c2c05d0fda62e7ce2e0383696570a57",
"sha256": "c69b8c38adfc3e94178f2f7e82395e910c392366b2e3eb9f06516f09a13ed968"
},
"downloads": -1,
"filename": "NonlinearLeastSquares-2.0.2.tar.gz",
"has_sig": false,
"md5_digest": "0c2c05d0fda62e7ce2e0383696570a57",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 127082,
"upload_time": "2023-06-14T05:54:33",
"upload_time_iso_8601": "2023-06-14T05:54:33.562567Z",
"url": "https://files.pythonhosted.org/packages/40/9f/0541af0c9292cb0d34a0a4adc7e0e6d19962a61d74ad6b01c2374396fcbb/NonlinearLeastSquares-2.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-14 05:54:33",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "nonlinearleastsquares"
}