# Preparing OpenCL cache Configuration

Hi,

I am trying to get the Image Stitching code running on my VS2013. Everything compiles and builds successfully and I am passing the parameters correctly as well. The code runs and I am given the following terminal, which hangs (or at least does not go on, even if it does some processing) for a while.

[INFO:0] Initialize OpenCL runtiime...
[INFO:0] Successfully initialized OpenCL cache directory: C:\Users\username\AppData\Local\Temp\opencv\3.4.0-rc\opencl-cache
[INFO:0] Preparing OpenCL cache configuration for context: NVIDIA_Corporation--GeForce_GTX_660_Ti--388_19


I turned the GPU option off and it still does the same. I am wondering what could be the reason, and the first thing came to my mind was that I include the libraries from CUDA, which may cause a problem maybe? I could try to run this example with the minimum requirements and see if it does the same. Perhaps some can tell me what libraries need to be included to run this code? (Not sure if this is a solution, just brainstorming at the moment.)

UPDATE:

Adding the false flag also did not work.

[ INFO:2] Initialize OpenCL runtime...
[ INFO:5] Initialize OpenCL runtime...
[ INFO:1] Initialize OpenCL runtime...
[ INFO:7] Initialize OpenCL runtime...
[ INFO:3] Initialize OpenCL runtime...
[ INFO:6] Initialize OpenCL runtime...
[ INFO:8] Initialize OpenCL runtime...
[ INFO:4] Initialize OpenCL runtime...
[ INFO:9] Initialize OpenCL runtime...
[ INFO:10] Initialize OpenCL runtime...
[ INFO:11] Initialize OpenCL runtime...
[ INFO:2] Successfully initialized OpenCL cache directory: C:\Users\username\AppData\Local\Temp\opencv\3.4.0-rc\opencl_cache\
[ INFO:2] Preparing OpenCL cache configuration for context: NVIDIA_Corporation--GeForce_GTX_660_Ti--388_19

edit retag close merge delete

Can you try to add cv::setUseOpenCL(false) at the beginning of the program?

( 2017-12-21 05:18:46 -0500 )edit

( 2017-12-21 05:30:34 -0500 )edit

cv::ocl::setUseOpenCL(false); also #include "opencv2/core/ocl.hpp"

but again, those are just info messages. annoying, but entirely harmless.

(i'm getting those, too, from various programs.)

nonetheless, would you be so nice, to replace the screenshot with a TEXT version, so folks here can quote it, it can be properly indexed for search, etc. ? thank you !

( 2017-12-21 05:34:52 -0500 )edit

Getting the same messages, not doing a damn thing, it really is annoying. I uploaded the output again.

( 2017-12-21 05:43:22 -0500 )edit
1

@berak I did not see the comment of yours before (I guess there was an editing). Of course, I can make them text.

( 2017-12-21 05:50:31 -0500 )edit
1

@Raki, this seems to be work in progress

(was just starting to write an issue there (i think, it's super annoying, too !) , but now i think: let the dust settle with the devs a bit.)

in the meantime, you could just "hack it" locally, and just change core/utils/logger.hpp, line 54 to:

#   define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_INFO


(needs a rebuild, though)

( 2017-12-21 06:00:10 -0500 )edit

Thanks for the update @berak. I did not know that it was being worked on. I guess I'll rather wait because I do not really want to rebuild my OpenCV again. Nevertheless thanks for the effort.

( 2017-12-21 06:08:32 -0500 )edit

@berak Is it still in progress? When will I be able to run my code? It is a bit strange that such an important feature of OpenCV does not work.

( 2018-01-05 05:17:24 -0500 )edit

( 2018-01-05 05:59:18 -0500 )edit
1

Sort by » oldest newest most voted

So, I re-installed OpenCV since the relevant ticket appeared to be solved. After the installation, I ran the below code (it is just the trimmed version of the original code, it does the same thing) and after approximately 10 seconds the program gave an output (stitched image).

#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/stitching.hpp"
#include <iostream>

// a global container to hold the image parts in, which are gonna be stitched later
std::vector<cv::Mat> imageParts;

/*
User defined function that imitates system("pause") behavior.
*/
void pause()
{
do {
std::cout << '\n' << "Press the Enter key to continue.";
} while (std::cin.get() != '\n');

return;
}

int main()
{
// check if the images were passed (using opencv's String class)
cv::String folderPath("imageParts/*.png"); //select only .png files
std::vector<cv::String> filenames;

cv::glob(folderPath, filenames, true); // a function that forms a valid path out of the above two

for (size_t i = 0; i < filenames.size(); ++i)
{

if (!img.data)
{
return -1;
}

// divide each into three sub images, so that the chances of success are higher
cv::Rect rect(0, 0, img.cols / 2, img.rows);
imageParts.push_back(img(rect).clone());
rect.x = img.cols / 3;
imageParts.push_back(img(rect).clone());
rect.x = img.cols / 2;
imageParts.push_back(img(rect).clone());
}

// conduct stitching
cv::Mat stitchedImage;
cv::Ptr<cv::Stitcher> stitcher = cv::Stitcher::create(cv::Stitcher::SCANS, false); //use gpu = false
cv::Stitcher::Status status = stitcher->stitch(imageParts, stitchedImage);

if (status != cv::Stitcher::OK)
{
std::cout << "Can't stitch images, error code = " << int(status) << std::endl;
return -1;
}

// write it on the disk and inform the user
cv::imwrite("stitchedImage.jpg", stitchedImage);
std::cout << "stitching completed successfully\n" << "stitchedHDD.jpg" << " saved!";

// hang the console
pause();

return 0;
}


It is important to use a function that hangs the console (like system("pause") kind of mechanism), because otherwise it closes it abruptly and you may think it did not stitch anything.

Another important point is to not to use gpu, since it never worked for me, saying that CUDA has not implemented this functionality yet.

So, I hereby confirm that the issue has been solved by OpenCV.

more

Official site

GitHub

Wiki

Documentation