How to get context in opencv ocl?

asked 2018-05-08 11:04:41 -0600

Brainabilgh gravatar image

I am trying to run my first program using OpenCV::ocl version 2.4.11 without success. I have an exception when calling cv::ocl::Context::getContext():

#include <opencv2/ocl/ocl.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <opencv2/nonfree/ocl.hpp>
#include <opencv2/nonfree/gpu.hpp>

int main(int argc, char *argv[])
{
    cv::ocl::Context *context_ocl;
    try{
        context_ocl = cv::ocl::Context::getContext();
    }
    catch (cv::Exception e){
        std::cout << e.msg << std::endl;
    }
    catch (...){
        std::cout << "Exception" << std::endl;
    }
    std::getchar();
    return 0;
}

The try-catch statement cannot catch the exception, so I don't know where is the problem. I used to use OpenCV without issues, so I think it's built properly. Here is my Visual Studio 2013 linker input:

my list of links

edit retag flag offensive close merge delete

Comments

Another thing, when I try to declare a PlatformInfo like this: cv::ocl::PlatformInfo platformInfo; I get error LNK2019: Unresolved external symbol ... cv::ocl::PlatformInfo::~PlatformInfo(void)

Brainabilgh gravatar imageBrainabilgh ( 2018-05-08 11:05:39 -0600 )edit
1

please do not use opencv 2.4 for this. it is a 4 years old maintenance release.

try again with current 3.4.1, and updated code

berak gravatar imageberak ( 2018-05-08 11:09:04 -0600 )edit