Casting a matrix expression with factor 1.0 doesn't work (Bug #2952)

Added by Stephen Kockentiedt over 4 years ago. Updated almost 2 years ago.

Status:Open Start date:2013-04-11
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:


Target version:Next Hackathon
Affected version:2.4.8 (latest release) Operating System:Any
Difficulty: HW Platform:Any
Pull request:


When executing the following code, m2 has the type CV_8UC1 and m3 throws an assertion error on calling type(). If the factor is 2.0 instead, the problem does not occur.

cv::Mat m1(4,4,CV_32SC1, cv::Scalar::all(0));
cv::Mat m2 = cv::Mat_<double>(m1 * 1.0);
cv::Mat_<double> m3(m1 * 1.0);


Updated by Maria Dimashova over 4 years ago

  • Affected version changed from 2.4.4 to 2.4.0 - 2.4.4
  • Assignee set to Vadim Pisarevsky
  • Category set to core

Updated by Maria Dimashova over 4 years ago

Affected version 2.4.4.

Updated by Daniil Osokin over 3 years ago

This is actually not a bug. Result of m1 * 1.0 from this example has CV_32SC1 type, so it's incorrect to initialize Mat_<double> with int data. But it is look unexpected: different result types with tifferent factors. The problem starts in void MatOp_AddEx::assign(const MatExpr& e, Mat& m, int _type) const at line 1202 in 'matop.cpp'.

  • HW Platform set to Any
  • Operating System set to Any
  • Affected version changed from 2.4.0 - 2.4.4 to 2.4.8 (latest release)
  • Target version set to Next Hackathon

Updated by Maksim Shabunin almost 2 years ago

Issue has been transferred to GitHub:

Also available in: Atom PDF