I am exporting C++ API for python code using Cython. The application will be executed on Ubuntu. The project files are present here
The function I am wrapping, reads the file name of the image and displays the image. The Show_Img.pyx file looks as follows
import cv2
cdef public void Print_image(char* name):
img = cv2.imread(name)
cv2.imshow("Image", img)
while(True):
if cv2.waitKey(1) & 0xFF == ord('q'):
break
The c++ interface generated from Cython looks as follows
__PYX_EXTERN_C DL_IMPORT(void) Print_image(char *);
The header file is included in my algo.cpp, which calls the function like below
#include<iostream>
#include<Python.h>
#include"Show_Img.h"
using namespace std;
int main(){
char *name = "face.jpg";
Py_Initialize();
Print_image(name);
Py_Finalize();
return 0;
}
With the command below, I can also compile the above code and also generate the application
g++ algo.cpp `pkg-config --libs --cflags python-2.7` `pkg-config --libs --cflags opencv` -L. -lShow_Img -o algo
also the path to the library LD_LIBRARY_PATH is set correctly
Upon execution of the application, there is an error Segmentation fault (core dumped)
Why am I unable to execute the application, is there a mistake in the generation process? or Library linking?
import cv2) won't get run.