如何在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)