Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to get context in opencv ocl?

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;
        context_ocl = cv::ocl::Context::getContext();
    catch (cv::Exception e){
        std::cout << e.msg << std::endl;
    catch (...){
        std::cout << "Exception" << std::endl;
    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