{"action":"opened","issue":{"url":"https://api.github.com/repos/mshabunin/test2/issues/488","labels_url":"https://api.github.com/repos/mshabunin/test2/issues/488/labels{/name}","comments_url":"https://api.github.com/repos/mshabunin/test2/issues/488/comments","events_url":"https://api.github.com/repos/mshabunin/test2/issues/488/events","html_url":"https://github.com/mshabunin/test2/issues/488","id":96603878,"number":488,"title":"Results of cv::resize and cv::gpu::resize do not match","user":{"login":"opencv-pushbot","id":2051563,"avatar_url":"https://avatars.githubusercontent.com/u/2051563?v=3","gravatar_id":"","url":"https://api.github.com/users/opencv-pushbot","html_url":"https://github.com/opencv-pushbot","followers_url":"https://api.github.com/users/opencv-pushbot/followers","following_url":"https://api.github.com/users/opencv-pushbot/following{/other_user}","gists_url":"https://api.github.com/users/opencv-pushbot/gists{/gist_id}","starred_url":"https://api.github.com/users/opencv-pushbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencv-pushbot/subscriptions","organizations_url":"https://api.github.com/users/opencv-pushbot/orgs","repos_url":"https://api.github.com/users/opencv-pushbot/repos","events_url":"https://api.github.com/users/opencv-pushbot/events{/privacy}","received_events_url":"https://api.github.com/users/opencv-pushbot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mshabunin/test2/labels/affected:%202.4","name":"affected: 2.4","color":"ededed"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/auto-transferred","name":"auto-transferred","color":"ededed"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/category:%20gpu%20(cuda)","name":"category: gpu (cuda)","color":"ededed"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/priority:%20normal","name":"priority: normal","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-22T16:05:02Z","updated_at":"2015-07-22T16:05:03Z","closed_at":null,"body":"Transferred from http://code.opencv.org/issues/3641\r\n```\n|| Lon Risinger on 2014-04-10 18:54\n|| Priority: Normal\n|| Affected: 2.4.0 - 2.4.8\n|| Category: gpu (cuda)\n|| Tracker: Bug\n|| Difficulty: \n|| PR: \n|| Platform: x64 / Linux\n```\n\nResults of cv::resize and cv::gpu::resize do not match\n-----------\n```\nWhen re-sizing an image patch using the GPU accelerated version of resize(), the results do not match the results of the equivalent unaccelerated resize().\r\n\r\nThe code snippet below shows that each channel is off by 1 or occasionally 2.\r\n\r\nPossibly useful info:\r\nType is CV_8UC3 - have not tried other cv::Mat types.\r\nOpenCV compiled with cuda 5.5 and gcc/g++ 4.6\r\nCode snippet compiled with g++ 4.8.1\r\nOS: Linux Ubuntu 13.10\r\n\r\n=============================================================================\r\n\r\n   std::cout << \"OPENCV RESIZE GPU/CPU compare ...\" << std::endl;\r\n    \r\n    // initialize image size \r\n    cv::Size imgSize(640, 480);\r\n    \r\n    \r\n    \r\n    // initialize image with its pixels going from (0,0,0) to (255,255,255)\r\n    cv::Mat image = cv::Mat(imgSize, CV_8UC3, cv::Scalar(0,0,0));\r\n    for (int row = 0; row < image.rows; ++row)\r\n    {\r\n        for (int col = 0; col < image.cols; ++col)\r\n        {\r\n            image.at<cv::Vec3b>(row, col)[0] = floor(float(row)/float(image.rows)*255.0f);\r\n            image.at<cv::Vec3b>(row, col)[1] = floor(float(col)/float(image.cols)*255.0f);\r\n            image.at<cv::Vec3b>(row, col)[2] = floor(((float(row)/float(image.rows) + float(col)/float(image.cols))/2.0f) * 255.0f);\r\n        }\r\n    }\r\n    \r\n    cv::gpu::GpuMat image_gpu;\r\n    image_gpu.upload(image);\r\n    cv::Size standardBoxSize(10, 10);\r\n    cv::Rect rawBox(20, 20, 50, 50); // x, y, width, height\r\n    cv::gpu::GpuMat patch_gpu;\r\n    cv::Mat cpu_resized_patch;\r\n    cv::Mat gpu_resized_patch;\r\n    \r\n    cv::gpu::Stream stream;\r\n    // resize source image area within rawBox to standard size\r\n    cv::gpu::resize(image_gpu(rawBox), patch_gpu, standardBoxSize);    \r\n    patch_gpu.download(gpu_resized_patch);\r\n    cv::resize(image(rawBox), cpu_resized_patch, standardBoxSize);\r\n    \r\n    int misMatchCnt = 0;\r\n    for (int row = 0; row < cpu_resized_patch.rows; ++row)\r\n    {\r\n        for (int col = 0; col < cpu_resized_patch.cols; ++col)\r\n        {\r\n            cv::Vec3b pix_cpu = cpu_resized_patch.at<cv::Vec3b>(row, col);\r\n            cv::Vec3b pix_gpu = gpu_resized_patch.at<cv::Vec3b>(row, col);\r\n            if(pix_cpu[0] != pix_gpu[0] ||  pix_cpu[1] != pix_gpu[1] || pix_cpu[2] != pix_gpu[2])\r\n            {\r\n                std::cout  << \" col: \" << col << \" row: \" << row \r\n                           << \" diff: \" << pix_cpu[0]- pix_gpu[0] \r\n                           << \" \" << pix_cpu[1]- pix_gpu[1] \r\n                           << \" \" << pix_cpu[2]- pix_gpu[2] \r\n                           << std::endl;\r\n                misMatchCnt++;\r\n            }\r\n        }\r\n    }\r\n    \r\n    std::cout  << \" mismatch \" << misMatchCnt / (cpu_resized_patch.size().height*cpu_resized_patch.size().width) * 100 << \" %\" << std::endl;\r\n\r\n===================================================================\r\n\r\nOutput:\r\n\r\n\r\nOPENCV RESIZE GPU/CPU compare ...\r\n col: 0 row: 0 diff: 1 1 1\r\n col: 1 row: 0 diff: 1 1 1\r\n col: 2 row: 0 diff: 1 1 1\r\n col: 3 row: 0 diff: 1 1 1\r\n col: 4 row: 0 diff: 1 1 1\r\n col: 5 row: 0 diff: 1 1 1\r\n col: 6 row: 0 diff: 1 1 1\r\n col: 7 row: 0 diff: 1 1 1\r\n col: 8 row: 0 diff: 1 1 1\r\n col: 9 row: 0 diff: 1 1 1\r\n...\r\n col: 4 row: 9 diff: 1 1 1\r\n col: 5 row: 9 diff: 1 1 1\r\n col: 6 row: 9 diff: 1 1 1\r\n col: 7 row: 9 diff: 1 1 1\r\n col: 8 row: 9 diff: 1 1 1\r\n col: 9 row: 9 diff: 1 1 1\r\n\r\n mismatch 100 %\n```\n\nHistory\n-------\n##### Alexander Smorkalov on 2014-04-30 19:11\n```\n-   Assignee set to Vladislav Vinogradov\n-   Category set to gpu (cuda)\n```\n##### Dmitry Retinskiy on 2014-05-29 06:36\n```\nHi Vlad,\r\n\r\ncould you check this and say your opinion?\r\nThanks.\n-   Affected version changed from 2.4.8 (latest release) to 2.4.0 -\n    2.4.8\n-   Status changed from New to Open\n```"}}