Ask Your Question

Anthony Huggett's profile - activity

2017-03-10 02:04:05 -0600 received badge  Editor (source)
2017-03-10 02:02:00 -0600 commented question OpenCL access violation with x64/MSVC2015

Updating the graphics driver has cured the problem. Thanks to LBerger for pointing me in the right direction.

2017-03-10 01:40:49 -0600 commented question OpenCL access violation with x64/MSVC2015

Intel(R) HD Graphics 530 (on a Dell Precision 7510 laptop). Dell may have used a custom variant for them.

2017-03-09 04:56:55 -0600 asked a question OpenCL access violation with x64/MSVC2015

I'm a new user of openCV. Having built the .dlls on MSVC2015, targeting x64, I get the following error when trying to run a test program QuickView.exe.

#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
    if (argc != 2)
    {
        cout << " Usage: display_image ImageToLoadAndDisplay" << endl;
        return -1;
    }
Mat image;
image = imread(argv[1], IMREAD_COLOR); // Read the file

if (image.empty()) // Check for invalid input
{
    cout << "Could not open or find the image" << std::endl;
    return -1;
}

namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
imshow("Display window", image); // Show our image inside it.

waitKey(0); // Wait for a keystroke in the window
return 0;

}

The error I get is exception thrown at 0x000007FEDD58A32A (igdrcl64.dll) in QuickView.exe: 0xC0000005: Access violation reading location 0x0000000000000990.

I can apparently continue past the error with no ill effects.

The call stack is (with apologies for the line length)

igdrcl64.dll!000007feded1a32a() Unknown

igdrcl64.dll!000007feded17f4b() Unknown

igdrcl64.dll!000007fededa6567() Unknown

igdrcl64.dll!000007fededa227e() Unknown

igdrcl64.dll!000007fededa2447() Unknown

ntdll.dll!0000000077bf0dc2()    Unknown

ntdll.dll!0000000077bf21ba()    Unknown

KernelBase.dll!000007fefdccaa85()   Unknown

IntelOpenCL64.dll!000007fee23810bf()    Unknown

IntelOpenCL64.dll!000007fee236110b()    Unknown

OpenCL.dll!000007fee3b810cc()   Unknown

OpenCL.dll!000007fee3b83437()   Unknown

[External Code] 

OpenCL.dll!000007fee3b82d8c()   Unknown

opencv_core320d.dll!OPENCL_FN_clGetPlatformIDs_switch_fn(unsigned int p1, _cl_platform_id * * p2, unsigned int * p3) Line 466   C++

opencv_core320d.dll!cv::ocl::haveOpenCL() Line 1472 C++

opencv_core320d.dll!cv::ocl::useOpenCL() Line 1493  C++

opencv_core320d.dll!cv::flip(const cv::_InputArray & _src, const cv::_OutputArray & _dst, int flip_mode) Line 809   C++

opencv_core320d.dll!cvFlip(const void * srcarr, void * dstarr, int flip_mode) Line 1469 C++

opencv_imgcodecs320d.dll!cvConvertImage(const void * srcarr, void * dstarr, int flags) Line 679 C++

opencv_highgui320d.dll!cvShowImage(const char * name, const void * arr) Line 1158   C++

opencv_highgui320d.dll!cv::imshow(const cv::String & winname, const cv::_InputArray & _img) Line 308    C++

QuickView.exe!main(int argc, char * * argv) Line 27 C++

Obviously imshow is calling something deep within OpenCL that is giving a problem. The workarounds I have successfully tested are to compile OpenCV without OpenCL support (comment out line 124 in cvconfig.h), or to switch off Win32 Access Violation catching. However, neither of these seem very satisfactory. Can anyone suggest a proper remedy, please?

2017-03-08 04:41:10 -0600 answered a question Exception thrown at 0x000007FEFDB49E5D in CVpro1.exe: Microsoft C++ exception: cv::Exception at memory location 0x000000000023F320.

I'm seeing a similar problem on MSVC 2015, running the image viewer test code:

#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
    if (argc != 2)
    {
        cout << " Usage: display_image ImageToLoadAndDisplay" << endl;
        return -1;
    }

    Mat image;
    image = imread(argv[1], IMREAD_COLOR); // Read the file

    if (image.empty()) // Check for invalid input
    {
        cout << "Could not open or find the image" << std::endl;
        return -1;
    }

    namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
    imshow("Display window", image); // Show our image inside it.

    waitKey(0); // Wait for a keystroke in the window
    return 0;
}

I'm building my own OpenCV libraries for x64.

I get an exception when I run under the MSVC debugger. It seems to be in the initialization before any of the main code is executed. However, I can continue past it without any apparent problems. The program also runs fine under Windows CMD shell.

Looking at the stack when the exception is thrown, it is a call to OpenCL: opencl_fn3(OPENCL_FN_clGetPlatformIDs, cl_int, (cl_uint p1, cl_platform_id* p2, cl_uint* p3))

One solution I've tested is to disable OpenCL (comment out line 124 of cvconfig.h) and rebuild the libraries. This avoids the call that is causing the problem, but is unsatisfactory because one loses the power of openCL.

Another workaround is to disable the Win32 access violation exception from being caught by the debugger. (When I see the exception it opens an "Exception Settings" window which allows me to select the kinds of exceptions that MSVC breaks for). However, disabling exceptions like this feels unsafe to me.

However, neither of these feels like a permanent solution. Maybe someone with deeper MSVC/OpenCV/OpenCL knowledge can sort it out - I'm a complete newbie to OpenCV.