Update SmartThings APIs for Tizen 5.0
[apps/native/smart-surveillance-camera.git] / README.md
1 # IoT Vision App
2 Analyze images captured by USB camera and then move camera angle by using servo motors.
3
4 ## HOW TO RUN - First run
5
6 ### 1. Flash binary
7 Tizen 5.0 M2 IoT 부트 이미지 다운로드 [[링크](http://download.tizen.org/releases/milestone/tizen/unified/tizen-unified_20181024.1/images/standard/iot-boot-armv7l-artik533s/)]
8
9 Tizen 5.0 M2 Iot Headed 이미지 다운로드 [[링크](http://download.tizen.org/releases/milestone/tizen/unified/tizen-unified_20181024.1/images/standard/iot-headed-3parts-armv7l-artik530_710/)]
10 ```
11 sudo minicom
12     thordown
13 lthor tizen-unified_20181024.1_iot-boot-armv7l-artik533s.tar.gz tizen-unified_20181024.1_iot-headed-3parts-armv7l-artik530_710.tar.gz
14 ```
15
16 ### 2. Install plug-in
17
18 ARTIK 530(5.0) Plugin download from https://developer.samsung.com/tizendevice/firmware
19
20
21 ### 3. Install Wifi util (*optional)
22 Tizen 5.0 M2 wifi-manager-tool 다운로드 [[링크](http://download.tizen.org/releases/milestone/tizen/unified/tizen-unified_20181024.1/repos/standard/packages/armv7l/capi-network-wifi-manager-tool-1.0.39-81.5.armv7l.rpm)]
23 ```
24 sdb root on; sdb shell 'mount -o remount,rw /'
25
26 sdb push capi-network-wifi-manager-tool-1.0.39-81.5.armv7l.rpm /tmp
27
28 sdb shell 'rpm -ivh /tmp/capi-network-wifi-manager-tool-1.0.39-81.5.armv7l.rpm'
29 ```
30
31 ### 4. Build and install custom version of IoT.js to include WebSocket feature
32 ```
33 git clone https://github.com/Samsung/iotjs.git
34
35 cd iotjs
36
37 sed -i 's/Release: 0/Release: 99/' config/tizen/packaging/iotjs.spec
38
39 sed -i '/--no-parallel-build/a \ \ --cmake-param=-DENABLE_MODULE_WEBSOCKET=ON \\' config/tizen/packaging/iotjs.spec
40
41 git diff config/tizen/packaging/iotjs.spec
42
43 ./config/tizen/gbsbuild.sh --clean
44
45 sdb push ~/GBS-ROOT/local/repos/tizen_unified_m1/armv7l/RPMS/iotjs-1.0.0-9.0.armv7l.rpm /tmp
46
47 sdb shell 'cd /tmp; rpm -ivh iotjs-1.0.0-9.0.armv7l.rpm'
48 ```
49 - https://github.com/Samsung/iotjs/wiki/Build-for-RPi3-Tizen
50 - https://github.com/Samsung/iotjs/blob/master/docs/api/IoT.js-API-WebSocket.md
51
52
53 ### 5. Change camera setting
54 ```
55 sdb shell "cat /etc/multimedia/mmfw_camcorder_camera0.ini | grep 640"
56
57 sdb shell "sed -i 's/640,480/320,240/g' /etc/multimedia/mmfw_camcorder_camera0.ini"
58
59 sdb shell "cat /etc/multimedia/mmfw_camcorder_camera0.ini | grep 320"
60 ```
61
62 ### 6. Build and install vision app
63 ```
64 git clone git://git.tizen.org/apps/native/smart-surveillance-camera # This git
65
66 cd smart-surveillance-camera
67
68 gbs build -A armv7l --include-all
69
70 sdb push ~/GBS-ROOT/local/BUILD-ROOTS/scratch.armv7l.0/home/abuild/rpmbuild/RPMS/armv7l/iot-vision-camera-0.0.1-1.armv7l.rpm /tmp
71
72 sdb shell 'rpm -ivh --force /tmp/iot-vision-camera-0.0.1-1.armv7l.rpm'
73 ```
74 ### 7. Some more settings
75 ```
76 sdb shell 'pkg_initdb'
77 ```
78 ### 8. Launch vision app
79 ```
80 sdb shell 'app_launcher -s iot-vision-camera'
81 ```
82 ### 9. Check vision app activity
83 ```
84 sdb shell 'ls -l /tmp/latest.jpg'
85 ```
86 ### 10. Install and run monitor server
87 * If you install latest version of "iot-vision-camera" package, the monitor server is automatically launched in booting time
88
89 * To check status of the monitor server
90         ```
91         sdb shell 'systemctl status iot-dashboard'
92         ```
93
94 * To restart the monitor server
95         ```
96         sdb shell 'systemctl stop iot-dashboard'
97         sdb shell 'systemctl start iot-dashboard'
98         sdb shell 'systemctl status iot-dashboard'  # To check status
99         ```
100
101 * To update some files of the monitor server, push the files to dashboard path `/opt/home/dashboard` and restart the monitor server as above
102         ```
103         sdb shell push {path/yourfile} /opt/home/dashboard/{path}
104         ```
105 OR! YOU CAN SIMPLY USE THE SCRIPT:
106 ```
107 ./update-dashboard.sh
108 ```
109
110
111 ## HOW TO RUN - Subsequent Runs
112 ```
113 sdb root on; sdb shell 'mount -o remount,rw /'
114
115 sdb shell 'app_launcher -s iot-vision-camera'
116
117  ./update-dashboard.sh
118 ```
119
120 ## Profiling Data
121
122 ### 카메라의 물리적 이동시간
123 슈퍼슬로우 카메라로 촬영결과 500ms 정도 소요
124
125 ### Rpi
126
127 #### Image Encoding (buffer -> jpg file)
128 소요시간 20 ~ 135ms (가끔씩 오래걸림, 장담 못함)
129
130 #### Vision Survailance (input -> cb event)
131 소요시간 38 ~ 50ms
132
133
134 ### Artik
135
136 #### Image Encoding (buffer -> jpg file)
137 소요시간 10 ~ 20ms, 대부분 10ms 초반 안정적
138
139 #### Vision Survailance (input -> cb event)
140 소요시간 24 ~ 42ms
141
142 ## Vision 움직임 정보 형식 (exif)
143 최대 244Byte 크기의 스트링으로 모두 숫자로 이루어져있다.
144
145 첫 2자리 숫자는 분석결과의 타입으로 TT 의 값을 갖는다.
146
147 그 다음 2자리 숫자는 포함된 움직임의 갯수 NN 의 값을 갖는다.
148
149 하나의 움직임은 8개 숫자로 구성되며 xxyywwhh 의 값을 갖는다.
150
151 xx: x 상대 좌표
152 yy: y 상대 좌표
153 ww: 상대 넓이
154 hh: 상대 높이
155
156 각각 0~99까지의 범위를 갖는 4개의 숫자를 이어놓은 것이다.
157 1자리 숫자의 경우 0을 넣어서 전체 길이를 고정한다.
158
159 TTNNxxyywwhhxxyywwhh....xxyywwhh 의 형태의 스트링이 된다.