Skip to content

Carotene (ARM HAL) uses wrong rounding in some places #24163

@ZJUGuoShuai

Description

@ZJUGuoShuai

System Information

  • OpenCV version: 4.8.0
  • Operating System: macOS 13.3.1 (ARM64) / Ubuntu 20.04.4 (x86_64)
  • Compiler: Apple clang version 14.0.3 / g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

Detailed description

Even this (1+0)/2 gives different result on macOS and Linux:

cv::Mat A = cv::Mat::ones(3, 3, CV_8UC1);
cv::Mat B = cv::Mat::zeros(3, 3, CV_8UC1);
cv::Mat mean = (A + B) / 2;
std::cout << "A = \n" << A << std::endl;
std::cout << "B = \n" << B << std::endl;
std::cout << "(A+B)/2 = \n" << mean << std::endl;

Steps to reproduce

Write this code:

cv::Mat A = cv::Mat::ones(3, 3, CV_8UC1);
cv::Mat B = cv::Mat::zeros(3, 3, CV_8UC1);
cv::Mat mean = (A + B) / 2;
std::cout << "A = \n" << A << std::endl;
std::cout << "B = \n" << B << std::endl;
std::cout << "(A+B)/2 = \n" << mean << std::endl;

On macOS:

A =
[  1,   1,   1;
   1,   1,   1;
   1,   1,   1]
B =
[  0,   0,   0;
   0,   0,   0;
   0,   0,   0]
(A+B)/2 =
[  1,   1,   1;
   1,   1,   1;
   1,   1,   0]

On Linux:

A =
[  1,   1,   1;
   1,   1,   1;
   1,   1,   1]
B =
[  0,   0,   0;
   0,   0,   0;
   0,   0,   0]
(A+B)/2 =
[  0,   0,   0;
   0,   0,   0;
   0,   0,   0]

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

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions