# Third Eye Demo 步驟 ###### tags: `hscc` `third eye` ## Basic - file location - `Download/celinechiu/darknet` - `Home/jee-oxygen/eclipse` - ipcam address - MAC `00:18:fb:41:0c:b7` - IP `192.168.1.127` - raspberry pi - IP `192.168.1.113 - MAC `B8:27:EB:91:87:D5` - PASSWORD `raspberry` - java version - `javac -version` - javac 1.8.0_181 - `java -version` - openjdk version "1.8.0_181" - tomcate version - `apache-tomcat-7.0.79` - `usr/local/tomcat/apache-tomcat-7.0.79` - python module - numba - `pip install numba` - matplotlib - `pip install matplotlib==2.2.3` - 預設安裝的 3.0.0 不支援 python 2.X - _tkinter - `sudo apt-get install python-tk` - skimage - 要先升級 pip 版本才能成功安裝 - `pip install --upgrade pip` - `sudo pip install scikit-image==0.13.1` - sklearn - `sudo pip install sklearn` - filterpy - `sudo pip install filterpy` - cffi - `sudo pip install cffi` ### 執行 darknet 遇到 ImportError: No module named sort 修改 `.bashrc` ``` sudo nano ~/.bashrc ``` 加入 ``` export PYTHONPATH=$PYTHONPATH:/home/hscc/nctu/HSCC/the-third-eye/darknet/src ``` Reload ``` source ~/.bashrc ``` ### 升級 pip 遇到問題不能查看版本和安裝套件 [pip2安装matplotlib, scikit-image](https://blog.csdn.net/math_computer/article/details/83211380) 修改 `/usr/bin/pip` ``` sudo nano /usr/bin/pip ``` 將 `pip` 改成 `pip._internal` ``` from pip import main from pip._internal import main ``` ## Step - 修改 `indoorMap.java` 中的 59-70 行的 beacon 位置 - 執行 `Hello.java` - 如果發生 port 8080 占用 - `sudo netstat -anp | grep 8080` - 將顯示的 process kill - 成功後會出現 `HTTP Status 404` 的頁面 - 如果沒出現,關掉 eclipse 終端的 Server Tab 重新執行 - SSH 連進 raspberry pi 執行 `PositionClient2.py` - `sudo pyton PositionClinet2.py` - 執行前先去看裡面的 IP 位置是否正確 - line: 24 `serverAddr = "http://192.168.1.105:8080/"` - 如果 Beacon 有任何一顆沒電,都有可能發生錯誤 - 修改 Beacon 的相對位置 - `image.c` (line: 454) - ``` CvPoint2D32f src_coordinate[4] = {cvPoint2D32f(58, 87), cvPoint2D32f(577, 68), cvPoint2D32f(610, 280), cvPoint2D32f(25, 297)}; ``` - 分別對應 - |1(右上)|3(右下)|6(左下)|4(左上)| |:-:|:-:|:-:|:-:| |(100, 120)|(100, 1240)|(540, 1240)|(540, 120)| - ``` CvPoint2D32f dst_coordinate[4] = {cvPoint2D32f(100, 120),cvPoint2D32f(100, 1240),cvPoint2D32f(540, 1240),cvPoint2D32f(540, 120)}; ``` - 進到 `Download/celinechiu/darknet` 執行 darknet - `./darknet detector demo cfg/nctu_delta.data cfg/nctu_delta.cfg weights/nctu_delta_200.weights rtsp://192.168.1.127/medias1 -thresh 0.3` - `./darknet detector demo cfg/nctu_delta.data cfg/nctu_delta.cfg weights/nctu_delta_200.weights rtsp://admin:admin@140.113.86.137:554/medias1 -thresh 0.3` ## 修改 yolo ID fusion.c (line: 176, 178) ``` sprinf(result, "ID:01 hung") sprinf(result, "ID:02 chiu") ``` 資料夾 tag_pic 中的 tag_pic.txt 修改圖片的名稱 ``` unknown.jpg ID:01 hung ID:02 chiu valuable object.JPG ``` ## 建立 Pi - 需要檔案 - PositionClient2.py - blescan.py - 修改 wifi config ``` network={ ssid="OpenWrt" psk="1234567890" key_mgmt=WPA-PSK } ``` - 在 boot 目錄下新增空白文件,命名 `ssh`,之後可以靠 `pi@192.168.1.180` 控制 ``` sudo apt-get install python-bluez # BLE 套件 sudo apt-get install i2c-tools # I2C 套件 ``` - 確認 I2C 位置,查看是否有偵測到 `GY-521` 和 `GY-271` - 1e `GY-271` - 68 `GY-521` ``` sudo ls -al /dev/*i2c* sudo i2cdetect -y 1 ``` ``` 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1e -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- ``` - 修改 ID 和 Server IP - 在 PositionClient2.py 中 ``` ID = "ID=001" serverAddr = "http://192.168.1.118:8080/" ``` ## 加入 Streaming demo.c (line: 242) ``` //show_image(disp, "Demo"); send_mjpeg(disp, 8090, 200, 95); ``` demo.c (line: 277) 這個好像都不會被 call 到,還是拿掉比較保險 ``` //show_image(disp, "Demo"); ``` mjpeg_streaming.h (line: 23) 原本是使用 `darknet.h` 但是因為 third-eye 裡面都把東西移到 `image.h` 裡面 ``` #include "darknet.h" ``` 一定要加 `extern "C"`,不然 cpp 會 call 不到原本 c 裡面定義的 function (not reference to ...) ``` extern "C" { #include "image.h" } ``` Makefile (line: 57) `OBJ= ` 後面加上 `mjpeg_streaming.o` ``` OBJ=mjpeg_streaming.o ``` Makefile (line: 68-74) 將 `gcc` 編譯的地方改成 `g++` `CXX` 在 Makefile (line: 20) 已經有宣告了 `CXX=g++` ``` $(EXEC): $(OBJS) #$(CC) $(COMMON) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(CXX) $(COMMON) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(OBJDIR)%.o: %.cpp $(DEPS) #$(CC) $(COMMON) $(CFLAGS) -c $< -o $@ $(CXX) $(COMMON) $(CFLAGS) -c $< -o $@ ``` ### 遇到的錯誤 如果在 `demo.c` 中加入 `#include "mjpeg_streaming.h"` 會發生錯誤 不加的話 `demo.c` 一樣可以讀到 `send_mjpeg` (???) ``` In file included from ./src/demo.c:18:0: ./src/mjpeg_streaming.h:23:8: error: expected identifier or ‘(’ before string constant extern "C" { ^ compilation terminated due to -Wfatal-errors. Makefile:77: recipe for target 'obj/demo.o' failed make: *** [obj/demo.o] Error 1 ``` ## Yolo 的結果 ``` draw_box_width(im, left, top, right, bot, width, red, green, blue); ``` ``` void draw_box_width(image a, int x1, int y1, int x2, int y2, int w, float r, float g, float b) ``` ## Move to Docker ### Install Java install ``` sudo apt-get update sudo apt-get install default-jre sudo apt-get install default-jdk ``` check OpenJDK version ``` $ java -version openjdk version "1.8.0_181" OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-0ubuntu0.16.04.1-b13) OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode) ``` check JRE version ``` $ javac -version javac 1.8.0_181 ``` ### Install TomCat 7 https://tomcat.apache.org/download-70.cgi https://www.cnblogs.com/EasonJim/p/7202844.html ``` wget http://apache.stu.edu.tw/tomcat/tomcat-7/v7.0.91/bin/apache-tomcat-7.0.91.tar.gz sudo cp apache-tomcat-7.0.91.tar.gz /opt/ cd /opt/ sudo tar zxvf apache-tomcat-8.5.16.tar.gz cd apache-tomcat-7.0.91/ sudo /opt/apache-tomcat-7.0.91/bin/startup.sh ``` 訪問 `127.0.0.1:8080` ``` sudo /opt/apache-tomcat-7.0.91/bin/shutdown.sh ```