{"action":"opened","issue":{"url":"https://api.github.com/repos/Itseez/opencv/issues/5915","labels_url":"https://api.github.com/repos/Itseez/opencv/issues/5915/labels{/name}","comments_url":"https://api.github.com/repos/Itseez/opencv/issues/5915/comments","events_url":"https://api.github.com/repos/Itseez/opencv/issues/5915/events","html_url":"https://github.com/Itseez/opencv/issues/5915","id":124635309,"number":5915,"title":"calcOpticalFlowPyrLK yields incorrect result when using OpenCL","user":{"login":"lych77","id":3362775,"avatar_url":"https://avatars.githubusercontent.com/u/3362775?v=3","gravatar_id":"","url":"https://api.github.com/users/lych77","html_url":"https://github.com/lych77","followers_url":"https://api.github.com/users/lych77/followers","following_url":"https://api.github.com/users/lych77/following{/other_user}","gists_url":"https://api.github.com/users/lych77/gists{/gist_id}","starred_url":"https://api.github.com/users/lych77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lych77/subscriptions","organizations_url":"https://api.github.com/users/lych77/orgs","repos_url":"https://api.github.com/users/lych77/repos","events_url":"https://api.github.com/users/lych77/events{/privacy}","received_events_url":"https://api.github.com/users/lych77/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-03T07:45:04Z","updated_at":"2016-01-03T07:45:04Z","closed_at":null,"body":"Visual Studio 2015\r\nOpenCV 3.1.0\r\nWITH_OPENCL enabled\r\nWITH_OPENCL_SVM enabled/disabled (always occur)\r\n\r\nConcise sample code:\r\n\r\n\tcout << \"useOpenCL: \" << ocl::useOpenCL() << endl;\r\n\r\n\t// Just the sample video shipped with OpenCV source\r\n\tVideoCapture cap(\"D:\\\\work\\\\opencv_3.1\\\\opencv\\\\sources\\\\samples\\\\data\\\\768x576.avi\");\r\n\r\n\tUMat f0, f1, g0, g1;\r\n\tcap >> f0;\r\n\tcap >> f1;\r\n\r\n\tcvtColor(f0, g0, COLOR_BGR2GRAY);\r\n\tcvtColor(f1, g1, COLOR_BGR2GRAY);\r\n\r\n\tMat p0(8, 1, CV_32FC2), p1, status, err;\r\n\ttheRNG().fill(p0, RNG::UNIFORM, 0, min(f0.rows, f0.cols));\r\n\r\n\tcalcOpticalFlowPyrLK(g0, g1, p0, p1, status, err);\r\n\r\n\tcout << \"p0: \" << p0 << endl;\r\n\tcout << \"p1: \" << p1 << endl;\r\n\tcout << \"status: \" << status << endl;\r\n\tcout << \"err: \" << err << endl;\r\n\r\nOutput when OpenCL is disabled:\r\n\r\n    useOpenCL: 0\r\n    p0: [305.4429, 114.7733;\r\n     231.01024, 469.08582;\r\n     251.78859, 143.30287;\r\n     445.30853, 438.966;\r\n     177.28961, 404.60065;\r\n     275.5856, 456.30145;\r\n     49.445633, 43.234711;\r\n     94.131866, 172.67282]\r\n    p1: [305.45264, 114.76205;\r\n     231.08749, 469.09006;\r\n     251.80547, 143.31331;\r\n     445.29504, 438.96689;\r\n     177.42975, 404.54962;\r\n     275.69241, 456.32147;\r\n     49.464996, 43.233234;\r\n     94.185921, 172.67618]\r\n    status: [  1;\r\n       1;\r\n       1;\r\n       1;\r\n       1;\r\n       1;\r\n       1;\r\n       1]\r\n    err: [1.2229308;\r\n     1.2712585;\r\n     1.2330641;\r\n     1.5741214;\r\n     1.2522676;\r\n     1.2371032;\r\n     1.4520266;\r\n     1.9238945]\r\n\r\nOutput when OpenCL is enabled:\r\n\r\n    useOpenCL: 1\r\n    p0: [305.4429, 114.7733;\r\n     231.01024, 469.08582;\r\n     251.78859, 143.30287;\r\n     445.30853, 438.966;\r\n     177.28961, 404.60065;\r\n     275.5856, 456.30145;\r\n     49.445633, 43.234711;\r\n     94.131866, 172.67282]\r\n    p1: [305.45108, 114.7645;\r\n     14.43814, 29.317863;\r\n     15.736787, 8.9564295;\r\n     27.831783, 27.435375;\r\n     11.080601, 25.28754;\r\n     17.2241, 28.518841;\r\n     3.0903521, 2.7021694;\r\n     5.8832417, 10.792051]\r\n    status: [  1;\r\n       1;\r\n       1;\r\n       1;\r\n       1;\r\n       1;\r\n       1;\r\n       1]\r\n    err: [1.2273066;\r\n     -4.3160208e+08;\r\n     -4.3160208e+08;\r\n     -4.3160208e+08;\r\n     -4.3160208e+08;\r\n     -4.3160208e+08;\r\n     -4.3160208e+08;\r\n     -4.3160208e+08]\r\n\r\nThis problem occurs only if grayscale images (g0, g1) are passed, and for colored images, i.e. passing f0, f1 instead of g0, g1, it's correct in both cases.\r\n"}}