0

I am using OpenCV with VC++. The function is doing what it ought do but throwing an exception which is causing access violation in reading a location and refers to ntdll.dll. What would I missing for being unable to handle the exception when the code is doing what it should do ?

void cl::first()
{
  Mat a=imread("C:\\1.jpg");
  Mat b;
  cvtColor(a,b,CV_RGB2BGR);
  imwrite("C:\\2.jpg",b);
  return ;
}

Exception

First-chance exception at 0x77551e86 (ntdll.dll) in app.exe: 0xC0000005: 
Access violation reading location 0x43819ccc. Unhandled exception at 0x77551e86 (ntdll.dll) 
in app.exe: 0xC0000005: Access violation reading location 0x43819ccc. 
The program '[4500] app.exe: Native' has exited with code -1073741819 (0xc0000005).
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
user1638698
  • 1
  • 1
  • 2
  • Duplicate: http://stackoverflow.com/questions/2623163/opencv-2-0-c-api-using-imshow-returns-unhandled-exception-and-bad-flag – ArtemStorozhuk Aug 31 '12 at 18:26

1 Answers1

1

I had the same error, check your environment variables in

control panel->system-> advanced system settings->environment variables->path

to ensure opencv bin path is added to the environment 'path', then restart your computer.

That should work

Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
  • @petter-friberg I take it you deleted my comment? I would like to point out, that in my case, I did not do any changes to the path variable, I simply restarted the machine and then the error was gone. – N4ppeL Apr 11 '17 at 15:55
  • @N4ppeL I actually only custom mod flagged it to remove the first part (the swearing), but since the system considered it not useful it got deleted with that single flag. Sorry but try to keep all comments professional and there is no need for anyone to clean'em up. – Petter Friberg Apr 11 '17 at 18:00