When using perspectiveTransform in rather complicated settings, it would be easier for developers to have two separate assertions for each part of the boolean expression in order to pinpoint problems more efficiently. In my case I am struggling in Python2.7 with finding out whether scn+1 == m.cols or the depth == CV_32F || depth == CV_64F is making a problem, which is kind of hard.
This fixes all problems from the article "Checking OpenCV with PVS-Studio"
<http://www.viva64.com/en/b/0191/> that are not already fixed and are
not in 3rdparty or the legacy module.
The problems fixed are two instances of useless code and one instance
of unspecified behavior (right-shifting a negative number).
I propose forEach method for cv::Mat and cv::Mat_.
This is solution for the overhead of MatIterator_<_Tp>.
I runs a test that micro opecode runs all over the pixel of cv::Mat_<cv::Point3_<uint8_t>>.
And this implementation 40% faster than the simple pointer, 80% faster than iterator.
With OpenMP, 70% faster than simple pointer, 95% faster than iterator (Core i7 920).
Above all, code is more readable.
My test code is here.
https://gist.github.com/kazuki-ma/8285876
Thanks.