Conversation
|
👍 |
|
PR is merged, but GitHub does not show correct status. |
|
@alalek Hi, I'm late here, but observed that this PR makes "inplace rgb2bgr" operation slow for cv::Mat. Specifically, for a cv::Mat image = cv::read("rgb.png");
cv::cvtColor(image, image, cv::COLOR_BGR2RGB);costs 15 ms, while my own naive implentation only costs 5 ms void rgb2bgr_inplace_naive(unsigned char* buf, size_t height, size_t width)
{
unsigned char tmp = 0;
size_t len = height * width *3;
for (size_t i=0; i<len; i+=3) {
tmp = buf[i];
buf[i] = buf[i+2];
buf[i+2] = tmp;
}
}and I figured out the "magic" is the change in this commit, i.e.: if (_src.getObj() == _dst.getObj()) // inplace processing (#6653)
_src.copyTo(src); // !! this copy makes more time cost
else
src = _src.getMat();Is there any better solution, that keeps arm neon performance for inplace rgb2bgr, and also resolve #6653 ? |
|
Using implementations with 2 pointers with equal addresses would cause bugs (due to compiler optimizations, see #7819 as example). Consider using of 2 different Mat objects in |
|
Tested with the following code, which is more faster (3ms on my android arm64): cv::Mat image = cv::read("rgb.png");
cv::Mat image_copy = image;
cv::cvtColor(image_copy, image, cv::COLOR_BGR2RGB);Is the usage OK? In this usage, |
resolves #6653