Skip to content

Quaternion SLERP: templated function supports only double #23293

@shtern94

Description

@shtern94

System Information

OpenCV version: 4.5.2
OS: Ubuntu 20.04.5 LTS
Compiler & compiler version: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

Detailed description

I am trying to create a templated function that will also use Quat's slerp function.
I've discovered that for some reason the slerp function is converting input quaternions to Quatd (lines 748 and 749 in quaternion.inl.hpp), thus blocking the usage of this function with any other than double type.
I tried removing this enforcement and the function starts working with float type (as an example).
Also you can see, that in nlerp function it is implemented as Quat<T> as expected (link)
Is there a real reason for this limitation?

Steps to reproduce

A simple example that crashes at compilation time:

cv::Quat<float> quat1(-0.436207, -0.3, 0.54, 0.654311);
cv::Quat<float> quat2(-0.479223, 0.77, 0.28, 0.314714);
cv::Quat<float> test = cv::Quat<float>::slerp(quat1, quat2, float(0.5));

This won't compile, but if you switch float to double it does work.

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions