如何在Linux设备上编译EZCAP_Qt

1.安装CMAKE (Install CMAKE)

$ sudo apt-get install cmake
$ cmake –version
若使用“cmake –version”命令可以输出版本则说明安装成功。(If you can get the version with “cmake –version” command,it is successful to install.)
2.安装libusb-1.0库 (Install libusb-1.0 library)
$ sudo apt-get update $ sudo apt-get install libusb-1.0-*
3.安装OpenCV库 (Install OpenCV library)
$ unzip opencv-3.4.3.zip
$ cd opencv-3.4.3 $ mkdir build
$ cd build $ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
$ make $ sudo make install
$ sudo nano /etc/ld.so.conf
文本末尾添加“/usr/local/lib”,按下Ctrl + O,回车保存修改,Ctrl + X退出修改(Add “/usr/local/lib” in the text end,push “Ctrl + O” and “Enter” to save modification,and push “Ctrl + X” to exit)
$ sudo ldconfig
注:
1.其他版本的OpenCV也可以,不过旧版本的OpenCV在编译时有可能会遇到因为兼容性而产生的编译问题,可以在OpenCV的官网(https://opencv.org/)或在SourceForge(https://sourceforge.net/)上搜索OpenCV来查看历史版本;
2.OpenCV编译过程比较缓慢,需要耐心等待;
3.如果是在树莓派或其他小型设备上进行编译,由于性能问题可能会导致编译中卡死的问题,此时需要关闭设备重启后重新进行编译;
4.若在小型设备上开发需要注意散热,温度过高会导致性能下降甚至卡死;
Note:
1.You can choose other version OpenCV,but it maybe generate other compile issue because of compatibility,you can find other version OpenCV library on their official website(https://opencv.org/),or search on SourceForge(https://sourceforge.net/).
2.The speed of compiling OpenCV library will a little slow,please wait patiently.
3.If you dp it on RPI or other minitype devic,the device maybe generate system jammed issue because of performance,now,you need power off the device and restart it and continue to compile.
4.If you dp it on RPI or other minitype devic,please pay attention to heat dissipation.
4.安装Qt Creator (Install Qt Creator)
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install qt5-default
$ sudo apt-get install qtcreator
注:
1.若树莓派下执行第一步update时提示404 Not Found,需要修改本机DNS(If system note “404 Not Found” issue when execute “sudo apt-get update” on RPI,you need modify device DNS),
$ sudo nano /etc/resolv.conf
修改127.0.1.1为8.8.8.8,Ctrl + O,回车保存修改,Ctrl + X退出修改(Modify 127.0.1.1 to 8.8.8.8,push “Ctrl + O” and “Enter” to save modification,and push “Ctrl + X” to exit)
$ service network restart
2.多数情况下Qt Creator安装好后会自动配置好编译器套件,不过有时也会发生编译套件未配置或配置出错的情况,需要手动检查一下,检查方法如下(In most cases,Qt Creator will auto configure compile kits after install,but somtimes,an unconfigured or misconfigured build suite will occurs,so you need check it by yourself,the method of check as follow ):
$ sudo qtcreator
程序运行起来之后点击工具(Tools)-> 选项(Options)-> 编译套件(Kits),查看编译套件是否有错误提示,如果有请按照如下步骤配置编译套件(After Qt Creator has been run,click Tools->Options->Kits,check if the kits has error note,if has error,please configure kits as follow),
1.设置编译器:点击添加选择MinGW,选择g++编译器的路径,ABI选择arm-linux-guneabihf-elf(Setup compiler:click Add and select MinGW,choose teh path of g++ compiler,ABI choose arm-linux-gnueabihf-elf);

2.设置编译套件:编译器选择刚才设置好的MinGW,选择调试器(Setup compile kits:choose the MinGW you setuped just now to be compiler,and choose debuger);

5.下载并安装QHYCCD SDK(Download and Install QHYCCD SDK)

请根据自己使用的Linux版本下载对应版本的SDK,可以通过”uname -a”命令查看所使用的Linux版本(Please download the corresponding version of the SDK according to the Linux version you are using. You can check the Linux version used by the “uname -a” command.),
若结果为x86_32,则对应Linux (If the result is x86_32, it corresponds to Linux);
若结果为x86_64,则对应Linux_x64 (If the result is x86_64, it corresponds to Linux_x64);
若结果为armv7l,则对应RPI3 (If the result is armv7l, it corresponds to RPI3);
若结果为aarch64,则对应AARCH64 (If the result is aarch64, it corresponds to AARCH64)。
此次以armhf为例(This time with armhf as an example),
$ tar -xvf RPI3_qhyccd_V20191115_0.tgz
$ cd RPI3_qhyccd_V20191115_0
$ chmod 777 *.sh
$ sudo ./install.sh
6.下载EZCAP_Qt源码并编译(Download EZCAP_Qt source code and compile it)
$ unzip EZCAP_QT.zip
$ sudo qtcreator
Qt Creator程序运行起来之后需要进行以下操作(After running the Qt Creator program, you need to do the following):

6.1 点击文件(File)->打开文件或项目(Open File or Project),进入刚才解压得到的EZCAP_QT目录,找到EZCAP.pro文件并打开(Click File->Open File or Project,enter the EZCAP_QT directory that was just extracted)

6.2 选择编译套件,点击Configure Project按钮(Select the build suite and click the Configure Project button)

6.3 打开并修改EZCAP.pro文件(Open and modify EZCAP.pro file)

修改说明:

1.INCLUDEPATH是头文件的所在位置,QHYCCD SDK和OpenCV的头文件安装后会保存到/usr/local/include目录下;libusb-1.0的头文件需要通过”sudo find / -name libusb.h”来查找文件所在位置并做相应修改。
2.LIBS是库文件的所在位置,QHYCCD SDK和OpenCV的库文件都安装在”/usr/local/lib”目录中,cfitsio和libusb-1.0的库文件所在位置会保存在系统库目录下,
armv7l的路径是/usr/lib/arm-linux-gnueabihf;
aarch64的路径是/usr/lib/aarch64-linux-gnu;
x86_32的路径是/usr/lib/x86_32-linux-gnu;
x86_64的路径是/usr/lib/x86_64-linux-gnu;
需要根据实际情况做相应修改,上图以armv7l为示例,若是aarch64设备需要修改为”LIBS += /usr/lib/aarch64-linux-gnu -lusb-1.0 -lcfitsio”。
The description of modification:
1.INCLUDEPATH is the location of the header files. The header files of QHYCCD SDK and OpenCV will be saved to the /usr/local/ include directory after installation; the header files of libusb-1.0 need to be passed “sudo find / -name libusb.h”. Find the location of the file and modify it accordingly.
2. LIBS is the location of the library files. Both the QHYCCD SDK and OpenCV library files are installed in the “/usr/local/lib” directory. The locations of the cfitsio and libusb-1.0 library files are stored in the system library directory.
The path of armv7l is /usr/lib/arm-linux-gnueabihf;
the path of aarch64 is / usr / lib / aarch64-linux-gnu;
The path of x86_32 is / usr / lib / x86_32-linux-gnu;
The path of x86_64 is / usr / lib / x86_64-linux-gnu;
You need to modify it according to the actual situation. The above picture uses armv7l as an example. If it is an aarch64 device, you need to modify it to “LIBS + = / usr / lib / aarch64-linux-gnu -lusb-1.0 -lcfitsio”.

6.4 按照下图修改qhyccdStatus.h、main.cpp和myStruct.h三个文件,修改好后在左下角选择Release模式,点击编译按钮开始编译(Modify the three files qhyccdStatus.h, main.cpp and myStruct.h according to the following figure. After modification, select Release mode in the lower left corner and click the compile button to start compiling)

6.5 编译成功(Compile successfully)