| 1 | initial version |
Some possibilities.
Firstly, when using the Mat.at<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 Mat.at<T>() operator does not perform type value conversion.
For example:
CV_8UC1 use ucharCV_8UC3 use cv::Vec3bCV_32FC1 use floatCV_32SC1 use int32_tSecondly, 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.