-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
cartToPolar does not work in place #21732
Copy link
Copy link
Closed
Labels
Milestone
Description
System information (version)
- OpenCV => 4.5
- Operating System / Platform => Linux
- Compiler => clang 11
Detailed description
cartToPolar does not work in place: this should be fixed or there should be an error. polarToCart seems to work but I cannot confirm the OCL and IPP versions work. There should be a test for both anyway (like the code I provide below).
Steps to reproduce
The following code shows the issue. clang++ -g -O3 -l opencv_core -I /usr/include/opencv4/ -o test main.cc
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
int main(int, char**argv){
cv::Mat1d A[2] = {cv::Mat1d(10, 10), cv::Mat1d(10, 10)};
cv::Mat1d B[2], C[2];
for(auto&a: A) cv::randu(a, 0, 10000);
cv::cartToPolar(A[0], A[1], B[0], B[1], false);
cv::polarToCart(B[0], B[1], C[0], C[1], false);
std::cout << "There is a small difference due to the 0.3 degree approximation" << std::endl;
std::cout << cv::norm(A[0], C[0], cv::NORM_INF) << " " << cv::norm(A[1], C[1], cv::NORM_INF) << std::endl;
cv::cartToPolar(A[0], A[1], B[0], B[1], false);
cv::polarToCart(B[0], B[1], C[0], C[1], false);
cv::polarToCart(B[0], B[1], B[0], B[1], false);
std::cout << "This gives 0" << std::endl;
std::cout << cv::norm(B[0], C[0], cv::NORM_INF) << " " << cv::norm(B[1], C[1], cv::NORM_INF) << std::endl;
cv::cartToPolar(A[0], A[1], B[0], B[1], false);
cv::cartToPolar(A[0], A[1], A[0], A[1], false);
std::cout << "This does not give 0 for the second norm showing it does not work in place" << std::endl;
std::cout << cv::norm(A[0], B[0], cv::NORM_INF) << " " << cv::norm(A[1], B[1], cv::NORM_INF) << std::endl;
}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
Reactions are currently unavailable