Mat_ -> Matx conversion sets matrix to all zeros (Bug #3891)


Added by Philipp Hasper over 10 years ago. Updated over 9 years ago.


Status:Done Start date:2014-09-01
Priority:High Due date:
Assignee:Alexander Alekhin % Done:

0%

Category:core
Target version:3.0
Affected version:branch 'master' (3.0-dev) Operating System:Any
Difficulty:Medium HW Platform:Any
Pull request:

Description

The automatic conversion from Mat_ to Matx always sets the matrix to zero. This is because the corresponding operator
calls the standard constructor which then sets all values to zero.

The bad thing about this is, that this conversion also happens automatically if a function accepting Matx is called with a Mat_ object. See the example program: the first matrix is non-zero while the second and third are all zero.

Fixing the bug by changing
this->Mat::operator Matx<typename DataType<_Tp>::channel_type, m, n>();
to
this->Mat::operator Matx<typename DataType<_Tp>::channel_type, m, n>((_Tp*)data);
did not work - the standard constructor is still called.


ConversionFail.cpp (345 Bytes) Philipp Hasper, 2014-09-01 08:29 pm


Associated revisions

Revision 80c79d40
Added by Vadim Pisarevsky almost 10 years ago

Merge pull request #3891 from mshabunin:fix-v4l2-link

History

Updated by Philipp Hasper over 10 years ago

  • Target version set to 3.0-beta

Updated by Andrey Pavlenko over 10 years ago

Philipp, thanks for the report.
OpenCV community would appreciate if you also fix the problem and submit a pull-request.
Otherwise please wait for the fix by somebody other.

  • Status changed from New to Open
  • Assignee set to Andrey Pavlenko
  • Difficulty set to Medium
  • Priority changed from Blocker to High
  • Category set to core

Updated by Maksim Shabunin almost 10 years ago

  • Target version changed from 3.0-beta to 3.0

Updated by Vadim Pisarevsky almost 10 years ago

at least on OSX with Xcode 6.1 and clang the code works fine

  • Status changed from Open to Cancelled

Updated by Alexander Alekhin over 9 years ago

Problem exists for MSVS2010 / MSVS 2012 builds and test "Core_Matx.fromMat_" failed.

Added PR: https://github.com/Itseez/opencv/pull/4122

  • Assignee changed from Andrey Pavlenko to Alexander Alekhin
  • Status changed from Cancelled to Open

Updated by Alexander Alekhin over 9 years ago

  • Status changed from Open to Done

Also available in: Atom PDF