实战打包OpenCV-Python
打包时解决掉的问题:
- ModuleNotFoundError: No Module named cv2
- ImportError: numpy.core.multiarray failed to import
打包示例源码:
请看文章末尾
版本信息:
opencv-python==4.5.1.48
numpy==1.23.2
Nuitka==0.6.19.1
打包系统:
Windows10 64位
打包前我们需要运行下代码,确保没有报错。
hello.py代码如下:
import cv2 as cv
alpha = 0.5# [load]
src1 = cv.imread(cv.samples.findFile('linux.jpg'))
src2 = cv.imread(cv.samples.findFile('windows.jpg'))
if src1 is None:print("Error loading src1")exit(-1)
elif src2 is None:print("Error loading src2")exit(-1)# [blend_images]
beta = (1.0 - alpha)
dst = cv.addWeighted(src1, alpha, src2, beta, 0.0)# [di