1

I am attempting to launch a python file from a c# program using Iron python but i am getting the error ironpython.runtime.exceptions.importexception{"No module named numpy"} although the python file does import numpy

c# code:

private void btnStartPython_Click(object sender, EventArgs e)
    {
        ScriptEngine engine = Python.CreateEngine();
         engine.ExecuteFile(@"C:\Users\matth\Desktop\testmctest.py");
    }

python code:

import numpy 
import cv2
import dlib

PREDICTOR_PATH = "C:/Python27/shape_predictor_68_face_landmarks.dat"
predictor = dlib.shape_predictor(PREDICTOR_PATH)
cascade_path='C:/Users/matth/Source/Repos/CLM-   
framework/lib/3rdParty/OpenCV3.0/classifiers
/haarcascade_frontalface_default.xml'
cascade = cv2.CascadeClassifier(cascade_path)


def get_landmarks(im):
rects = cascade.detectMultiScale(im, 1.3,5)
x,y,w,h =rects[0]
rect=dlib.rectangle(x,y,x+w,y+h)
return numpy.matrix([[p.x, p.y] for p in predictor(im, rect).parts()])

def annotate_landmarks(im, landmarks):
im = im.copy()
for idx, point in enumerate(landmarks):
    pos = (point[0, 0], point[0, 1])
    cv2.putText(im, str(idx), pos,
                fontFace=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX,
                fontScale=0.4,
                color=(0, 0, 255))
    cv2.circle(im, pos, 3, color=(0, 255, 255))
return im

im=cv2.imread('fk.jpg')
cv2.imshow('Result',annotate_landmarks(im,get_landmarks(im)))
cv2.waitKey(0)
cv2.destroyAllWindows()
the pro-gramer
  • 37
  • 2
  • 10
  • I'm guessing you installed `numpy` through pip and not through iron python. https://stackoverflow.com/questions/29397540/how-to-install-numpy-and-scipy-for-ironpython27-old-method-doenst-work – Chrispresso Apr 05 '18 at 17:22

0 Answers0