Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Some possibilities.

Firstly, when using the<T>() operator, you have the responsibility to make sure that T corresponds to the actual data type of the matrix. If the data types do not match, it is an undefined behavior - it is effectively an invalid type cast and will eventually cause your program to crash. The<T>() operator does not perform type value conversion.

For example:

  • For CV_8UC1 use uchar
  • For CV_8UC3 use cv::Vec3b
  • For CV_32FC1 use float
  • For CV_32SC1 use int32_t

Secondly, keep in mind that the atan2(y, x) function is traditionally defined with rise (y) as the first argument, and run (x) as the second argument. This comes from the phrase "Rise over Run" in the definition of slope.