使用python应用程序打包OpenCV [英] Packaging OpenCV with a python app
问题描述
因此,我正在考虑在使用OpenCV的应用程序的开发中使用哪种语言.作为我决定的一部分,我想知道在最终应用程序中包含opencv库有多么容易/困难.我真的很想用python写这个,因为opencv绑定很棒,python很简单,等等.
So I'm contemplating what language to use in the development of an app that uses OpenCV. As a part of my decision, I'm interested in knowing how easy/difficult it is to include the opencv library in the final app. I'd really like to write this in python because the opencv bindings are great, python's easy, etc.
但是我还没有找到明确的答案,例如当py2app看到导入cv行时会自动捆绑opencv"(我认为不是),如果没有,那么有一种已知的方法可以做到这一点?
But I haven't been able to find a clear answer on stuff like "does py2app automatically bundle opencv when it sees the import cv line" (I think not) and if not, then is there a known way to do this?
总的来说,我想知道使用opencv分发python桌面应用程序的最佳方法.
In general, I would like to know the best way to distribute a python desktop app with opencv.
推荐答案
我已经使用cxFreeze和OpenCV有效地打包,部署和交付了Python应用.
I've effectively packaged, deployed, and shipped a Python app using OpenCV with cxFreeze.
http://cx-freeze.sourceforge.net/
是的,cxFreeze自动选择了OpenCV的python扩展.我必须手动复制OpenCV DLL(Windows),但这是一个小问题,可以通过cxFreeze中的后处理步骤解决.它确实会拾取其他DLL,因此我不确定是什么问题.
Yes, cxFreeze auto picked up the python extensions to OpenCV. I had to manually copy the OpenCV DLLs (Windows), but that was a minor issue that can be solved by a post-processing step in cxFreeze. It does pick up other DLL's, so I'm not sure what the issue was.
实际上,它运行得如此之好,令我感到惊讶.唯一无法正确接收的是QT库.基本上,这是我的步骤(我正在使用QT,因此如果您不在,请忽略该部分):
In fact, it worked so well I was surprised. The ONLY thing it didn't pick up properly was a QT library. Basically here were my steps (I'm using QT so ignore that part if you aren't):
- cxfreeze App.py --target-dir应用程序--base-name Win32GUI --include-modules PySide.QtNetwork
- 将opencv \ build \ x86 \ vc9 \ bin文件复制到App目录中.
就是这样.
这篇关于使用python应用程序打包OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!