I am trying to call image display code of python from C using cython.
I had followed the procedure for creating .c and .h from .pyx and adding these into the C code in visual studio.
I had checked the python version on command prompt and it is Python 3.6.3 |Anaconda custom (64-bit). I am able to import cv2 there on command prompt.
But when I call this .c and .h file into C code I am getting error
NameError: name 'cv2' is not defined
Exception ignored in: 'read.readImage'
NameError: name 'cv2' is not defined
I had checked for python path is set in the environment. Still I am getting the error.
The code for read.pyx is
import numpy as np
import cv2
cdef public void readImage():
img = cv2.imread('dog.jpeg')
print('reading')
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
The code for souce.cpp in visual studio is
#include "Python.h"
# include "read.h"
using namespace cv;
int main(void) {
Py_Initialize();
PyInit_read();
readImage();
Py_Finalize();
return 0;
}
import sys; print(sys.path)in your python installation and in the standalone exe. I wouldn’t be surprised if they differ. You said the python path is set, to which value?