Skip to content

Fix cubic root computation in calibrateHandEye#18164

Closed
catree wants to merge 1 commit intoopencv:masterfrom
catree:fix_hand_eye_calibration_Andreff_NaN
Closed

Fix cubic root computation in calibrateHandEye#18164
catree wants to merge 1 commit intoopencv:masterfrom
catree:fix_hand_eye_calibration_Andreff_NaN

Conversation

@catree
Copy link
Copy Markdown
Contributor

@catree catree commented Aug 21, 2020

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • N/A The feature is well documented and sample code can be built with the project CMake

fix #17986

qy = (m02 - m20) / S;
qz = (m10 - m01) / S;
} else if ((m00 > m11)&(m00 > m22)) {
} else if (m00 > m11 && m00 > m22) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #18115

I just copy/paste this code from the above link. Don't know if & is intended in the original code but it is better to fix that.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contribution!

Please take a look on comments below.

//Eq 15
double det = determinant(R);
R = pow(sign_double(det) / abs(det), 1.0/3.0) * R;
R = std::cbrt(std::copysign(1, det) / abs(det)) * R;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to add check to ensure that det != 0 (like fabs(det) < FLT_EPSILON and failure with StsNoConv)

It may be impossible in math theory, but we are working with approximated computations. There are several parts in OpenCV code which can return negative value for stddev (like 1e-6) and have hacks to clamp these values.
It would be nice to "fail fast" and don't process NaNs.

methods.push_back(CALIB_HAND_EYE_DANIILIDIS);

for (size_t idx = 0; idx < methods.size(); idx++) {
Matx33d R_cam2gripper_est;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets provide more details in case of failures of complex tests:

for (...) {
    SCOPED_TRACE(cv::format("method=%d", methods[idx]));
    ...

… to handle negative values. Improve doc. Add regression test.

Use C++11 std::copysign.
@catree catree force-pushed the fix_hand_eye_calibration_Andreff_NaN branch from a5537f2 to 49b6928 Compare August 25, 2020 01:31
@catree
Copy link
Copy Markdown
Contributor Author

catree commented Aug 27, 2020

This can be closed since 3.4 branch has been merged into master.

@alalek
I think the corresponding issue must be closed manually.

@catree catree closed this Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CALIB_HAND_EYE: _ANDREFF & _DANIILIDIS fail

2 participants