Skip to content

Differences between maths with Mat and MatExpr #14738

@awebb-nz

Description

@awebb-nz

There seems to be inconsistencies in mathematical expressions that create MatExprs.

System information (version)
  • OpenCV => 4.1.0
  • Operating System / Platform => macOS 10.13.6
  • Compiler => clang-1000.11.45.5
Detailed description

I have been trying to use opencv to do some image processing, and I have found an inconsistency between using Mat and MatExpr.

Steps to reproduce

Specifically, in the following code, I would expect the output in both cases to be the same:

Mat m(1, 1, CV_32FC3, 1);
Mat n = m.clone();

Mat temp = m * 5;
temp = temp + 10;
std::cout << temp << std::endl;

Mat temp2 = n * 5 + 10;
std::cout << temp2 << std::endl;

However, the output I get is:

[15, 0, 0]
[15, 10, 10]

There have been some similar previous issues (#9688 #9720), but those are both a bit older, and I am not sure they show the same issues.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions