findTransformECC iterations do not converge
When I using findTransformECC, and I provide an initial warping matrix. But the program is down when the iteration not converge.
OpenCV Error: Iterations do not converge (the algorithm stopped before its convergence...) in findTransformECC ,
Can I just ignore the error and return a not converged flag? Why this funcion is designed to crash when not converged? I think it's not friendly.
Can you add reproducible code and data?
I think you should be able to wrap the call in
try / catch
to catch the exception.Yes, the program always failed when the initial warp parameter is not good. try/catch can fix this problem. But I still wonder why OpenCV won't just return the status like "calcOpticalFlowPyrLK". Thanks for your reply.
It was integrated like this.
If you think there is an issue with
findTransformECC
not converging (not because of too far initial values but rather an implementation issue in the method), feel free to add the reproducible data and code.The method uses most likely a non-linear optimization approach. So if the initial guess is too far, the method can converge to a local minima I guess.