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;
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:
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)
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