{"action":"opened","issue":{"url":"https://api.github.com/repos/mshabunin/test2/issues/349","labels_url":"https://api.github.com/repos/mshabunin/test2/issues/349/labels{/name}","comments_url":"https://api.github.com/repos/mshabunin/test2/issues/349/comments","events_url":"https://api.github.com/repos/mshabunin/test2/issues/349/events","html_url":"https://github.com/mshabunin/test2/issues/349","id":95412331,"number":349,"title":"Stitcher generate result file 158 bytes long without error","user":{"login":"mshabunin","id":3304494,"avatar_url":"https://avatars.githubusercontent.com/u/3304494?v=3","gravatar_id":"","url":"https://api.github.com/users/mshabunin","html_url":"https://github.com/mshabunin","followers_url":"https://api.github.com/users/mshabunin/followers","following_url":"https://api.github.com/users/mshabunin/following{/other_user}","gists_url":"https://api.github.com/users/mshabunin/gists{/gist_id}","starred_url":"https://api.github.com/users/mshabunin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mshabunin/subscriptions","organizations_url":"https://api.github.com/users/mshabunin/orgs","repos_url":"https://api.github.com/users/mshabunin/repos","events_url":"https://api.github.com/users/mshabunin/events{/privacy}","received_events_url":"https://api.github.com/users/mshabunin/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:%20stitching","name":"category: stitching","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-16T11:23:22Z","updated_at":"2015-07-16T11:23:22Z","closed_at":null,"body":"Transferred from http://code.opencv.org/issues/3122\r\n```\n|| Nikolay Rogoshchenkov on 2013-06-28 21:22\n|| Priority: Normal\n|| Affected: branch 'master' (2.4.9)\n|| Category: stitching\n|| Tracker: Bug\n|| Difficulty: \n|| PR: \n|| Platform: x64 / Windows\n```\n\nStitcher generate result file 158 bytes long without error\n-----------\n```\n*Subj!*\r\n\r\nCommand line to reproduce: \r\n<pre>\r\nopenCV_stitch_three.exe  b1.bmp b2.bmp b3.bmp\r\n</pre>\r\n\r\nExample code:\r\n<pre>\r\nint main(int argc, char* argv[])\r\n{\r\n    int retval = parseCmdArgs(argc, argv);\r\n    if (retval) return -1;\r\n\r\n    Mat pano;\r\n\t\r\n\tprintf(\"Channels image1: %d\\n\", imgs[0].type());\r\n\tprintf(\"Channels image2: %d\\n\", imgs[1].type());\r\n\t\r\n\tint width = 170;\r\n\t\r\n\tcv::Rect rect1 = cvRect( imgs[0].cols-width, 0, width, imgs[0].rows); //second half of the first image\r\n\tcv::vector<cv::Rect> roi1;\r\n\troi1.push_back(rect1);\r\n\r\n\tcv::Rect rect12 =  cvRect(0, 0,width, imgs[1].rows);  //first half of the second image\r\n\tcv::Rect rect23 = cvRect(imgs[1].cols -width, 0, width, imgs[1].rows);  //second half of the first image\r\n\tcv::vector<cv::Rect> roi2;\r\n\troi2.push_back(rect12);\r\n\troi2.push_back(rect23);\r\n\r\n\tcv::Rect rect3 = cvRect(0, 0, width, imgs[2].rows); //first half of the third image\r\n\tcv::vector<cv::Rect> roi3;\r\n\troi3.push_back(rect3);\r\n\r\n\tcv::vector<cv::vector<cv::Rect>> rois;\r\n\trois.resize(3);\r\n\trois[0] = roi1;\r\n\trois[1] = roi2;\r\n\trois[2] = roi3;\r\n\t//cv::imshow(\"debug_img1\", imgs[0]);\r\n\tMat tmp1, tmp2, tmp3;\r\n\tcvtColor(imgs[0], tmp1, CV_BGR2GRAY); \r\n\tcvtColor(imgs[1], tmp2, CV_BGR2GRAY); \r\n\tcvtColor(imgs[2], tmp3, CV_BGR2GRAY); \r\n\t/*lensCorrectorBarrel(tmp1.data, tmp1.cols, tmp1.rows);\r\n\tlensCorrectorBarrel(tmp2.data, tmp2.cols, tmp2.rows);\r\n\tlensCorrectorBarrel(tmp3.data, tmp3.cols, tmp3.rows);\r\n\timwrite(\"corr1.tif\", tmp1);\r\n\timwrite(\"corr2.tif\", tmp2);\r\n\timwrite(\"corr3.tif\", tmp3);*/\r\n\t/*namedWindow( \"debug_img_corr1\", CV_WINDOW_AUTOSIZE );\r\n\tnamedWindow( \"debug_img_corr2\", CV_WINDOW_AUTOSIZE );\r\n\tcv::imshow(\"debug_img_corr1\", tmp1);\r\n\tcv::imshow(\"debug_img_corr2\", tmp2);*/\r\n\r\n\tcvtColor(tmp1, imgs[0], CV_GRAY2BGR); \r\n\tcvtColor(tmp2, imgs[1], CV_GRAY2BGR); \r\n\tcvtColor(tmp3, imgs[2], CV_GRAY2BGR); \r\n\r\n\t//char cc = cvWaitKey(0);\r\n\r\n\t/*cv::rectangle( imgs[0], rect1, CV_RGB(255,0,0), 1);\r\n\tcv::rectangle( imgs[1], rect12, CV_RGB(255,0,0), 1);\r\n\tcv::rectangle( imgs[1], rect23, CV_RGB(255,0,0), 1);\r\n\tcv::rectangle( imgs[2], rect3, CV_RGB(255,0,0), 1);\r\n\tcv::imshow(\"debug_img1\", imgs[0]);\r\n\tcv::imshow(\"debug_img2\", imgs[1]);\r\n\tcv::imshow(\"debug_img3\", imgs[2]);\r\n\tchar c = cvWaitKey(0);*/\r\n\r\n    Stitcher stitcher = Stitcher::createDefault(false);\r\n\tstitcher.setPanoConfidenceThresh(0.07);\r\n\tstitcher.setWaveCorrection(false);\r\n\t\r\n\t//detail::BestOf2NearestMatcher *matcher = new detail::BestOf2NearestMatcher(false, 0.001/*=match_conf*/);\r\n\t//detail::SurfFeaturesFinder *featureFinder = new detail::SurfFeaturesFinder(100);\r\n\t//stitcher.setFeaturesMatcher(matcher);\r\n\t//stitcher.setFeaturesFinder(featureFinder);\r\n    Stitcher::Status status = stitcher.stitch(imgs, rois, pano);\r\n\t//Stitcher::Status status = stitcher.composePanorama(imgs, pano);\r\n\t\r\n    if (status != Stitcher::OK)\r\n    {\r\n        cout << \"Can't stitch images, error code = \" << status << endl;\r\n        return -1;\r\n    }\r\n\r\n    imwrite(result_name, pano);\r\n\r\n\tchar ac = cvWaitKey(0);\r\n\tif(ac == 'ESC')\r\n\t\treturn 0;\r\n}\r\n</pre>\r\n\r\nThank you.\n```\n\nHistory\n-------\n##### Nikolay Rogoshchenkov on 2013-06-28 21:27\n```\nHow can I attach additional files? With good images, for example.\n```\n##### Alexey Spizhevoy on 2013-07-01 06:27\n```\nThere is the 'Files' section available when one is composing a new message.\n```\n##### Nikolay Rogoshchenkov on 2013-07-01 12:12\n```\nSince archieve with good images > 5MB, you can download it here: http://nikkadim.com/good_images.tar.gz ~6.9MB\nThank you.\n```\n##### Alexey Spizhevoy on 2013-07-02 08:32\n```\nThe code works fine when the images are passed in the correct order. Otherwise the application generates trash (as expected), but sometimes even without error message -- which isn't OK. I will add an error notification.\n```\n##### Nikolay Rogoshchenkov on 2013-07-04 22:25\n```\nAlexey Spizhevoy wrote:\r\n> The code works fine when the images are passed in the correct order. Otherwise the application generates trash (as expected), but sometimes even without error message -- which isn't OK. I will add an error notification.\r\n\r\nSo, you wanna say, that's order in my example is wrong?\n```\n##### Alexey Spizhevoy on 2013-07-05 07:52\n```\nIf I pass \"a1.bmp a2.bmp a3.bmp\" (you haven't attached any b*.bmp) then your code works, in some other cases it fails.\n-   Affected version changed from 2.4.5 (latest release) to branch\n    'master' (2.4.9)\n```\n##### Nikolay Rogoshchenkov on 2013-07-05 19:19\n```\nThis problem.tar.gz archive contains:\r\n<pre>\r\n- openCV_stitch_three.exe\r\n- b1.bmp\r\n- b2.bmp\r\n- b3.bmp\r\n- result.tif\r\n</pre>\r\n\r\nCommand line to reproduce: \r\n<pre>\r\nopenCV_stitch_three.exe  b1.bmp b2.bmp b3.bmp\r\n</pre>\r\n\r\nIn this case we have result.tif with size 158 bytes (header).\r\n\r\nThank you.\n-   File problem.tar.gz added\n```\n##### Alexey Spizhevoy on 2013-07-09 08:21\n```\nI've checked: \"openCV_stitch_three.exe b1.bmp b2.bmp b3.bmp\" failed, but \"openCV_stitch_three.exe b1.bmp b3.bmp b2.bmp\" generated good panorama.\n```\n##### Nikolay Rogoshchenkov on 2013-07-11 02:37\n```\nAlexey Spizhevoy wrote:\r\n> I've checked: \"openCV_stitch_three.exe b1.bmp b2.bmp b3.bmp\" failed, but \"openCV_stitch_three.exe b1.bmp b3.bmp b2.bmp\" generated good panorama.\r\n\r\nFailed - you mean you've got error? Or 158 bytes result file?\r\nBut problem is the right sequence is b1.bmp b2.bmp b3.bmp, this images from 3 camera in one row.\n```\n##### Nikita Manovich on 2013-07-11 07:56\n```\n-   Status changed from New to Open\n```\n##### Alexey Spizhevoy on 2013-07-11 07:59\n```\n> Failed - you mean you've got error? Or 158 bytes result file?\n158 bytes result.\n\n> But problem is the right sequence is b1.bmp b2.bmp b3.bmp, this images from 3 camera in one row.\nMaybe, but it turns out that b1,b3,b2 are matched better, than b1,b2,b3. The images' texture is very specific.\n```\n##### Nikolay Rogoshchenkov on 2013-07-11 14:41\n```\nAlexey Spizhevoy wrote:\r\n> > Failed - you mean you've got error? Or 158 bytes result file?\r\n> 158 bytes result.\r\n> \r\n> > But problem is the right sequence is b1.bmp b2.bmp b3.bmp, this images from 3 camera in one row.\r\n> Maybe, but it turns out that b1,b3,b2 are matched better, than b1,b2,b3. The images' texture is very specific.\r\n\r\nOk, is it normal to receive 158 byte file without error from stitching module? Probably not.\n```\n##### Alexey Spizhevoy on 2013-07-12 08:57\n```\nI've already said before that silent stitching failure is not OK. The \"pull request\":https://github.com/Itseez/opencv/pull/1079 is waiting to be merged.\n```\n##### Nikolay Rogoshchenkov on 2013-07-12 11:39\n```\nThank you! Sorry, I did not notice that.\nThis update will be available only in 2.4.9, right?\n```\n##### Nikolay Rogoshchenkov on 2013-07-12 13:47\n```\nAlexey, i think the problem with 158 bytes size file is more deeper.\r\n\r\nI've compiled  OpenCV246 with CUDA and TBB support, and wrote a simple program (see attachment) for stitching 6 images. \r\nBut each time when I start this program I've got different results:\r\n!http://nikkadim.com/stitch_six.png!\r\nEach time when stitching tooks >10 secs I had result image size 158 bytes, than I restart program with the same input image data I had a good results (with calculation time ~5 sec).\n-   File main.cpp added\n```\n##### Nikolay Rogoshchenkov on 2013-07-12 13:48\n```\ninput files available here: http://nikkadim.com/input_imges.zip ~5.5Mb\n```\n##### Alexey Spizhevoy on 2013-07-12 14:27\n```\nThe fix will be available in the next major release. What version the master branch will become isn't determined yet. But the issue with error message isn't critical anyway, however if you need the fix you can build OpenCV from the master branch when the pull request is merged.\r\n\r\nAs for the new info, do you have the same problem without CUDA support?\n```\n##### Nikolay Rogoshchenkov on 2013-07-13 21:19\n```\nAlexey Spizhevoy wrote:\r\n> As for the new info, do you have the same problem without CUDA support?\r\nThank you, Alexey!\r\nI did not try, but anyway, I did not use CUDA instructions in program, you can see it. Should I anyway try to compile OpenCV without CUDA?\n```\n##### Alexey Spizhevoy on 2013-07-15 12:09\n```\nI couldn't reproduce the problem. But I guess the behavior you observed was due to the FLANN matcher (used in BestOf2NearestMatcher) and it's non-deterministic actually.\n```\n##### Nikolay Rogoshchenkov on 2013-07-15 22:01\n```\nAlexey Spizhevoy wrote:\n> I couldn't reproduce the problem. But I guess the behavior you observed was due to the FLANN matcher (used in BestOf2NearestMatcher) and it's non-deterministic actually.\nIf needed I can share the dll's, exe and input files to reproduce the issue. \n\nAlso I have noticed, that this issue also reproduced on my desktop PC (Intel Core i7 950/24GB DDR3/Win7 x64). I can reproduce this with 32-bit and 64-bit version of program.\nHow can I also help to catch the root of case? May try to play with BestOf2NearestMatcher params?\n\nThank you, Alexey.\n```\n##### Nikolay Rogoshchenkov on 2013-10-30 20:00\n```\nany updates?\n```\n##### Nikolay Rogoshchenkov on 2015-04-07 16:19\n```\nSame with 2.4.11 for both x86 and x64 arch's.\nResulting pano has size = (1,1), but calculation time about right\n```"}}