在 Python 虚拟环境中的 IC Imaging Control 4
本文介绍如何在 Linux 系统中的 Python 虚拟环境(venv)中使用 IC Imaging Control 4 和 IC 4 GenTL Producer。建议额外阅读《Python 虚拟环境与包》(Python Virtual Environments and Packages)相关内容。
在创建虚拟环境之前,请先从 https://www.theimagingsource.com 安装对应的 IC 4 GenTL Producer。下载的安装包通常会复制到"Downloads"(下载)文件夹中。
cd ~/Downloads
sudo apt install ./ic4-gentl-driver-....deb
安装 IC 4 GenTL Producer 之后,即可创建虚拟环境。在本示例中,虚拟环境是直接在用户文件夹下创建的,因此使用了 "cd ~" 命令。
cd ~
python -m venv ./ic4-test
"ic4-test"目录必须尚不存在。该目录会被自动创建。
新的虚拟环境通过以下命令行来激活:
source ./ic4-test/bin/activate
现在,终端提示符前面会显示虚拟环境目录的名称。此处为"(ic4.test)"。
安装 IC 4:
pip3 install imagingcontrol4
安装 IC 4 示例程序:
git clone https://github.com/TheImagingSource/ic4-examples.git
运行 IC 4 Python 演示应用程序:
Qt6 演示应用程序示例可能需要 libxcb-cursor0 软件包。该软件包可通过以下命令安装:
sudo apt install libxcb-cursor0
Demoapp 脚本位于 "ic4-examples/python/qt6/demoapp" 目录中
cd ic4-examples/python/qt6/demoapp
该文件夹中包含 'requirements.txt' 文件,该文件用于安装演示应用程序所需但尚未安装的所有软件包:
pip install -r requirements.txt
现在,按如下方式启动演示应用程序:
python demoapp.py
如有其他问题,请使用我们的contact form。