I am exporting a C ++ API for python code using Cython. The application will run on Ubuntu. Project files are here
The function that I am wrapping reads the image file name and displays the image. The file is Show_Img.pyxas 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 created from Cython is as follows
__PYX_EXTERN_C DL_IMPORT(void) Print_image(char *);
The header file is included in mine algo.cpp, which calls the function as shown 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;
}
Using the command below, I can also compile the above code as well as generate the application
g++ algo.cpp `pkg-config --libs --cflags python-2.7` `pkg-config --libs --cflags opencv` -L. -lShow_Img -o algo
library path is also set correctly LD_LIBRARY_PATH
An error occurs after running the application Segmentation fault (core dumped)
Why can't I run the application, is there an error in the generation process? or library linking?