I want to write some Python code in my c++ Visual Studio project. I added Pythons include and lib path and everything works fine so far. I can run Python and c++ code in one project.
Problem comes now: I also want to use opencv. I added the include and lib path and get a error running my example code.
Exception thrown at 0x00007FFA5FC7A99B (ucrtbased.dll) in Project 3.exe: 0xC0000005: Access violation reading location 0x000067706A2E6369.
For me it seems like the python38.dll and world430.dll stay in some conflic together, but Im really more a beginner in the coding world.
I tried to run the programm without the python code and without its include and lib path - is working. I tried to run the programm without the opencv code and without its include and lib path - is working.
Only when I put this things together this Debug-error appears.
Any ideas why this happens and how I could fix that?
My code is here, I marked the point where the error appears. When I put the opencv corresponding code at the end, the programm runs to same cv line and throws the error.
#include <stdio.h>
#include <conio.h>
#include <Python.h>
#include <iostream>
#include<opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat img = imread("examplepic.jpg"); //Error occuring here
namedWindow("image", WINDOW_NORMAL);
imshow("image", img);
waitKey(0);
PyObject* pInt;
Py_Initialize();
PyRun_SimpleString("print('Hello World - python')");
Py_Finalize();
cout << "Hello world!" << endl;
printf("\nPress any key to exit...\n");
if (!_getch()) _getch();
return 0;
}
User contributions licensed under CC BY-SA 3.0