1

我正在尝试创建一个使用 opencv 作为后端的 python 应用程序,当我尝试使用 导出应用程序时会出现问题pyinstaller,事实上,即使我使用的 cv2 功能很少:

from cv2 import normalize, cvtColor, applyColorMap, imread, NORM_MINMAX, COLORMAP_JET, COLOR_BGR2RGB

每次我“pyinstall”脚本时,生成的文件夹都会很大(> 100mb)。这是因为pyinstaller导入了整个 opencv 库:

libopencv_aruco.so.3.3        libopencv_dnn.so.3.3         libopencv_hdf.so.3.3        libopencv_objdetect.so.3.3         libopencv_rgbd.so.3.3              libopencv_text.so.3.3         libopencv_xphoto.so.3.3
libopencv_bgsegm.so.3.3       libopencv_face.so.3.3        libopencv_highgui.so.3.3    libopencv_optflow.so.3.3           libopencv_saliency.so.3.3          libopencv_tracking.so.3.3     cv2.so
libopencv_bioinspired.so.3.3  libopencv_features2d.so.3.3  libopencv_imgcodecs.so.3.3  libopencv_phase_unwrapping.so.3.3  libopencv_shape.so.3.3             libopencv_videoio.so.3.3
libopencv_calib3d.so.3.3      libopencv_flann.so.3.3       libopencv_img_hash.so.3.3   libopencv_photo.so.3.3             libopencv_stitching.so.3.3         libopencv_video.so.3.3
libopencv_ccalib.so.3.3       libopencv_freetype.so.3.3    libopencv_imgproc.so.3.3    libopencv_plot.so.3.3              libopencv_structured_light.so.3.3  libopencv_xfeatures2d.so.3.3
libopencv_core.so.3.3         libopencv_fuzzy.so.3.3       libopencv_ml.so.3.3         libopencv_reg.so.3.3               libopencv_surface_matching.so.3.3  libopencv_ximgproc.so.3.3

我使用的 cv2 组件很少,是否可以只导入所需的组件?我已经尝试手动导入共享库,但它当然不起作用,因为它们没有init函数:

ImportError: dynamic module does not define init function (init__main__)

任何会减少我的可交付成果大小的解决方案将不胜感激。

4

0 回答 0