google-ar / arcore-android-sdk

ARCore SDK for Android Studio
https://developers.google.com/ar
Other
4.97k stars 1.22k forks source link

Cannot get distortion parameter from ACameraMetadata #836

Closed nedfex closed 3 years ago

nedfex commented 5 years ago

SPECIFIC ISSUE ENCOUNTERED

I was modifying the sample code hello_ar_application.cc in sample/hello_ar_c, and trying to get intrinsic and distortion parameters, however the Tags did not contain such attributes, here is the code I added after backgroundrenderer.Draw(arsession, arframe) in the function void HelloArApplication::OnDrawFrame()

 int32_t count = 0;
    const uint32_t* tags = nullptr;
    ACameraMetadata_getAllTags(cameraMetadata, &count, &tags);
    LOGI("Metadata available %d tags: ", count);
    for (int tagIdx = 0; tagIdx < count; ++tagIdx) {
      LOGI("Found camera tag: %I", tags[tagIdx]);
      if (ACAMERA_LENS_DISTORTION == tags[tagIdx]) {
        LOGI("ACAMERA_LENS_RADIAL_DISTORTION available!!!!");
      }
    }
ACameraMetadata_const_entry entry = {0};
    camera_status_t cameraStatus = ACameraMetadata_getConstEntry(
        cameraMetadata, ACAMERA_LENS_DISTORTION, &entry);
    if (cameraStatus == ACAMERA_OK) {
      LOGI("Dist coeff: ");
      //            for (size_t i = 0; i < 6; i++)  {
      //                RORLOG_INFO << "coeff "  << i << ": " <<
      //                entry.data.f[i];
      //            }
    } 

Does anyone have idea how to get those values? Also, are images came out from ndk undistorted or not by default?

Thanks

VERSIONS USED

STEPS TO REPRODUCE THE ISSUE

WORKAROUNDS (IF ANY)

ADDITIONAL COMMENTS

JaimeIvanCervantes commented 5 years ago

I am also interested on this: when I acquire the came image, is the image undistorted already? If it's not undistorted, would it be possible to get the distortion coefficients?

devbridie commented 3 years ago

Currently no update on this, but this is duplicating #112. The image that comes out of ARCore is distorted.