Stitcher generate result file 158 bytes long without error (Bug #3122)
Description
Subj!
Command line to reproduce:
openCV_stitch_three.exe b1.bmp b2.bmp b3.bmp
Example code:
int main(int argc, char* argv[]) { int retval = parseCmdArgs(argc, argv); if (retval) return -1; Mat pano; printf("Channels image1: %d\n", imgs[0].type()); printf("Channels image2: %d\n", imgs[1].type()); int width = 170; cv::Rect rect1 = cvRect( imgs[0].cols-width, 0, width, imgs[0].rows); //second half of the first image cv::vector<cv::Rect> roi1; roi1.push_back(rect1); cv::Rect rect12 = cvRect(0, 0,width, imgs[1].rows); //first half of the second image cv::Rect rect23 = cvRect(imgs[1].cols -width, 0, width, imgs[1].rows); //second half of the first image cv::vector<cv::Rect> roi2; roi2.push_back(rect12); roi2.push_back(rect23); cv::Rect rect3 = cvRect(0, 0, width, imgs[2].rows); //first half of the third image cv::vector<cv::Rect> roi3; roi3.push_back(rect3); cv::vector<cv::vector<cv::Rect>> rois; rois.resize(3); rois[0] = roi1; rois[1] = roi2; rois[2] = roi3; //cv::imshow("debug_img1", imgs[0]); Mat tmp1, tmp2, tmp3; cvtColor(imgs[0], tmp1, CV_BGR2GRAY); cvtColor(imgs[1], tmp2, CV_BGR2GRAY); cvtColor(imgs[2], tmp3, CV_BGR2GRAY); /*lensCorrectorBarrel(tmp1.data, tmp1.cols, tmp1.rows); lensCorrectorBarrel(tmp2.data, tmp2.cols, tmp2.rows); lensCorrectorBarrel(tmp3.data, tmp3.cols, tmp3.rows); imwrite("corr1.tif", tmp1); imwrite("corr2.tif", tmp2); imwrite("corr3.tif", tmp3);*/ /*namedWindow( "debug_img_corr1", CV_WINDOW_AUTOSIZE ); namedWindow( "debug_img_corr2", CV_WINDOW_AUTOSIZE ); cv::imshow("debug_img_corr1", tmp1); cv::imshow("debug_img_corr2", tmp2);*/ cvtColor(tmp1, imgs[0], CV_GRAY2BGR); cvtColor(tmp2, imgs[1], CV_GRAY2BGR); cvtColor(tmp3, imgs[2], CV_GRAY2BGR); //char cc = cvWaitKey(0); /*cv::rectangle( imgs[0], rect1, CV_RGB(255,0,0), 1); cv::rectangle( imgs[1], rect12, CV_RGB(255,0,0), 1); cv::rectangle( imgs[1], rect23, CV_RGB(255,0,0), 1); cv::rectangle( imgs[2], rect3, CV_RGB(255,0,0), 1); cv::imshow("debug_img1", imgs[0]); cv::imshow("debug_img2", imgs[1]); cv::imshow("debug_img3", imgs[2]); char c = cvWaitKey(0);*/ Stitcher stitcher = Stitcher::createDefault(false); stitcher.setPanoConfidenceThresh(0.07); stitcher.setWaveCorrection(false); //detail::BestOf2NearestMatcher *matcher = new detail::BestOf2NearestMatcher(false, 0.001/*=match_conf*/); //detail::SurfFeaturesFinder *featureFinder = new detail::SurfFeaturesFinder(100); //stitcher.setFeaturesMatcher(matcher); //stitcher.setFeaturesFinder(featureFinder); Stitcher::Status status = stitcher.stitch(imgs, rois, pano); //Stitcher::Status status = stitcher.composePanorama(imgs, pano); if (status != Stitcher::OK) { cout << "Can't stitch images, error code = " << status << endl; return -1; } imwrite(result_name, pano); char ac = cvWaitKey(0); if(ac == 'ESC') return 0; }
Thank you.
Associated revisions
Merge pull request #3122 from akarsakov:cvtcolor_perf_test_fix
History
Updated by Nikolay Rogoshchenkov over 11 years ago
How can I attach additional files? With good images, for example.
Updated by Alexey Spizhevoy over 11 years ago
There is the 'Files' section available when one is composing a new message.
Updated by Nikolay Rogoshchenkov over 11 years ago
Since archieve with good images > 5MB, you can download it here: http://nikkadim.com/good_images.tar.gz ~6.9MB
Thank you.
Updated by Alexey Spizhevoy over 11 years ago
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.
Updated by Nikolay Rogoshchenkov over 11 years ago
Alexey Spizhevoy wrote:
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.
So, you wanna say, that's order in my example is wrong?
Updated by Alexey Spizhevoy over 11 years ago
If 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.
- Affected version changed from 2.4.5 (latest release) to branch 'master' (2.4.9)
Updated by Nikolay Rogoshchenkov over 11 years ago
This problem.tar.gz archive contains:
- openCV_stitch_three.exe - b1.bmp - b2.bmp - b3.bmp - result.tif
Command line to reproduce:
openCV_stitch_three.exe b1.bmp b2.bmp b3.bmp
In this case we have result.tif with size 158 bytes (header).
Thank you.
- File problem.tar.gz added
Updated by Alexey Spizhevoy over 11 years ago
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.
Updated by Nikolay Rogoshchenkov over 11 years ago
Alexey Spizhevoy wrote:
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.
Failed - you mean you've got error? Or 158 bytes result file?
But problem is the right sequence is b1.bmp b2.bmp b3.bmp, this images from 3 camera in one row.
Updated by Nikita Manovich over 11 years ago
- Status changed from New to Open
Updated by Alexey Spizhevoy over 11 years ago
Failed - you mean you've got error? Or 158 bytes result file?
158 bytes result.
But problem is the right sequence is b1.bmp b2.bmp b3.bmp, this images from 3 camera in one row.
Maybe, but it turns out that b1,b3,b2 are matched better, than b1,b2,b3. The images' texture is very specific.
Updated by Nikolay Rogoshchenkov over 11 years ago
Alexey Spizhevoy wrote:
Failed - you mean you've got error? Or 158 bytes result file?
158 bytes result.
But problem is the right sequence is b1.bmp b2.bmp b3.bmp, this images from 3 camera in one row.
Maybe, but it turns out that b1,b3,b2 are matched better, than b1,b2,b3. The images' texture is very specific.
Ok, is it normal to receive 158 byte file without error from stitching module? Probably not.
Updated by Alexey Spizhevoy over 11 years ago
I've already said before that silent stitching failure is not OK. The pull request is waiting to be merged.
Updated by Nikolay Rogoshchenkov over 11 years ago
Thank you! Sorry, I did not notice that.
This update will be available only in 2.4.9, right?
Updated by Nikolay Rogoshchenkov over 11 years ago
Alexey, i think the problem with 158 bytes size file is more deeper.
I've compiled OpenCV246 with CUDA and TBB support, and wrote a simple program (see attachment) for stitching 6 images.
But each time when I start this program I've got different results:
Each 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).
- File main.cpp added
Updated by Nikolay Rogoshchenkov over 11 years ago
input files available here: http://nikkadim.com/input_imges.zip ~5.5Mb
Updated by Alexey Spizhevoy over 11 years ago
The 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.
As for the new info, do you have the same problem without CUDA support?
Updated by Nikolay Rogoshchenkov over 11 years ago
Alexey Spizhevoy wrote:
As for the new info, do you have the same problem without CUDA support?
Thank you, Alexey!
I 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?
Updated by Alexey Spizhevoy over 11 years ago
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.
Updated by Nikolay Rogoshchenkov over 11 years ago
Alexey Spizhevoy wrote:
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.
If needed I can share the dll's, exe and input files to reproduce the issue.
Also 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.
How can I also help to catch the root of case? May try to play with BestOf2NearestMatcher params?
Thank you, Alexey.
Updated by Nikolay Rogoshchenkov over 11 years ago
any updates?
Updated by Nikolay Rogoshchenkov almost 10 years ago
Same with 2.4.11 for both x86 and x64 arch's.
Resulting pano has size = (1,1), but calculation time about right
Updated by Maksim Shabunin over 9 years ago
Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4591