Fixed estimateDistortion and estimateUndistortion that got stuck in optimizer when calling calibrateCameras
I changed estimateDistortion and estimateUndistortion. These made calls to nlminb with parameters that were set to NA. In the call to the optimized function there were then set to zero. In the original package this made the optimizer get stuck. In the code, these final to parameters were always set to NAs in the starting values. So they were never actually estimated and always set to zero.
To conserve functionality I, changed to code to be able to receive either 5 or 7 starting parameters. If 5 parameters were sent, (similar to setting them to NA in the current version, which was always the case), then the final two parameters are set to zero. After the call to the optimizer these NAs are then padded to the output, to make sure that 7 parameters are returned (for both estimateDistortion and estimateUndistortion). Minor changes were made to undistortionError and distortionError to allow for the code change
A test of calibrateCameras() on the movie clip that is available as example online shows that the code now runs. I could not check if the outcomes are numerically the same. Thanks again for sharing this code in github. Much appreciated.