使用pyinstaller将python程序转换为Windows可执行文件

时间:2018-09-21 19:55:20

标签: python pyinstaller opencv3.0

我无法使用pyinstaller将以下python代码转换为Windows可执行文件。 Python代码在python 2.7和python 3.6上运行良好。我已经从github / pyinstaller / pyinstaller / archive / develop.tae.gz安装了pyinstaller

import cv2 
import os
import inspect
import os.path

filename = inspect.getframeinfo(inspect.currentframe()).filename
path     = os.path.dirname(os.path.abspath(filename))

os.chdir(path)
id = open('Emp.txt', 'r').read()
writePath = "./Images/"

faceCascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
cam = cv2.VideoCapture(0)

sampleNum = 0

while(True):
    # Capture frame by frame
    ret, frame = cam.read()
    #frame = np.full((100,80,3), 12, dtype = np.uint8)
    grayFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    faces = faceCascade.detectMultiScale(grayFrame,scaleFactor=1.5, minNeighbors=5)
    for (x,y,w,h) in faces:
        sampleNum = sampleNum + 1
        cv2.imwrite(writePath + str(id) + "." +str(sampleNum) + ".jpg", grayFrame[y:y+h,x:x+w])

        color = (255,0,0)
        thickness = 2
        cv2.rectangle(frame,(x,y),(x+w, y+h),color, thickness)
    cv2.imshow ("frame",frame)
    cv2.waitKey(2)
    if (sampleNum > 5):
        break

cam.release()
cv2.destroyAllWindows() 

0 个答案:

没有答案