Ask Your Question
0

Preparing OpenCL cache Configuration

asked 2017-12-21 04:30:44 -0600

Raki gravatar image

updated 2017-12-21 06:07:33 -0600

berak gravatar image

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 flag offensive close merge delete

Comments

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

Eduardo gravatar imageEduardo ( 2017-12-21 05:18:46 -0600 )edit

error C3861: 'setUseOpenCL': identifier not found

Raki gravatar imageRaki ( 2017-12-21 05:30:34 -0600 )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 !

berak gravatar imageberak ( 2017-12-21 05:34:52 -0600 )edit

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

Raki gravatar imageRaki ( 2017-12-21 05:43:22 -0600 )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.

Raki gravatar imageRaki ( 2017-12-21 05:50:31 -0600 )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)

berak gravatar imageberak ( 2017-12-21 06:00:10 -0600 )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.

Raki gravatar imageRaki ( 2017-12-21 06:08:32 -0600 )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.

Raki gravatar imageRaki ( 2018-01-05 05:17:24 -0600 )edit

@berak where can we send a ticket about this? The problem persists...

Raki gravatar imageRaki ( 2018-01-05 05:59:18 -0600 )edit
1

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-01-08 01:19:13 -0600

Raki gravatar image

updated 2018-01-08 01:22:09 -0600

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)
    {
        // read the images
        cv::Mat img = cv::imread(filenames[i]);

        // give error if they are not found
        if (!img.data)
        {
            std::cerr << "Problem loading image. Path can be wrong." << std::endl;
            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.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-12-21 04:30:44 -0600

Seen: 2,526 times

Last updated: Jan 08 '18