├── Basic-LED ├── Python │ ├── Application.py │ ├── Device.py │ ├── README.md │ ├── required │ │ └── confs.json │ └── requirements.txt └── images │ ├── Blinking.jpg │ ├── Hardware.jpg │ ├── Raspberry-Pi-Basic-LED-Example-Hackster.png │ └── Raspberry-Pi-Basic-LED-Example.png ├── Computer-Vision ├── Python │ ├── Haarcascades │ │ ├── haarcascade_frontalface_alt.xml │ │ ├── haarcascade_frontalface_alt2.xml │ │ ├── haarcascade_frontalface_default.xml │ │ ├── haarcascade_profileface.xml │ │ └── lbpcascade_frontalface_improved.xml │ ├── README.md │ ├── TASS.py │ ├── TASSCore.py │ ├── img │ │ ├── TASS-Banner.png │ │ └── unavailable.jpg │ ├── media │ │ └── __init__.py │ ├── model │ │ ├── __init__.py │ │ ├── mean.png │ │ └── modelEigenvector.png │ ├── processed │ │ └── __init__.py │ ├── required │ │ └── config.json │ ├── requirements.txt │ └── training │ │ └── __init__.py └── images │ ├── Blinking.jpg │ ├── Hardware.jpg │ ├── Raspberry-Pi-Computer-Vision-Example-Hackster.png │ └── Raspberry-Pi-Computer-Vision-Example.png ├── Dev-Kit-IoT-Alarm ├── Python │ ├── Application.py │ ├── Device.py │ ├── README.md │ ├── required │ │ └── confs.json │ └── requirements.txt └── images │ ├── Dev-Kit-IoT-Alarm.png │ ├── blinking.jpg │ └── hardware.jpg ├── README.md ├── _DOCS ├── 1-Raspberry-Pi-Prep.md ├── 2-Installing-OpenCV-3-2-0.md ├── 2-Installing-OpenCV.md ├── 3-Raspberry-Pi-Domain-And-SSL.md ├── 4-Securing-Your-Raspberry-Pi-With-IPTables.md ├── 5-Installing-Motion.md ├── 6-Secure-Nginx-Server-For-Motion.md └── README.md └── images └── main ├── Device-Autonomous-Communication.png ├── Device-Creation.png ├── Intel-Software-Innovator.jpg ├── Raspberry-Pi-Documentation.png ├── Raspberry-Pi-Examples.png ├── SensorData.png └── WarningData.png /Basic-LED/Python/Application.py: -------------------------------------------------------------------------------- 1 | ############################################################################################ 2 | # Title: IoT JumpWay Raspberry Pi Basic LED Application 3 | # Description: Application for connecting to IoT connected LED using Raspberry Pi. 4 | # Last Modified: 2018-04-22 5 | ############################################################################################ 6 | 7 | import time, sys, json 8 | 9 | import JumpWayMQTT.Application as JWMQTTapplication 10 | 11 | class Application(): 12 | 13 | def __init__(self): 14 | 15 | self.jumpwayClient = None 16 | self.configs = {} 17 | 18 | with open('required/confs.json') as configs: 19 | self.configs = json.loads(configs.read()) 20 | 21 | self.startMQTT() 22 | 23 | def startMQTT(self): 24 | 25 | try: 26 | 27 | self.jumpwayClient = JWMQTTapplication.ApplicationConnection({ 28 | "locationID": self.configs["IoTJumpWay"]["Location"], 29 | "applicationID": self.configs["IoTJumpWay"]["App"], 30 | "applicationName": self.configs["IoTJumpWay"]["AppName"], 31 | "username": self.configs["IoTJumpWayMQTT"]["AppMQTTUsername"], 32 | "password": self.configs["IoTJumpWayMQTT"]["AppMQTTPassword"] 33 | }) 34 | 35 | except Exception as e: 36 | print(str(e)) 37 | sys.exit() 38 | 39 | self.jumpwayClient.connectToApplication() 40 | 41 | Application = Application() 42 | 43 | while True: 44 | 45 | Application.jumpwayClient.publishToDeviceChannel( 46 | "Commands", 47 | Application.configs["IoTJumpWay"]["Zone"], 48 | Application.configs["IoTJumpWay"]["Device"], 49 | { 50 | "Actuator":"LED", 51 | "ActuatorID":Application.configs["Actuators"]["LED"]["ID"], 52 | "Command":"TOGGLE", 53 | "CommandValue":"ON" 54 | } 55 | ) 56 | 57 | time.sleep(5) 58 | 59 | Application.jumpwayClient.publishToDeviceChannel( 60 | "Commands", 61 | Application.configs["IoTJumpWay"]["Zone"], 62 | Application.configs["IoTJumpWay"]["Device"], 63 | { 64 | "Actuator":"LED", 65 | "ActuatorID":Application.configs["Actuators"]["LED"]["ID"], 66 | "Command":"TOGGLE", 67 | "CommandValue":"OFF" 68 | } 69 | ) 70 | 71 | time.sleep(5) 72 | 73 | Application.jumpwayClient.disconnectFromApplication() -------------------------------------------------------------------------------- /Basic-LED/Python/Device.py: -------------------------------------------------------------------------------- 1 | ############################################################################################ 2 | # Title: IoT JumpWay Raspberry Pi Basic LED Device 3 | # Description: IoT connected LED using Raspberry Pi. 4 | # Last Modified: 2018-04-22 5 | ############################################################################################ 6 | 7 | import time, sys, json 8 | 9 | import RPi.GPIO as GPIO 10 | import JumpWayMQTT.Device as JWMQTTdevice 11 | 12 | class Device(): 13 | 14 | def __init__(self): 15 | 16 | self.jumpwayClient = None 17 | self.configs = {} 18 | 19 | with open('required/confs.json') as configs: 20 | self.configs = json.loads(configs.read()) 21 | 22 | GPIO.setmode(GPIO.BCM) 23 | GPIO.setwarnings(False) 24 | GPIO.setup( 25 | self.configs["Actuators"]["LED"]["PIN"], 26 | GPIO.OUT 27 | ) 28 | 29 | self.startMQTT() 30 | 31 | def deviceCommandsCallback(self,topic,payload): 32 | 33 | print("Received command data: %s" % (payload)) 34 | 35 | jsonData = json.loads(payload.decode("utf-8")) 36 | 37 | if jsonData['ActuatorID']==self.configs["Actuators"]["LED"]["ID"] and jsonData['Command']=='TOGGLE' and jsonData['CommandValue']=='ON': 38 | 39 | GPIO.output( 40 | self.configs["Actuators"]["LED"]["PIN"], 41 | GPIO.HIGH 42 | ) 43 | 44 | elif jsonData['ActuatorID']==self.configs["Actuators"]["LED"]["ID"] and jsonData['Command']=='TOGGLE' and jsonData['CommandValue']=='OFF': 45 | 46 | GPIO.output( 47 | self.configs["Actuators"]["LED"]["PIN"], 48 | GPIO.LOW 49 | ) 50 | 51 | def startMQTT(self): 52 | 53 | try: 54 | 55 | self.jumpwayClient = JWMQTTdevice.DeviceConnection({ 56 | "locationID": self.configs["IoTJumpWay"]["Location"], 57 | "zoneID": self.configs["IoTJumpWay"]["Zone"], 58 | "deviceId": self.configs["IoTJumpWay"]["Device"], 59 | "deviceName": self.configs["IoTJumpWay"]["DeviceName"], 60 | "username": self.configs["IoTJumpWayMQTT"]["MQTTUsername"], 61 | "password": self.configs["IoTJumpWayMQTT"]["MQTTPassword"] 62 | }) 63 | 64 | except Exception as e: 65 | print(str(e)) 66 | sys.exit() 67 | 68 | self.jumpwayClient.connectToDevice() 69 | self.jumpwayClient.subscribeToDeviceChannel("Commands") 70 | self.jumpwayClient.deviceCommandsCallback = self.deviceCommandsCallback 71 | 72 | Device = Device() 73 | 74 | while True: 75 | 76 | pass 77 | 78 | Device.jumpwayClient.disconnectFromDevice() -------------------------------------------------------------------------------- /Basic-LED/Python/README.md: -------------------------------------------------------------------------------- 1 | # IoT JumpWay Raspberry Pi Basic LED Example 2 | 3 | ![IoT JumpWay Raspberry Pi Basic LED Example Docs](../images/Raspberry-Pi-Basic-LED-Example.png) 4 | 5 | ## Introduction 6 | Want to take your first steps into the magical world of the Internet of Things, or want to find out how easy it is to use the IoT JumpWay as your secure IoT communication platform? This tutorial is for you an will hold your hand through setting up your first Raspberry Pi project powered by the IoT JumpWay. 7 | 8 | ## What Will We Build? 9 | 10 | This tutorial is a simple tutorial that will help you take your first steps to using the IoT JumpWay to connect your IoT devices and applications to the Internet of Things. 11 | 12 | The tutorial will use IoT JumpWay Python MQTT Library for communication, a Raspberry Pi with an added LED, and an application that can control the LED via the IoT JumpWay. 13 | 14 | ## Python Versions 15 | 16 | - 2.7 17 | - 3.4 or above 18 | 19 | ## Software Requirements 20 | 21 | 1. Jessie 22 | 2. [IoT JumpWay Python MQTT Client](https://github.com/iotJumpway/JumpWayMQTT "IoT JumpWay Python MQTT Client") 23 | 24 | ## Hardware requirements 25 | 26 | ![IoT JumpWay Raspberry Pi Basic LED Example Docs](../images/Hardware.jpg) 27 | 28 | 1. Raspberry Pi. 29 | 2. 1 x LED. 30 | 3. 1 x 220 ohm Resistor 31 | 4. 2 x Jumper Wires 32 | 5. 1 x Breadboard 33 | 34 | ## Before You Begin 35 | 36 | There are a few tutorials that you should follow before beginning, especially if it is the first time you have followed any of our Raspberry Pi tutorials or if it is the first time you have used the IoT JumpWay Developer Program. If this is the first time you have used the IoT JumpWay in your IoT projects, you will require a developer account and some basics to be set up before you can start creating your IoT devices. Visit the following [IoT JumpWay Developer Program Docs (5-10 minute read/setup)](https://github.com/iotJumpway/IoT-JumpWay-Docs/ "IoT JumpWay Developer Program Docs (5-10 minute read/setup)") and check out the guides that take you through registration and setting up your Location Space, Zones, Devices and Applications (About 5 minutes read). 37 | 38 | - [IoT JumpWay Developer Program Docs (5-10 minute read/setup)](https://github.com/iotJumpway/IoT-JumpWay-Docs/ "IoT JumpWay Developer Program Docs (5-10 minute read/setup)") 39 | 40 | - [Preparing Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/1-Raspberry-Pi-Prep.md "Preparing Your Raspberry Pi") 41 | 42 | ## Preparing Your Raspberry Pi 3 43 | 44 | Take some time to ensure your Raspberry Pi firmware and packages are up to date, and that your device is secure by following the [Raspberry Pi 3 Preparation Doc](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/1-Raspberry-Pi-Prep.md "Raspberry Pi 3 Preparation Doc") tutorial. 45 | 46 | ## Cloning The Repo 47 | 48 | You will need to clone this repository to a location on your Raspberry Pi 3. Navigate to the directory you would like to download it to and issue the following commands. 49 | 50 | $ git clone https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples.git 51 | 52 | ## Install Requirements 53 | 54 | $ cd IoT-JumpWay-RPI-Examples/Basic-LED/Python 55 | $ (sudo) pip install --upgrade pip 56 | $ (sudo) pip install -r requirements.txt 57 | 58 | ## Setting Up Your Raspberry Pi 59 | 60 | ![IoT JumpWay Raspberry Pi Basic LED Example Docs](../images/Blinking.jpg) 61 | 62 | First of all you need to connect up an LED to your Raspberry Pi. To connect the LED you will need a breadboard, a 220 ohm resistor, and two jumper wires. 63 | 64 | 1. Place the LED on your breadboard. 65 | 2. Connect the short leg of the LED to pin 18 of your Raspberry Pi using a jumper wire. 66 | 3. Connect one end of the resistor to the long leg of your LED. 67 | 4. Connect the other end of the resistor to the 3v output of the Raspberry Pi. 68 | 69 | ## Device / Application Connection Credentials & Sensor Settings 70 | 71 | - Follow the [IoT JumpWay Developer Program (BETA) Location Device Doc](https://github.com/iotJumpway/IoT-JumpWay-Docs/blob/master/4-Location-Devices.md "IoT JumpWay Developer Program (BETA) Location Device Doc") to set up your device, and the [IoT JumpWay Developer Program (BETA) Location Application Doc](https://github.com/iotJumpway/IoT-JumpWay-Docs/blob/master/5-Location-Applications.md "IoT JumpWay Developer Program (BETA) Location Application Doc") to set up your application. 72 | 73 | ![IoT JumpWay Raspberry Pi Basic LED Example Docs](../../images/main/Device-Creation.png) 74 | 75 | - Retrieve your connection credentials and update the config.json file with your new connection credentials and actuator (LED) settings. 76 | 77 | ``` 78 | "IoTJumpWay": { 79 | "Location": 0, 80 | "Zone": 0, 81 | "Device": 0, 82 | "DeviceName" : "", 83 | "App": 0, 84 | "AppName": "" 85 | } 86 | ``` 87 | 88 | ``` 89 | "Actuators": { 90 | "LED": { 91 | "ID": 0, 92 | "PIN": 18 93 | } 94 | } 95 | ``` 96 | 97 | ``` 98 | "IoTJumpWayMQTT": { 99 | "MQTTUsername": "", 100 | "MQTTPassword": "", 101 | "AppMQTTUsername": "", 102 | "AppMQTTPassword": "" 103 | } 104 | ``` 105 | 106 | ## Execute The Programs 107 | 108 | $ sudo python/python3 Device.py 109 | $ sudo python/python3 Application.py 110 | 111 | ## Viewing Your Data 112 | 113 | Each command sent to the device is stored in the [IoT JumpWay](https://iot.techbubbletechnologies.com/ "IoT JumpWay"). You will be able to access the data in the [IoT JumpWay Developers Area](https://iot.techbubbletechnologies.com/developers/dashboard/ "IoT JumpWay Developers Area"). Once you have logged into the Developers Area, visit the [IoT JumpWay Location Devices Page](https://iot.techbubbletechnologies.com/developers/location-devices "Location Devices page"), find your device and then visit the Commands Data page to view the data sent from your device. 114 | 115 | ![IoT JumpWay Raspberry Pi Basic LED Example Docs](../../images/main/SensorData.png) 116 | 117 | ![IoT JumpWay Raspberry Pi Basic LED Example Docs](../../images/main/WarningData.png) 118 | 119 | ## Bugs/Issues 120 | 121 | Please feel free to create issues for bugs and general issues you come across whilst using the IoT JumpWay Raspberry Pi Examples. You may also use the issues area to ask for general help whilst using the IoT JumpWay Raspberry Pi Examples in your IoT projects. 122 | 123 | ## Contributors 124 | 125 | [![Adam Milton-Barker, Intel® Software Innovator](../../images/main/Intel-Software-Innovator.jpg)](https://github.com/AdamMiltonBarker) -------------------------------------------------------------------------------- /Basic-LED/Python/required/confs.json: -------------------------------------------------------------------------------- 1 | { 2 | "IoTJumpWay": { 3 | "Location": 0, 4 | "Zone": 0, 5 | "Device": 0, 6 | "DeviceName" : "", 7 | "App": 0, 8 | "AppName": "" 9 | }, 10 | "Actuators": { 11 | "LED": { 12 | "ID": 0, 13 | "PIN": 18 14 | } 15 | }, 16 | "Cameras": {}, 17 | "Sensors": {}, 18 | "IoTJumpWayMQTT": { 19 | "MQTTUsername": "", 20 | "MQTTPassword": "", 21 | "AppMQTTUsername": "", 22 | "AppMQTTPassword": "" 23 | } 24 | } -------------------------------------------------------------------------------- /Basic-LED/Python/requirements.txt: -------------------------------------------------------------------------------- 1 | JumpWayMQTT -------------------------------------------------------------------------------- /Basic-LED/images/Blinking.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Basic-LED/images/Blinking.jpg -------------------------------------------------------------------------------- /Basic-LED/images/Hardware.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Basic-LED/images/Hardware.jpg -------------------------------------------------------------------------------- /Basic-LED/images/Raspberry-Pi-Basic-LED-Example-Hackster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Basic-LED/images/Raspberry-Pi-Basic-LED-Example-Hackster.png -------------------------------------------------------------------------------- /Basic-LED/images/Raspberry-Pi-Basic-LED-Example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Basic-LED/images/Raspberry-Pi-Basic-LED-Example.png -------------------------------------------------------------------------------- /Computer-Vision/Python/Haarcascades/lbpcascade_frontalface_improved.xml: -------------------------------------------------------------------------------- 1 | 2 | 61 | 62 | 63 | 64 | BOOST 65 | LBP 66 | 45 67 | 45 68 | 69 | GAB 70 | 9.9500000476837158e-001 71 | 5.0000000000000000e-001 72 | 9.4999999999999996e-001 73 | 1 74 | 100 75 | 76 | 256 77 | 1 78 | 19 79 | 80 | 81 | <_> 82 | 6 83 | -4.1617846488952637e+000 84 | 85 | <_> 86 | 87 | 0 -1 26 -1 -1 -17409 -1 -1 -1 -1 -1 88 | 89 | -9.9726462364196777e-001 -3.8938775658607483e-001 90 | <_> 91 | 92 | 0 -1 18 -1 -1 -21569 -20545 -1 -1 -20545 -1 93 | 94 | -9.8648911714553833e-001 -2.5386649370193481e-001 95 | <_> 96 | 97 | 0 -1 30 -21569 -16449 1006578219 -20801 -16449 -1 -21585 -1 98 | 99 | -9.6436238288879395e-001 -1.4039695262908936e-001 100 | <_> 101 | 102 | 0 -1 54 -1 -1 -16402 -4370 -1 -1 -1053010 -4456466 103 | 104 | -8.4081345796585083e-001 3.8321062922477722e-001 105 | <_> 106 | 107 | 0 -1 29 -184747280 -705314819 1326353 1364574079 -131073 -5 108 | 2147481147 -1 109 | 110 | -8.1084597110748291e-001 4.3495711684226990e-001 111 | <_> 112 | 113 | 0 -1 89 -142618625 -4097 -37269 -20933 872350430 -268476417 114 | 1207894255 2139032115 115 | 116 | -7.3140043020248413e-001 4.3799084424972534e-001 117 | 118 | <_> 119 | 6 120 | -4.0652265548706055e+000 121 | 122 | <_> 123 | 124 | 0 -1 19 -1 -1 -17409 -1 -1 -1 -1 -1 125 | 126 | -9.9727255105972290e-001 -7.2050148248672485e-001 127 | <_> 128 | 129 | 0 -1 38 -1 1073741823 -1 -1 -1 -1 -1 -1 130 | 131 | -9.8717331886291504e-001 -5.3031939268112183e-001 132 | <_> 133 | 134 | 0 -1 28 -16385 -1 -21569 -20545 -1 -1 -21569 -1 135 | 136 | -9.3442338705062866e-001 6.5213099122047424e-002 137 | <_> 138 | 139 | 0 -1 112 -2097153 -1 -1 -1 -1 -8193 -1 -35467 140 | 141 | -7.9567342996597290e-001 4.2883640527725220e-001 142 | <_> 143 | 144 | 0 -1 48 -134239573 -16465 58663467 -1079022929 -1073758273 145 | -81937 -8412501 -404766817 146 | 147 | -7.1264797449111938e-001 4.1050794720649719e-001 148 | <_> 149 | 150 | 0 -1 66 -17047555 -1099008003 2147479551 -1090584581 -69633 151 | -1342177281 -1090650121 -1472692240 152 | 153 | -7.6119172573089600e-001 4.2042696475982666e-001 154 | 155 | <_> 156 | 7 157 | -4.6904473304748535e+000 158 | 159 | <_> 160 | 161 | 0 -1 12 -1 -1 -17409 -1 -1 -1 -1 -1 162 | 163 | -9.9725550413131714e-001 -8.3142280578613281e-001 164 | <_> 165 | 166 | 0 -1 31 -1 -168429569 -1 -1 -1 -1 -1 -1 167 | 168 | -9.8183268308639526e-001 -3.6373397707939148e-001 169 | <_> 170 | 171 | 0 -1 38 -1 1073741759 -1 -1 -1 -1 -1 -1 172 | 173 | -9.1890293359756470e-001 7.8322596848011017e-002 174 | <_> 175 | 176 | 0 -1 27 -17409 -2097153 -134372726 -21873 -65 -536870913 177 | -161109 -4215889 178 | 179 | -8.0752444267272949e-001 1.9565649330615997e-001 180 | <_> 181 | 182 | 0 -1 46 -469779457 -286371842 -33619971 -212993 -1 -41943049 183 | -134217731 -1346863620 184 | 185 | -6.9232726097106934e-001 3.8141927123069763e-001 186 | <_> 187 | 188 | 0 -1 125 -1896950780 -1964839052 -9 707723004 -34078727 189 | -1074266122 -536872969 -262145 190 | 191 | -8.1760478019714355e-001 3.4172961115837097e-001 192 | <_> 193 | 194 | 0 -1 80 -402657501 654311423 -419533278 -452984853 195 | 1979676215 -1208090625 -167772569 -524289 196 | 197 | -6.3433408737182617e-001 4.3154156208038330e-001 198 | 199 | <_> 200 | 8 201 | -4.2590322494506836e+000 202 | 203 | <_> 204 | 205 | 0 -1 42 -1 -655361 -1 -1 -1 -1 -1 -1 206 | 207 | -9.9715477228164673e-001 -8.6178696155548096e-001 208 | <_> 209 | 210 | 0 -1 40 -1 -705300491 -1 -1 -1 -1 -1 -1 211 | 212 | -9.8356908559799194e-001 -5.7423096895217896e-001 213 | <_> 214 | 215 | 0 -1 43 -65 872413111 -2049 -1 -1 -1 -1 -1 216 | 217 | -9.2525935173034668e-001 -1.3835857808589935e-001 218 | <_> 219 | 220 | 0 -1 111 -1 -5242881 -1 -524289 -4194305 -1 -1 -43148 221 | 222 | -7.8076487779617310e-001 1.8362471461296082e-001 223 | <_> 224 | 225 | 0 -1 25 -145227841 868203194 -1627394049 935050171 226 | 2147483647 1006600191 -268439637 1002437615 227 | 228 | -7.2554033994674683e-001 3.3393219113349915e-001 229 | <_> 230 | 231 | 0 -1 116 -214961408 50592514 -2128 1072162674 -1077940293 232 | -1084489966 -134219854 -1074790401 233 | 234 | -6.1547595262527466e-001 3.9214438199996948e-001 235 | <_> 236 | 237 | 0 -1 3 -294987948 -1124421633 -73729 -268435841 -33654928 238 | 2122317823 -268599297 -33554945 239 | 240 | -6.4863425493240356e-001 3.8784855604171753e-001 241 | <_> 242 | 243 | 0 -1 22 -525585 -26738821 -17895690 1123482236 1996455758 244 | -8519849 -252182980 -461898753 245 | 246 | -5.5464369058609009e-001 4.4275921583175659e-001 247 | 248 | <_> 249 | 8 250 | -4.0009465217590332e+000 251 | 252 | <_> 253 | 254 | 0 -1 82 -1 -1 -1 -1 -33685505 -1 -1 -1 255 | 256 | -9.9707120656967163e-001 -8.9196771383285522e-001 257 | <_> 258 | 259 | 0 -1 84 -1 -1 -1 -1 2147446783 -1 -1 -1 260 | 261 | -9.8670446872711182e-001 -7.5064390897750854e-001 262 | <_> 263 | 264 | 0 -1 79 -1 -1 -262145 -1 -252379137 -1 -1 -1 265 | 266 | -8.9446705579757690e-001 7.0268943905830383e-002 267 | <_> 268 | 269 | 0 -1 61 -1 -8201 -1 -2097153 -16777217 -513 -16777217 270 | -1162149889 271 | 272 | -7.2166109085083008e-001 2.9786801338195801e-001 273 | <_> 274 | 275 | 0 -1 30 -21569 -1069121 1006578211 -134238545 -16450 276 | -268599297 -21617 -14680097 277 | 278 | -6.2449234724044800e-001 3.8551881909370422e-001 279 | <_> 280 | 281 | 0 -1 75 -268701913 -1999962377 1995165474 -453316822 282 | 1744684853 -2063597697 -134226057 -50336769 283 | 284 | -5.5207914113998413e-001 4.2211884260177612e-001 285 | <_> 286 | 287 | 0 -1 21 -352321825 -526489 -420020626 -486605074 1155483470 288 | -110104705 -587840772 -25428801 289 | 290 | -5.3324747085571289e-001 4.4535955786705017e-001 291 | <_> 292 | 293 | 0 -1 103 70270772 2012790229 -16810020 -245764 -1208090635 294 | -753667 -1073741828 -1363662420 295 | 296 | -6.4402890205383301e-001 3.8995954394340515e-001 297 | 298 | <_> 299 | 8 300 | -4.6897511482238770e+000 301 | 302 | <_> 303 | 304 | 0 -1 97 -1 -1 -1 -1 -524289 -524289 -1 -1 305 | 306 | -9.9684870243072510e-001 -8.8232177495956421e-001 307 | <_> 308 | 309 | 0 -1 84 -1 -1 -1 -1 2147438591 -1 -1 -1 310 | 311 | -9.8677414655685425e-001 -7.8965580463409424e-001 312 | <_> 313 | 314 | 0 -1 113 -1 -1 -1 -1 -1048577 -262149 -1048577 -35339 315 | 316 | -9.2621946334838867e-001 -2.9984828829765320e-001 317 | <_> 318 | 319 | 0 -1 33 -2249 867434291 -32769 -33562753 -1 -1073758209 320 | -4165 -1 321 | 322 | -7.2429555654525757e-001 2.2348840534687042e-001 323 | <_> 324 | 325 | 0 -1 98 1659068671 -142606337 587132538 -67108993 577718271 326 | -294921 -134479873 -129 327 | 328 | -5.5495566129684448e-001 3.5419258475303650e-001 329 | <_> 330 | 331 | 0 -1 100 -268441813 788267007 -286265494 -486576145 -8920251 332 | 2138505075 -151652570 -2050 333 | 334 | -5.3362584114074707e-001 3.9479774236679077e-001 335 | <_> 336 | 337 | 0 -1 51 -1368387212 -537102978 -98305 -163843 1065109500 338 | -16777217 -67321939 -1141359619 339 | 340 | -5.6162708997726440e-001 3.8008108735084534e-001 341 | <_> 342 | 343 | 0 -1 127 -268435550 1781120906 -251658720 -143130698 344 | -1048605 -1887436825 1979700688 -1008730125 345 | 346 | -5.1167154312133789e-001 4.0678605437278748e-001 347 | 348 | <_> 349 | 10 350 | -4.2179841995239258e+000 351 | 352 | <_> 353 | 354 | 0 -1 97 -1 -1 -1 -1 -524289 -524289 -1 -1 355 | 356 | -9.9685418605804443e-001 -8.8037383556365967e-001 357 | <_> 358 | 359 | 0 -1 90 -1 -1 -1 -1 -8912897 -524297 -8912897 -1 360 | 361 | -9.7972750663757324e-001 -5.7626229524612427e-001 362 | <_> 363 | 364 | 0 -1 96 -1 -1 -1 -1 -1 -65 -1 -2249 365 | 366 | -9.0239793062210083e-001 -1.7454113066196442e-001 367 | <_> 368 | 369 | 0 -1 71 -1 -4097 -1 -513 -16777217 -268468483 -16797697 370 | -1430589697 371 | 372 | -7.4346423149108887e-001 9.4165161252021790e-002 373 | <_> 374 | 375 | 0 -1 37 1364588304 -581845274 -536936460 -3 -308936705 376 | -1074331649 -4196865 -134225953 377 | 378 | -6.8877440690994263e-001 2.7647304534912109e-001 379 | <_> 380 | 381 | 0 -1 117 -37765187 -540675 -3 -327753 -1082458115 -65537 382 | 1071611901 536827253 383 | 384 | -5.7555085420608521e-001 3.4339720010757446e-001 385 | <_> 386 | 387 | 0 -1 85 -269490650 -1561395522 -1343312090 -857083986 388 | -1073750223 -369098755 -50856110 -2065 389 | 390 | -5.4036927223205566e-001 4.0065473318099976e-001 391 | <_> 392 | 393 | 0 -1 4 -425668880 -34427164 1879048177 -269570140 790740912 394 | -196740 2138535839 -536918145 395 | 396 | -4.8439365625381470e-001 4.4630467891693115e-001 397 | <_> 398 | 399 | 0 -1 92 74726960 -1246482434 -1 -246017 -1078607916 400 | -1073947163 -1644231687 -1359211496 401 | 402 | -5.6686979532241821e-001 3.6671569943428040e-001 403 | <_> 404 | 405 | 0 -1 11 -135274809 -1158173459 -353176850 540195262 406 | 2139086600 2071977814 -546898600 -96272673 407 | 408 | -5.1499199867248535e-001 4.0788397192955017e-001 409 | 410 | <_> 411 | 9 412 | -4.0345416069030762e+000 413 | 414 | <_> 415 | 416 | 0 -1 78 -1 -1 -1 -1 -8912897 -1 -8912897 -1 417 | 418 | -9.9573624134063721e-001 -8.5452395677566528e-001 419 | <_> 420 | 421 | 0 -1 93 -1 -1 -1 -1 -148635649 -524297 -8912897 -1 422 | 423 | -9.7307401895523071e-001 -5.2884924411773682e-001 424 | <_> 425 | 426 | 0 -1 77 -1 -8209 -1 -257 -772734977 -1 -201850881 -1 427 | 428 | -8.6225658655166626e-001 4.3712578713893890e-002 429 | <_> 430 | 431 | 0 -1 68 -570427393 -16649 -69633 -131073 -536944677 -1 -8737 432 | -1435828225 433 | 434 | -6.8078064918518066e-001 2.5120577216148376e-001 435 | <_> 436 | 437 | 0 -1 50 -1179697 -34082849 -3278356 -37429266 -1048578 438 | -555753474 -1015551096 -37489685 439 | 440 | -6.1699724197387695e-001 3.0963841080665588e-001 441 | <_> 442 | 443 | 0 -1 129 -1931606992 -17548804 -16842753 -1075021827 444 | 1073667572 -81921 -1611073620 -1415047752 445 | 446 | -6.0499197244644165e-001 3.0735063552856445e-001 447 | <_> 448 | 449 | 0 -1 136 -269754813 1761591286 -1073811523 2130378623 -17580 450 | -1082294665 -159514800 -1026883840 451 | 452 | -5.6772041320800781e-001 3.5023149847984314e-001 453 | <_> 454 | 455 | 0 -1 65 2016561683 1528827871 -10258447 960184191 125476830 456 | -8511618 -1078239365 187648611 457 | 458 | -5.5894804000854492e-001 3.4856522083282471e-001 459 | <_> 460 | 461 | 0 -1 13 -207423502 -333902 2013200231 -202348848 1042454451 462 | -16393 1073117139 2004162321 463 | 464 | -5.7197356224060059e-001 3.2818377017974854e-001 465 | 466 | <_> 467 | 9 468 | -3.4892759323120117e+000 469 | 470 | <_> 471 | 472 | 0 -1 78 -1 -1 -1 -1 -8912897 -1 -8912897 -1 473 | 474 | -9.8917990922927856e-001 -7.3812037706375122e-001 475 | <_> 476 | 477 | 0 -1 93 -1 -1 -1 -1 -148635649 -524297 -8912897 -1 478 | 479 | -9.3414896726608276e-001 -2.6945295929908752e-001 480 | <_> 481 | 482 | 0 -1 83 -1 -524289 -1 -1048577 1879011071 -32769 -524289 483 | -3178753 484 | 485 | -7.6891708374023438e-001 5.2568886429071426e-002 486 | <_> 487 | 488 | 0 -1 9 -352329729 -17891329 -16810117 -486871042 -688128841 489 | -1358954675 -16777218 -219217968 490 | 491 | -6.2337344884872437e-001 2.5143685936927795e-001 492 | <_> 493 | 494 | 0 -1 130 -2157 -1548812374 -1343233440 -418381854 -953155613 495 | -836960513 -713571200 -709888014 496 | 497 | -4.7277018427848816e-001 3.9616456627845764e-001 498 | <_> 499 | 500 | 0 -1 121 -1094717701 -67240065 -65857 -32899 -5783756 501 | -136446081 -134285352 -2003298884 502 | 503 | -5.1766264438629150e-001 3.5814732313156128e-001 504 | <_> 505 | 506 | 0 -1 23 -218830160 -119671186 5505075 1241491391 -1594469 507 | -2097185 2004828075 -67649541 508 | 509 | -6.5394639968872070e-001 3.0377501249313354e-001 510 | <_> 511 | 512 | 0 -1 115 -551814749 2099511088 -1090732551 -2045546512 513 | -1086341441 1059848178 800042912 252705994 514 | 515 | -5.2584588527679443e-001 3.3847147226333618e-001 516 | <_> 517 | 518 | 0 -1 99 -272651477 578776766 -285233490 -889225217 519 | 2147448656 377454463 2012701952 -68157761 520 | 521 | -6.1836904287338257e-001 2.8922611474990845e-001 522 | 523 | <_> 524 | 9 525 | -3.0220029354095459e+000 526 | 527 | <_> 528 | 529 | 0 -1 36 -1 -570425345 -1 -570425345 -1 -50331649 -6291457 -1 530 | 531 | -9.7703826427459717e-001 -6.2527233362197876e-001 532 | <_> 533 | 534 | 0 -1 124 -1430602241 -33619969 -1 -3 -1074003969 -1073758209 535 | -1073741825 -1073768705 536 | 537 | -8.9538317918777466e-001 -3.1887885928153992e-001 538 | <_> 539 | 540 | 0 -1 88 -1 -268439625 -65601 -268439569 -393809 -270532609 541 | -42076889 -288361721 542 | 543 | -6.8733429908752441e-001 1.2978810071945190e-001 544 | <_> 545 | 546 | 0 -1 132 -755049252 2042563807 1795096575 465121071 547 | -1090585188 -20609 -1459691784 539672495 548 | 549 | -5.7038843631744385e-001 3.0220884084701538e-001 550 | <_> 551 | 552 | 0 -1 20 -94377762 -25702678 1694167798 -231224662 1079955016 553 | -346144140 2029995743 -536918961 554 | 555 | -5.3204691410064697e-001 3.4054222702980042e-001 556 | <_> 557 | 558 | 0 -1 47 2143026943 -285278225 -3 -612438281 -16403 -131074 559 | -1 -1430749256 560 | 561 | -4.6176829934120178e-001 4.1114711761474609e-001 562 | <_> 563 | 564 | 0 -1 74 203424336 -25378820 -35667973 1073360894 -1912815660 565 | -573444 -356583491 -1365235056 566 | 567 | -4.9911966919898987e-001 3.5335537791252136e-001 568 | <_> 569 | 570 | 0 -1 6 -1056773 -1508430 -558153 -102747408 2133997491 571 | -269043865 2004842231 -8947721 572 | 573 | -4.0219521522521973e-001 4.3947893381118774e-001 574 | <_> 575 | 576 | 0 -1 70 -880809694 -1070282769 -1363162108 -838881281 577 | -680395161 -2064124929 -34244753 1173880701 578 | 579 | -5.3891533613204956e-001 3.2062566280364990e-001 580 | 581 | <_> 582 | 8 583 | -2.5489892959594727e+000 584 | 585 | <_> 586 | 587 | 0 -1 39 -1 -572522497 -8519681 -570425345 -4195329 -50333249 588 | -1 -1 589 | 590 | -9.4647216796875000e-001 -3.3662387728691101e-001 591 | <_> 592 | 593 | 0 -1 124 -1430735362 -33619971 -8201 -3 -1677983745 594 | -1073762817 -1074003969 -1142979329 595 | 596 | -8.0300611257553101e-001 -3.8466516882181168e-002 597 | <_> 598 | 599 | 0 -1 91 -67113217 -524289 -671482265 -786461 1677132031 600 | -268473345 -68005889 -70291765 601 | 602 | -5.8367580175399780e-001 2.6507318019866943e-001 603 | <_> 604 | 605 | 0 -1 17 -277872641 -553910292 -268435458 -16843010 606 | 1542420439 -1342178311 -143132940 -2834 607 | 608 | -4.6897178888320923e-001 3.7864661216735840e-001 609 | <_> 610 | 611 | 0 -1 137 -1312789 -290527285 -286326862 -5505280 -1712335966 612 | -2045979188 1165423617 -709363723 613 | 614 | -4.6382644772529602e-001 3.6114525794982910e-001 615 | <_> 616 | 617 | 0 -1 106 1355856590 -109445156 -96665606 2066939898 618 | 1356084692 1549031917 -30146561 -16581701 619 | 620 | -6.3095021247863770e-001 2.9294869303703308e-001 621 | <_> 622 | 623 | 0 -1 104 -335555328 118529 1860167712 -810680357 -33558656 624 | -1368391795 -402663552 -1343225921 625 | 626 | -5.9658926725387573e-001 2.7228885889053345e-001 627 | <_> 628 | 629 | 0 -1 76 217581168 -538349634 1062631419 1039868926 630 | -1090707460 -2228359 -1078042693 -1147128518 631 | 632 | -4.5812287926673889e-001 3.7063929438591003e-001 633 | 634 | <_> 635 | 9 636 | -2.5802578926086426e+000 637 | 638 | <_> 639 | 640 | 0 -1 35 -513 -706873891 -270541825 1564475391 -120602625 641 | -118490145 -3162113 -1025 642 | 643 | -8.9068460464477539e-001 -1.6470588743686676e-001 644 | <_> 645 | 646 | 0 -1 41 -1025 872144563 -2105361 -1078076417 -1048577 647 | -1145061461 -87557413 -1375993973 648 | 649 | -7.1808964014053345e-001 2.2022204473614693e-002 650 | <_> 651 | 652 | 0 -1 95 -42467849 967946223 -811601986 1030598351 653 | -1212430676 270856533 -1392539508 147705039 654 | 655 | -4.9424821138381958e-001 3.0048963427543640e-001 656 | <_> 657 | 658 | 0 -1 10 -218116370 -637284625 -87373174 -521998782 659 | -805355450 -615023745 -814267322 -12069282 660 | 661 | -5.5306458473205566e-001 2.9137542843818665e-001 662 | <_> 663 | 664 | 0 -1 105 -275849241 -527897 -11052049 -69756067 -15794193 665 | -1141376839 -564771 -287095455 666 | 667 | -4.6759819984436035e-001 3.6638516187667847e-001 668 | <_> 669 | 670 | 0 -1 24 -1900898096 -18985228 -44056577 -24675 -1074880639 671 | -283998 796335613 -1079041957 672 | 673 | -4.2737138271331787e-001 3.9243003726005554e-001 674 | <_> 675 | 676 | 0 -1 139 -555790844 410735094 -32106513 406822863 -897632192 677 | -912830145 -117771560 -1204027649 678 | 679 | -4.1896930336952209e-001 3.6744937300682068e-001 680 | <_> 681 | 682 | 0 -1 0 -1884822366 -1406613148 1135342180 -1979127580 683 | -68174862 246469804 1001386992 -708885872 684 | 685 | -5.7093089818954468e-001 2.9880744218826294e-001 686 | <_> 687 | 688 | 0 -1 45 -469053950 1439068142 2117758841 2004671078 689 | 207931006 1265321675 970353931 1541343047 690 | 691 | -6.0491901636123657e-001 2.4652053415775299e-001 692 | 693 | <_> 694 | 9 695 | -2.2425732612609863e+000 696 | 697 | <_> 698 | 699 | 0 -1 58 1481987157 282547485 -14952129 421131223 -391065352 700 | -24212488 -100094241 -1157907473 701 | 702 | -8.2822084426879883e-001 -2.1619293093681335e-001 703 | <_> 704 | 705 | 0 -1 126 -134217889 -543174305 -75497474 -16851650 -6685738 706 | -75834693 -2097200 -262146 707 | 708 | -5.4628932476043701e-001 2.7662658691406250e-001 709 | <_> 710 | 711 | 0 -1 133 -220728227 -604288517 -661662214 413104863 712 | -627323700 -251915415 -626200872 -1157958657 713 | 714 | -4.1643124818801880e-001 4.1700571775436401e-001 715 | <_> 716 | 717 | 0 -1 2 -186664033 -44236961 -1630262774 -65163606 -103237330 718 | -3083265 -1003729 2053105955 719 | 720 | -5.4847818613052368e-001 2.9710745811462402e-001 721 | <_> 722 | 723 | 0 -1 62 -256115886 -237611873 -620250696 387061799 724 | 1437882671 274878849 -8684449 1494294023 725 | 726 | -4.6202757954597473e-001 3.3915829658508301e-001 727 | <_> 728 | 729 | 0 -1 1 -309400577 -275864640 -1056864869 1737132756 730 | -272385089 1609671419 1740601343 1261376789 731 | 732 | -4.6158722043037415e-001 3.3939516544342041e-001 733 | <_> 734 | 735 | 0 -1 102 818197248 -196324552 286970589 -573270699 736 | -1174099579 -662077381 -1165157895 -1626859296 737 | 738 | -4.6193107962608337e-001 3.2456985116004944e-001 739 | <_> 740 | 741 | 0 -1 69 -1042550357 14675409 1367955200 -841482753 742 | 1642443255 8774277 1941304147 1099949563 743 | 744 | -4.9091196060180664e-001 3.3870378136634827e-001 745 | <_> 746 | 747 | 0 -1 72 -639654997 1375720439 -2129542805 1614801090 748 | -626787937 -5779294 1488699183 -525406458 749 | 750 | -4.9073097109794617e-001 3.0637946724891663e-001 751 | 752 | <_> 753 | 9 754 | -1.2258235216140747e+000 755 | 756 | <_> 757 | 758 | 0 -1 118 302046707 -16744240 1360106207 -543735387 759 | 1025700851 -1079408512 1796961263 -6334981 760 | 761 | -6.1358314752578735e-001 2.3539231717586517e-001 762 | <_> 763 | 764 | 0 -1 5 -144765953 -116448726 -653851877 1934829856 722021887 765 | 856564834 1933919231 -540838029 766 | 767 | -5.1209545135498047e-001 3.2506987452507019e-001 768 | <_> 769 | 770 | 0 -1 140 -170132825 -1438923874 1879300370 -1689337194 771 | -695606496 285911565 -1044188928 -154210028 772 | 773 | -5.1769560575485229e-001 3.2290914654731750e-001 774 | <_> 775 | 776 | 0 -1 131 -140776261 -355516414 822178224 -1039743806 777 | -1012208926 134887424 1438876097 -908591660 778 | 779 | -5.0321841239929199e-001 3.0263835191726685e-001 780 | <_> 781 | 782 | 0 -1 64 -2137211696 -1634281249 1464325973 498569935 783 | -1580152080 -2001687927 721783561 265096035 784 | 785 | -4.6532225608825684e-001 3.4638473391532898e-001 786 | <_> 787 | 788 | 0 -1 101 -255073589 -211824417 -972195129 -1063415417 789 | 1937994261 1363165220 -754733105 1967602541 790 | 791 | -4.9611270427703857e-001 3.3260712027549744e-001 792 | <_> 793 | 794 | 0 -1 81 -548146862 -655567194 -2062466596 1164562721 795 | 416408236 -1591631712 -83637777 975344427 796 | 797 | -4.9862930178642273e-001 3.2003280520439148e-001 798 | <_> 799 | 800 | 0 -1 55 -731904652 2147179896 2147442687 2112830847 -65604 801 | -131073 -42139667 -1074907393 802 | 803 | -3.6636069416999817e-001 4.5651626586914063e-001 804 | <_> 805 | 806 | 0 -1 67 1885036886 571985932 -1784930633 724431327 807 | 1940422257 -1085746880 964888398 731867951 808 | 809 | -5.2619713544845581e-001 3.2635414600372314e-001 810 | 811 | <_> 812 | 9 813 | -1.3604533672332764e+000 814 | 815 | <_> 816 | 817 | 0 -1 8 -287609985 -965585953 -2146397793 -492129894 818 | -729029645 -544619901 -645693256 -6565484 819 | 820 | -4.5212322473526001e-001 3.8910505175590515e-001 821 | <_> 822 | 823 | 0 -1 122 -102903523 -145031013 536899675 688195859 824 | -645291520 -1165359094 -905565928 171608223 825 | 826 | -4.9594074487686157e-001 3.4109055995941162e-001 827 | <_> 828 | 829 | 0 -1 134 -790640459 487931983 1778450522 1036604041 830 | -904752984 -954040118 -2134707506 304866043 831 | 832 | -4.1148442029953003e-001 3.9666590094566345e-001 833 | <_> 834 | 835 | 0 -1 141 -303829117 1726939070 922189815 -827983123 836 | 1567883042 1324809852 292710260 -942678754 837 | 838 | -3.5154473781585693e-001 4.8011952638626099e-001 839 | <_> 840 | 841 | 0 -1 59 -161295376 -159215460 -1858041315 2140644499 842 | -2009065472 -133804007 -2003265301 1263206851 843 | 844 | -4.2808216810226440e-001 3.9841541647911072e-001 845 | <_> 846 | 847 | 0 -1 34 -264248081 -667846464 1342624856 1381160835 848 | -2104716852 1342865409 -266612310 -165954877 849 | 850 | -4.3293288350105286e-001 4.0339657664299011e-001 851 | <_> 852 | 853 | 0 -1 32 -1600388464 -40369901 285344639 1394344275 854 | -255680312 -100532214 -1031663944 -7471079 855 | 856 | -4.1385015845298767e-001 4.5087572932243347e-001 857 | <_> 858 | 859 | 0 -1 15 1368521651 280207469 35779199 -105983261 1208124819 860 | -565870452 -1144024288 -591535344 861 | 862 | -4.2956474423408508e-001 4.2176279425621033e-001 863 | <_> 864 | 865 | 0 -1 109 1623607527 -661513115 -1073217263 -2142994420 866 | -1339883309 -89816956 436308899 1426178059 867 | 868 | -4.7764992713928223e-001 3.7551075220108032e-001 869 | 870 | <_> 871 | 9 872 | -4.2518746852874756e-001 873 | 874 | <_> 875 | 876 | 0 -1 135 -116728032 -1154420809 -1350582273 746061691 877 | -1073758277 2138570623 2113797566 -138674182 878 | 879 | -1.7125381529331207e-001 6.5421247482299805e-001 880 | <_> 881 | 882 | 0 -1 63 -453112432 -1795354691 -1342242964 494112553 883 | 209458404 -2114697500 1316830362 259213855 884 | 885 | -3.9870172739028931e-001 4.5807033777236938e-001 886 | <_> 887 | 888 | 0 -1 52 -268172036 294715533 268575185 486785157 -1065303920 889 | -360185856 -2147476808 134777113 890 | 891 | -5.3581339120864868e-001 3.5815808176994324e-001 892 | <_> 893 | 894 | 0 -1 86 -301996882 -345718921 1877946252 -940720129 895 | -58737369 -721944585 -92954835 -530449 896 | 897 | -3.9938014745712280e-001 4.9603295326232910e-001 898 | <_> 899 | 900 | 0 -1 14 -853281886 -756895766 2130706352 -9519120 901 | -1921059862 394133373 2138453959 -538200841 902 | 903 | -4.0230083465576172e-001 4.9537116289138794e-001 904 | <_> 905 | 906 | 0 -1 128 -2133448688 -641138493 1078022185 294060066 907 | -327122776 -2130640896 -2147466247 -1910634326 908 | 909 | -5.8290809392929077e-001 3.4102553129196167e-001 910 | <_> 911 | 912 | 0 -1 53 587265978 -2071658479 1108361221 -578448765 913 | -1811905899 -2008965119 33900729 762301595 914 | 915 | -4.5518967509269714e-001 4.7242793440818787e-001 916 | <_> 917 | 918 | 0 -1 138 -1022189373 -2139094976 16658 -1069445120 919 | -1073555454 -1073577856 1096068 -978351488 920 | 921 | -4.7530207037925720e-001 4.3885371088981628e-001 922 | <_> 923 | 924 | 0 -1 7 -395352441 -1073541103 -1056964605 1053186 269111298 925 | -2012184576 1611208714 -360415095 926 | 927 | -5.0448113679885864e-001 4.1588482260704041e-001 928 | 929 | <_> 930 | 7 931 | 2.7163455262780190e-002 932 | 933 | <_> 934 | 935 | 0 -1 49 783189748 -137429026 -257 709557994 2130460236 936 | -196611 -9580 585428708 937 | 938 | -2.0454545319080353e-001 7.9608374834060669e-001 939 | <_> 940 | 941 | 0 -1 108 1284360448 1057423155 1592696573 -852672655 942 | 1547382714 -1642594369 125705358 797134398 943 | 944 | -3.6474677920341492e-001 6.0925579071044922e-001 945 | <_> 946 | 947 | 0 -1 94 1347680270 -527720448 1091567712 1073745933 948 | -1073180671 0 285745154 -511192438 949 | 950 | -4.6406838297843933e-001 5.5626088380813599e-001 951 | <_> 952 | 953 | 0 -1 73 1705780944 -145486260 -115909 -281793505 -418072663 954 | -1681064068 1877454127 -1912330993 955 | 956 | -4.7043186426162720e-001 5.8430361747741699e-001 957 | <_> 958 | 959 | 0 -1 110 -2118142016 339509033 -285260567 1417764573 960 | 68144392 -468879483 -2033291636 231451911 961 | 962 | -4.8700931668281555e-001 5.4639810323715210e-001 963 | <_> 964 | 965 | 0 -1 119 -1888051818 489996135 -65539 849536890 2146716845 966 | -1107542088 -1275615746 -1119617586 967 | 968 | -4.3356490135192871e-001 6.5175366401672363e-001 969 | <_> 970 | 971 | 0 -1 44 -1879021438 336830528 1073766659 1477541961 8560696 972 | -1207369568 8462472 1493893448 973 | 974 | -5.4343086481094360e-001 5.2777874469757080e-001 975 | 976 | <_> 977 | 7 978 | 4.9174150824546814e-001 979 | 980 | <_> 981 | 982 | 0 -1 57 644098 15758324 1995964260 -463011882 893285175 983 | 83156983 2004317989 16021237 984 | 985 | -1.7073170840740204e-001 9.0782123804092407e-001 986 | <_> 987 | 988 | 0 -1 123 268632845 -2147450864 -2143240192 -2147401728 989 | 8523937 -1878523840 16777416 616824984 990 | 991 | -4.8744434118270874e-001 7.3311311006546021e-001 992 | <_> 993 | 994 | 0 -1 120 -2110735872 803880886 989739810 1673281312 91564930 995 | -277454958 997709514 -581366443 996 | 997 | -4.0291741490364075e-001 8.2450771331787109e-001 998 | <_> 999 | 1000 | 0 -1 87 941753434 -1067128905 788512753 -1074450460 1001 | 779101657 -1346552460 938805167 -2050424642 1002 | 1003 | -3.6246949434280396e-001 8.7103593349456787e-001 1004 | <_> 1005 | 1006 | 0 -1 60 208 1645217920 130 538263552 33595552 -1475870592 1007 | 16783361 1375993867 1008 | 1009 | -6.1472141742706299e-001 5.9707164764404297e-001 1010 | <_> 1011 | 1012 | 0 -1 114 1860423179 1034692624 -285213187 -986681712 1013 | 1576755092 -1408205463 -127714 -1246035687 1014 | 1015 | -4.5621752738952637e-001 8.9482426643371582e-001 1016 | <_> 1017 | 1018 | 0 -1 107 33555004 -1861746688 1073807361 -754909184 1019 | 645922856 8388608 134250648 419635458 1020 | 1021 | -5.2466005086898804e-001 7.1834069490432739e-001 1022 | 1023 | <_> 1024 | 2 1025 | 1.9084988832473755e+000 1026 | 1027 | <_> 1028 | 1029 | 0 -1 16 536064 131072 -20971516 524288 576 1048577 0 40960 1030 | 1031 | -8.0000001192092896e-001 9.8018401861190796e-001 1032 | <_> 1033 | 1034 | 0 -1 56 67108864 0 4096 1074003968 8192 536870912 4 262144 1035 | 1036 | -9.6610915660858154e-001 9.2831486463546753e-001 1037 | 1038 | <_> 1039 | 1040 | 0 0 1 1 1041 | <_> 1042 | 1043 | 0 0 3 2 1044 | <_> 1045 | 1046 | 0 1 13 6 1047 | <_> 1048 | 1049 | 0 2 3 14 1050 | <_> 1051 | 1052 | 0 2 4 2 1053 | <_> 1054 | 1055 | 0 6 2 3 1056 | <_> 1057 | 1058 | 0 6 3 2 1059 | <_> 1060 | 1061 | 0 16 1 3 1062 | <_> 1063 | 1064 | 0 20 3 3 1065 | <_> 1066 | 1067 | 0 22 2 3 1068 | <_> 1069 | 1070 | 0 28 4 4 1071 | <_> 1072 | 1073 | 0 35 2 3 1074 | <_> 1075 | 1076 | 1 0 14 7 1077 | <_> 1078 | 1079 | 1 5 3 2 1080 | <_> 1081 | 1082 | 1 6 2 1 1083 | <_> 1084 | 1085 | 1 14 10 9 1086 | <_> 1087 | 1088 | 1 21 4 4 1089 | <_> 1090 | 1091 | 1 23 4 2 1092 | <_> 1093 | 1094 | 2 0 13 7 1095 | <_> 1096 | 1097 | 2 0 14 7 1098 | <_> 1099 | 1100 | 2 33 5 4 1101 | <_> 1102 | 1103 | 2 36 4 3 1104 | <_> 1105 | 1106 | 2 39 3 2 1107 | <_> 1108 | 1109 | 3 1 13 11 1110 | <_> 1111 | 1112 | 3 2 3 2 1113 | <_> 1114 | 1115 | 4 0 7 8 1116 | <_> 1117 | 1118 | 4 0 13 7 1119 | <_> 1120 | 1121 | 5 0 12 6 1122 | <_> 1123 | 1124 | 5 0 13 7 1125 | <_> 1126 | 1127 | 5 1 10 13 1128 | <_> 1129 | 1130 | 5 1 12 7 1131 | <_> 1132 | 1133 | 5 2 7 13 1134 | <_> 1135 | 1136 | 5 4 2 1 1137 | <_> 1138 | 1139 | 5 8 7 4 1140 | <_> 1141 | 1142 | 5 39 3 2 1143 | <_> 1144 | 1145 | 6 3 5 2 1146 | <_> 1147 | 1148 | 6 3 6 2 1149 | <_> 1150 | 1151 | 6 5 4 12 1152 | <_> 1153 | 1154 | 6 9 6 3 1155 | <_> 1156 | 1157 | 7 3 5 2 1158 | <_> 1159 | 1160 | 7 3 6 13 1161 | <_> 1162 | 1163 | 7 5 6 4 1164 | <_> 1165 | 1166 | 7 7 6 10 1167 | <_> 1168 | 1169 | 7 8 6 4 1170 | <_> 1171 | 1172 | 7 32 5 4 1173 | <_> 1174 | 1175 | 7 33 5 4 1176 | <_> 1177 | 1178 | 8 0 1 1 1179 | <_> 1180 | 1181 | 8 0 2 1 1182 | <_> 1183 | 1184 | 8 2 10 7 1185 | <_> 1186 | 1187 | 9 0 6 2 1188 | <_> 1189 | 1190 | 9 2 9 3 1191 | <_> 1192 | 1193 | 9 4 1 1 1194 | <_> 1195 | 1196 | 9 6 2 1 1197 | <_> 1198 | 1199 | 9 28 6 4 1200 | <_> 1201 | 1202 | 10 0 9 3 1203 | <_> 1204 | 1205 | 10 3 1 1 1206 | <_> 1207 | 1208 | 10 10 11 11 1209 | <_> 1210 | 1211 | 10 15 4 3 1212 | <_> 1213 | 1214 | 11 4 2 1 1215 | <_> 1216 | 1217 | 11 27 4 3 1218 | <_> 1219 | 1220 | 11 36 8 2 1221 | <_> 1222 | 1223 | 12 0 2 2 1224 | <_> 1225 | 1226 | 12 23 4 3 1227 | <_> 1228 | 1229 | 12 25 4 3 1230 | <_> 1231 | 1232 | 12 29 5 3 1233 | <_> 1234 | 1235 | 12 33 3 4 1236 | <_> 1237 | 1238 | 13 0 2 2 1239 | <_> 1240 | 1241 | 13 36 8 3 1242 | <_> 1243 | 1244 | 14 0 2 2 1245 | <_> 1246 | 1247 | 15 15 2 2 1248 | <_> 1249 | 1250 | 16 13 3 4 1251 | <_> 1252 | 1253 | 17 0 1 3 1254 | <_> 1255 | 1256 | 17 1 3 3 1257 | <_> 1258 | 1259 | 17 31 5 3 1260 | <_> 1261 | 1262 | 17 35 3 1 1263 | <_> 1264 | 1265 | 18 13 2 3 1266 | <_> 1267 | 1268 | 18 39 2 1 1269 | <_> 1270 | 1271 | 19 0 7 15 1272 | <_> 1273 | 1274 | 19 2 7 2 1275 | <_> 1276 | 1277 | 19 3 7 13 1278 | <_> 1279 | 1280 | 19 14 2 2 1281 | <_> 1282 | 1283 | 19 24 7 4 1284 | <_> 1285 | 1286 | 20 1 6 13 1287 | <_> 1288 | 1289 | 20 8 7 3 1290 | <_> 1291 | 1292 | 20 9 7 3 1293 | <_> 1294 | 1295 | 20 13 1 1 1296 | <_> 1297 | 1298 | 20 14 2 3 1299 | <_> 1300 | 1301 | 20 30 3 2 1302 | <_> 1303 | 1304 | 21 0 3 4 1305 | <_> 1306 | 1307 | 21 0 6 8 1308 | <_> 1309 | 1310 | 21 3 6 2 1311 | <_> 1312 | 1313 | 21 6 6 4 1314 | <_> 1315 | 1316 | 21 37 2 1 1317 | <_> 1318 | 1319 | 22 3 6 2 1320 | <_> 1321 | 1322 | 22 13 1 2 1323 | <_> 1324 | 1325 | 22 22 4 3 1326 | <_> 1327 | 1328 | 23 0 2 3 1329 | <_> 1330 | 1331 | 23 3 6 2 1332 | <_> 1333 | 1334 | 23 9 5 4 1335 | <_> 1336 | 1337 | 23 11 1 1 1338 | <_> 1339 | 1340 | 23 15 1 1 1341 | <_> 1342 | 1343 | 23 16 3 2 1344 | <_> 1345 | 1346 | 23 35 2 1 1347 | <_> 1348 | 1349 | 23 36 1 1 1350 | <_> 1351 | 1352 | 23 39 6 2 1353 | <_> 1354 | 1355 | 24 0 2 3 1356 | <_> 1357 | 1358 | 24 8 6 11 1359 | <_> 1360 | 1361 | 24 28 2 2 1362 | <_> 1363 | 1364 | 24 33 4 4 1365 | <_> 1366 | 1367 | 25 16 4 3 1368 | <_> 1369 | 1370 | 25 31 5 3 1371 | <_> 1372 | 1373 | 26 0 1 2 1374 | <_> 1375 | 1376 | 26 0 2 2 1377 | <_> 1378 | 1379 | 26 0 3 2 1380 | <_> 1381 | 1382 | 26 24 4 4 1383 | <_> 1384 | 1385 | 27 30 4 5 1386 | <_> 1387 | 1388 | 27 36 5 3 1389 | <_> 1390 | 1391 | 28 0 2 2 1392 | <_> 1393 | 1394 | 28 4 2 1 1395 | <_> 1396 | 1397 | 28 21 2 5 1398 | <_> 1399 | 1400 | 29 8 2 1 1401 | <_> 1402 | 1403 | 33 0 2 1 1404 | <_> 1405 | 1406 | 33 0 4 2 1407 | <_> 1408 | 1409 | 33 0 4 6 1410 | <_> 1411 | 1412 | 33 3 1 1 1413 | <_> 1414 | 1415 | 33 6 4 12 1416 | <_> 1417 | 1418 | 33 21 4 2 1419 | <_> 1420 | 1421 | 33 36 4 3 1422 | <_> 1423 | 1424 | 35 1 2 2 1425 | <_> 1426 | 1427 | 36 5 1 1 1428 | <_> 1429 | 1430 | 36 29 3 4 1431 | <_> 1432 | 1433 | 36 39 2 2 1434 | <_> 1435 | 1436 | 37 5 2 2 1437 | <_> 1438 | 1439 | 38 6 2 1 1440 | <_> 1441 | 1442 | 38 6 2 2 1443 | <_> 1444 | 1445 | 39 1 2 12 1446 | <_> 1447 | 1448 | 39 24 1 2 1449 | <_> 1450 | 1451 | 39 36 2 2 1452 | <_> 1453 | 1454 | 40 39 1 2 1455 | <_> 1456 | 1457 | 42 4 1 1 1458 | <_> 1459 | 1460 | 42 20 1 2 1461 | <_> 1462 | 1463 | 42 29 1 2 1464 | -------------------------------------------------------------------------------- /Computer-Vision/Python/README.md: -------------------------------------------------------------------------------- 1 | # Facial Recognition & Identification on Raspberry Pi 2 | 3 | ![Facial Recognition & Identification on Raspberry Pi](../images/Raspberry-Pi-Computer-Vision-Example.png) 4 | 5 | ## Introduction 6 | Facial recognition and identification will soon be playing a major role in our every day lives. The technology opens up a whole new world of possibilities, and applies to almost every aspect of our lives. Use cases of facial recognition/identification include security systems, authentication systems, personalised smart homes, and home care assistants. 7 | 8 | ## What Will We Build? 9 | This tutorial will help you to build a Raspberry Pi that allows you to train a Haarcascades model, detect recognised/unknown people, optionally monitor the camera in near realtime via a stream, and communicate with the IoT JumpWay sending sensor and warning messages that will allow your device to autonomously communicate with other IoT devices on your IoT JumpWay network. 10 | 11 | This tutorial will use IoT JumpWay Python MQTT Library for communication, OpenCV for computer vision, Motion to stream the webcame on a local port and a secure Nginx server so that the stream can be accessed safely from the outside world. 12 | 13 | This example was our original version of TASS, since our move forward with more advanced computer vision libraries and frameworks, we decided to open up the source code. 14 | 15 | ## Python Versions 16 | 17 | - 2.7 18 | - 3.4 or above 19 | 20 | ## Software Requirements 21 | 22 | - [IoT JumpWay Python MQTT Client](https://github.com/iotJumpway/JumpWayMQTT "IoT JumpWay Python MQTT Client") 23 | 24 | ## Hardware requirements 25 | 26 | ![IoT JumpWay Raspberry Pi Computer Vision Example Docs](../images/Hardware.jpg) 27 | 28 | 1. Raspberry Pi. 29 | 2. Linux Compatible Webcam 30 | 31 | ## Before You Begin 32 | 33 | There are a few tutorials that you should follow before beginning, especially if it is the first time you have followed any of our Raspberry Pi tutorials or if it is the first time you have used the IoT JumpWay Developer Program. 34 | 35 | - [IoT JumpWay Developer Program Docs (5-10 minute read/setup)](https://github.com/iotJumpway/IoT-JumpWay-Docs/ "IoT JumpWay Developer Program Docs (5-10 minute read/setup)") 36 | 37 | - [Preparing Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/1-Raspberry-Pi-Prep.md "Preparing Your Raspberry Pi") 38 | 39 | - [Setup Domain Name & SSL For Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/3-Raspberry-Pi-Domain-And-SSL.md "Setup Domain Name & SSL For Your Raspberry Pi") 40 | 41 | - [Installing OpenCV On Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/2-Installing-OpenCV.md "Installing OpenCV On Your Raspberry Pi") 42 | 43 | - [Installing Linux Motion On Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/5-Installing-Motion.md "Installing Linux Motion On Your Raspberry Pi") 44 | 45 | - [Installing Secure Nginx Server For Linux Motion On Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/6-Secure-Nginx-Server-For-Motion.md "Installing Secure Nginx Server For Linux Motion On Raspberry Pi") 46 | 47 | - [Securing Your Raspberry Pi With IPTables](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/4-Securing-Your-Raspberry-Pi-With-IPTables.md "Securing Your Raspberry Pi With IPTables") 48 | 49 | ## Cloning The Repo 50 | 51 | You will need to clone the IoT JumpWay Raspberry Pi Examples repository to a location on your Raspberry Pi. Navigate to the directory you would like to download it to and issue the following commands, easiest is to download it to your home directory. 52 | 53 | $ git clone https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples.git 54 | 55 | ## Install Requirements 56 | 57 | Next you will need to navigate to the Computer-Vision directory and install the requirements 58 | 59 | $ cd IoT-JumpWay-RPI-Examples/Computer-Vision/Python 60 | $ pip install --upgrade pip 61 | $ pip install -r requirements.txt 62 | 63 | ## Installing Open CV 64 | 65 | OpenCv needs to be installed, follow the [Installing OpenCV On Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/2-Installing-OpenCV.md "Installing OpenCV On Your Raspberry Pi") tutorial to accomplish this, this is the computer vision library we will be using. 66 | 67 | ## Installing Linux Motion 68 | 69 | We will use Linux Motion to stream a live feed to a local port on the Raspberry Pi which OpenCv will connect to and read in the frames from the stream. To get Linux Motion set up, follow the [Installing Linux Motion On Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/5-Installing-Motion.md "Installing Linux Motion On Your Raspberry Pi") tutorial. 70 | 71 | There are some modifications to make here, in section 9 of the Motion tutorial, it tells you how to modify the directory where the media is saved, for this tutorial you should change that settings to: 72 | 73 | /home/YOURUSERNAME/IoT-JumpWay-RPI-Examples/Computer-Vision/Python/media 74 | 75 | Don't forget to check out section 10 with regards to turning off the saving of images to save diskspace. 76 | 77 | ## Setup Domain Name & SSL For Your Raspberry Pi 78 | 79 | We like to make sure that we try to provide tutorials that will help people learn to create secure projects. For the video stream to work securely, you will need to set up a domain name that is pointed to your Raspberry Pi, you will also need to set up an SSL certificate to ensure that the server used for streaming the video is secure. The [Setup Domain Name & SSL For Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/3-Raspberry-Pi-Domain-And-SSL.md "Setup Domain Name & SSL For Your Raspberry Pi") tutorial explains how to do this, if in doubt ask your registrar or host to assist you. If you cloned this repository to your home directory, the paths that you need to use for your CSR and key generation in the following tutorial are: 80 | 81 | ``` 82 | /etc/nginx/key.key 83 | ``` 84 | 85 | and 86 | 87 | ``` 88 | /etc/nginx/csr.csr 89 | ``` 90 | 91 | Once you have received your signed crt.crt and ca.crt file from certificate authority, you need to upload them to: 92 | 93 | ``` 94 | /etc/nginx/ca.crt 95 | ``` 96 | 97 | and 98 | 99 | ``` 100 | /etc/nginx/crt.crt 101 | ``` 102 | 103 | ## Installing A Secure Nginx Server For Linux Motion 104 | 105 | We will use Nginx as our server solution and set it up in a way that it has a Grade A+ SSL rating on Qualys SSL Labs SSL Report. To do this we have provided a guide in the [Installing Secure Nginx Server For Linux Motion On Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/6-Secure-Nginx-Server-For-Motion.md "Installing Secure Nginx Server For Linux Motion On Raspberry Pi"), follow this tutorial to set up your server. You will need of completed the [Installing Linux Motion On Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/5-Installing-Motion.md "Installing Linux Motion On Your Raspberry Pi") and [Setup Domain Name & SSL For Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/3-Raspberry-Pi-Domain-And-SSL.md "Setup Domain Name & SSL For Your Raspberry Pi") tutorials before starting this step. 106 | 107 | ## Securing Your Raspberry Pi With IPTables 108 | 109 | The next security step you should take is setting up IPTables, the following tutorial will show you how: 110 | 111 | [Securing Your Raspberry Pi With IPTables](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/4-Securing-Your-Raspberry-Pi-With-IPTables.md "Securing Your Raspberry Pi With IPTables") 112 | 113 | ## Video Stream 114 | 115 | Once you have followed the above steps, if they are not already running you need to do the following in this order: 116 | 117 | 1. Start Linux Motion: 118 | 119 | ``` 120 | $ sudo service motion start 121 | ``` 122 | 123 | OR: 124 | 125 | ``` 126 | $ sudo /etc/init.d/motion start 127 | ``` 128 | 129 | 2. Start Nginx: 130 | 131 | ``` 132 | $ sudo service nginx start 133 | ``` 134 | 135 | OR: 136 | 137 | ``` 138 | $ sudo /etc/init.d/nginx start 139 | ``` 140 | 141 | IMPORTANT: This way of streaming is a new feature and we are still ironing out some kinks, if you would like to have OpenCV access the webcam directly and not have Motion/Nginx streaming, uncomment line 43 in TASS.py and comment out lines 44 and 45. 142 | 143 | ## Connection Credentials & Sensor Settings 144 | 145 | The next steps will be to setup your device instance in the IoT JumpWay Developer Console. 146 | 147 | - Follow the [IoT JumpWay Location Device Doc](https://github.com/iotJumpway/IoT-JumpWay-Docs/blob/master/4-Location-Devices.md "IoT JumpWay Location Device Doc") to set up your device. You will need to set up a device that has a CCTV Camera added via the Sensors/Actuators section. 148 | 149 | ![IoT JumpWay Raspberry Pi Computer Vision Example Docs](../../images/main/Device-Creation.png) 150 | 151 | - Retrieve your connection credentials and update the **required/config.json** file with your new connection credentials and camera ID setting (You will need to go into the device page after creating it to get your correct camera ID). 152 | 153 | ``` 154 | "IoTJumpWay": { 155 | "Location": 0, 156 | "Zone": 0, 157 | "Device": 0, 158 | "DeviceName" : "", 159 | "App": 0, 160 | "AppName": "" 161 | } 162 | ``` 163 | 164 | ``` 165 | "StreamSettings":{ 166 | "streamIP":"", 167 | "streamPort":1234 168 | } 169 | ``` 170 | 171 | ``` 172 | "IoTJumpWayMQTT": { 173 | "MQTTUsername": "", 174 | "MQTTPassword": "", 175 | "AppMQTTUsername": "", 176 | "AppMQTTPassword": "" 177 | } 178 | ``` 179 | 180 | ## Training Your Data 181 | 182 | Now that the basics are set up, it is time to train your model with your own photos. When you download this repo, there will already be a trained model and processed images in the processed folder, but this model will not recognise you. You should make a good selection of photos of yourself in different positions and lighting. The more photos you train your model on, the more accurate it will be, if your device is not identifying you you simply need to train it with more images of yourself. 183 | 184 | You can add as many images as you like (Dependant on the space available on your RPI 3), for as many people as you like. To add training data navigate to the training folder and create a directory, the directory should be a number, and not a number that is already in the processed folder. 185 | 186 | Once you have built up your folder of images, head over to TASS.py and change line 34 (self.train = 0) to self.train = 1 and the start the program. The program will loop through your images and if it detects a face it will recreate an image in the format required for the model, save it to a matching folder in the processed directory, and delete the original image to save space. If it does not detect a face it will simply delete the original image as it is useless for the facial recognition. 187 | 188 | Once the processing stage has finished, your new model will automatically start training, once training is finished, it will automatically run the main facial recognition program. Put your face in front of your connected webcam and watch the output of the program as it tries to identify who you are. 189 | 190 | NOTE: Remove the README file from the processing directory. 191 | 192 | ## Executing The Program 193 | 194 | ``` 195 | $ sudo python/python3 TASS.py 196 | ``` 197 | 198 | ## Autonomous IoT Communication 199 | 200 | Each time your device detects a person, the device will send sensor data to the [IoT JumpWay](https://iot.techbubbletechnologies.com/ "IoT JumpWay") and warning alerts will be sent when the motion sensor picks up an intruder. You can use sensor values and warning messages to trigger autonomous communication with other devices you have connected to your IoT JumpWay Location Space. 201 | 202 | On the device edit page, scroll down to the "Create Rules" section under the "Actuators / Sensors". Here you can use the dropdown menu to create rules that allow your device to email you or to autonomously communicate with other devices on its network in the event of status updates, sensor data and warnings. 203 | 204 | ![IoT JumpWay IoT JumpWay Intel® Arduino/Genuino 101 DFRobot LCD Intruder System Example Docs](../../images/main/Device-Autonomous-Communication.png) 205 | 206 | ## Viewing Your Data 207 | 208 | You will be able to access the data in the [IoT JumpWay Developers Area](https://iot.techbubbletechnologies.com/developers/dashboard/ "IoT JumpWay Developers Area"). Once you have logged into the Developers Area, visit the [IoT JumpWay Location Devices Page](https://iot.techbubbletechnologies.com/developers/location-devices "Location Devices page"), find your device and then visit the "Sensor/Actuator Data" page and the "Commands Data" page to view the data sent from your device. 209 | 210 | ![IoT JumpWay Raspberry Pi Computer Vision Example Docs](../../images/main/SensorData.png) 211 | 212 | ![IoT JumpWay Raspberry Pi Computer Vision Example Docs](../../images/main/WarningData.png) 213 | 214 | ## Bugs/Issues 215 | 216 | Please feel free to create issues for bugs and general issues you come across whilst using the IoT JumpWay Raspberry Pi Examples. You may also use the issues area to ask for general help whilst using the IoT JumpWay Raspberry Pi Examples in your IoT projects. 217 | 218 | ## Contributors 219 | 220 | [![Adam Milton-Barker, Intel® Software Innovator](../../images/main/Intel-Software-Innovator.jpg)](https://github.com/AdamMiltonBarker) 221 | 222 | 223 | -------------------------------------------------------------------------------- /Computer-Vision/Python/TASS.py: -------------------------------------------------------------------------------- 1 | # ***************************************************************************** 2 | # Copyright (c) 2016 and other Contributors. 3 | # 4 | # All rights reserved. This program and the accompanying materials 5 | # are made available under the terms of the Eclipse Public License v1.0 6 | # which accompanies this distribution, and is available at 7 | # http://www.eclipse.org/legal/epl-v10.html 8 | # 9 | # Contributors: 10 | # Adam Milton-Barker - Limited 11 | # ***************************************************************************** 12 | 13 | import cv2 14 | import sys 15 | import os 16 | 17 | import time 18 | import json 19 | 20 | from datetime import datetime 21 | 22 | import JumpWayMQTT.Device as JWMQTTdevice 23 | from TASSCore import TassCore 24 | 25 | TassCore = TassCore() 26 | 27 | class TASS(): 28 | 29 | def __init__(self): 30 | 31 | self.jumpwayClient = "" 32 | self.configs = {} 33 | self.train = 0 34 | 35 | with open('required/config.json') as configs: 36 | self.configs = json.loads(configs.read()) 37 | 38 | self.startMQTT() 39 | 40 | print("LOADING VIDEO CAMERA") 41 | 42 | #self.OpenCVCapture = cv2.VideoCapture(0) 43 | self.OpenCVCapture = cv2.VideoCapture('http://'+self.configs["StreamSettings"]["streamIP"]+':'+self.configs["StreamSettings"]["streamPort"]+'/stream.mjpg') 44 | 45 | #self.OpenCVCapture.set(5, 30) 46 | #self.OpenCVCapture.set(3,640) 47 | #self.OpenCVCapture.set(4,480) 48 | 49 | def deviceCommandsCallback(self,topic,payload): 50 | 51 | print("Received command data: %s" % (payload)) 52 | newSettings = json.loads(payload.decode("utf-8")) 53 | 54 | def startMQTT(self): 55 | 56 | try: 57 | 58 | self.jumpwayClient = JWMQTTdevice.DeviceConnection({ 59 | "locationID": self.configs["IoTJumpWay"]["Location"], 60 | "zoneID": self.configs["IoTJumpWay"]["Zone"], 61 | "deviceId": self.configs["IoTJumpWay"]["Device"], 62 | "deviceName": self.configs["IoTJumpWay"]["DeviceName"], 63 | "username": self.configs["IoTJumpWayMQTT"]["MQTTUsername"], 64 | "password": self.configs["IoTJumpWayMQTT"]["MQTTPassword"] 65 | }) 66 | 67 | except Exception as e: 68 | print(str(e)) 69 | sys.exit() 70 | 71 | self.jumpwayClient.connectToDevice() 72 | self.jumpwayClient.subscribeToDeviceChannel("Commands") 73 | self.jumpwayClient.deviceCommandsCallback = self.deviceCommandsCallback 74 | 75 | TASS = TASS() 76 | model = cv2.face.createEigenFaceRecognizer(threshold=TASS.configs["ClassifierSettings"]["predictionThreshold"]) 77 | model.load(TASS.configs["ClassifierSettings"]["Model"]) 78 | print("LOADED STREAM & MODEL") 79 | while True: 80 | 81 | if(TASS.train==1): 82 | 83 | print("TRAINING MODE") 84 | TassCore.processTrainingData() 85 | TassCore.trainModel() 86 | TASS.train=0 87 | 88 | elif(TASS.configs["AppSettings"]["armed"]==1): 89 | 90 | try: 91 | 92 | ret, frame = TASS.OpenCVCapture.read() 93 | if not ret: continue 94 | 95 | currentImage,detected = TassCore.captureAndDetect(frame) 96 | if detected is None: 97 | continue 98 | 99 | image = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) 100 | x, y, w, h = detected 101 | crop = TassCore.resize(TassCore.crop(image, x, y, w, h)) 102 | label,confidence = model.predict(crop) 103 | 104 | if label: 105 | 106 | print("Person " + str(label) + " Confidence " +str(confidence)) 107 | 108 | TASS.jumpwayClient.publishToDeviceChannel( 109 | "Sensors", 110 | { 111 | "Sensor":"CCTV", 112 | "SensorID":TASS.configs["IoTJumpWaySettings"]["SystemCameraID"], 113 | "SensorValue":"USER: " + str(label) 114 | } 115 | ) 116 | 117 | else: 118 | 119 | print("Person not recognised " + str(label) + " Confidence "+str(confidence)); 120 | 121 | TASS.jumpwayClient.publishToDeviceChannel( 122 | "Sensors", 123 | { 124 | "Sensor":"CCTV", 125 | "SensorID":TASS.configs["IoTJumpWaySettings"]["SystemCameraID"], 126 | "SensorValue":"NOT RECOGNISED" 127 | } 128 | ) 129 | 130 | TASS.jumpwayClient.publishToDeviceChannel( 131 | "Warnings", 132 | { 133 | "WarningType":"CCTV", 134 | "WarningOrigin":TASS.configs["IoTJumpWaySettings"]["SystemCameraID"], 135 | "WarningValue":"Intruder", 136 | "WarningMessage":"An intruder has been detected" 137 | } 138 | ) 139 | 140 | time.sleep(1) 141 | 142 | except cv2.error as e: 143 | print(e) 144 | 145 | TASS.OpenCVCapture.release() 146 | cv2.destroyAllWindows() 147 | TASS.jumpwayClient.disconnectFromDevice() 148 | -------------------------------------------------------------------------------- /Computer-Vision/Python/TASSCore.py: -------------------------------------------------------------------------------- 1 | # ***************************************************************************** 2 | # Copyright (c) 2016 and other Contributors. 3 | # 4 | # All rights reserved. This program and the accompanying materials 5 | # are made available under the terms of the Eclipse Public License v1.0 6 | # which accompanies this distribution, and is available at 7 | # http://www.eclipse.org/legal/epl-v10.html 8 | # 9 | # Contributors: 10 | # Adam Milton-Barker - Limited 11 | # Andrej Petelin - Limited 12 | # ***************************************************************************** 13 | 14 | import numpy as np 15 | 16 | import struct 17 | import cv2 18 | import os 19 | import fnmatch 20 | import json 21 | from datetime import datetime 22 | 23 | class TassCore(): 24 | 25 | def __init__(self): 26 | 27 | with open('required/config.json') as configs: 28 | 29 | self._configs = json.loads(configs.read()) 30 | 31 | def captureAndDetect(self,frame): 32 | 33 | faceCascade = cv2.CascadeClassifier( os.getcwd()+'/'+self._configs["ClassifierSettings"]["HAAR_FACES"]) 34 | gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) 35 | 36 | faces = faceCascade.detectMultiScale(gray, 37 | scaleFactor=self._configs["ClassifierSettings"]["HAAR_SCALE_FACTOR"], 38 | minNeighbors=self._configs["ClassifierSettings"]["HAAR_MIN_NEIGHBORS"], 39 | minSize=(30,30) 40 | ) 41 | 42 | 43 | if not len(faces): 44 | faceCascade = cv2.CascadeClassifier( os.getcwd()+'/'+self._configs["ClassifierSettings"]["HAAR_FACES2"]) 45 | faces = faceCascade.detectMultiScale(gray, 46 | scaleFactor=self._configs["ClassifierSettings"]["HAAR_SCALE_FACTOR"], 47 | minNeighbors=self._configs["ClassifierSettings"]["HAAR_MIN_NEIGHBORS"], 48 | minSize=(30,30) 49 | ) 50 | 51 | if not len(faces): 52 | faceCascade = cv2.CascadeClassifier( os.getcwd()+'/'+self._configs["ClassifierSettings"]["HAAR_FACES3"]) 53 | faces = faceCascade.detectMultiScale(gray, 54 | scaleFactor=self._configs["ClassifierSettings"]["HAAR_SCALE_FACTOR"], 55 | minNeighbors=self._configs["ClassifierSettings"]["HAAR_MIN_NEIGHBORS"], 56 | minSize=(30,30) 57 | ) 58 | 59 | if not len(faces): 60 | faceCascade = cv2.CascadeClassifier( os.getcwd()+'/'+self._configs["ClassifierSettings"]["HAAR_PROFILES"]) 61 | faces = faceCascade.detectMultiScale(gray, 62 | scaleFactor=self._configs["ClassifierSettings"]["HAAR_SCALE_FACTOR"], 63 | minNeighbors=self._configs["ClassifierSettings"]["HAAR_MIN_NEIGHBORS"], 64 | minSize=(30,30) 65 | ) 66 | 67 | print( "Found " + str(len(faces)) + " face(s)") 68 | 69 | if len(faces): 70 | 71 | return frame, faces[0] 72 | 73 | else: 74 | 75 | return frame, None 76 | 77 | def resize(self,image): 78 | 79 | return cv2.resize(image,(self._configs["ClassifierSettings"]["width"], self._configs["ClassifierSettings"]["height"]),interpolation=cv2.INTER_LANCZOS4) 80 | 81 | def crop(self,image, x, y, w, h): 82 | crop_height = int((self._configs["ClassifierSettings"]["width"] / float(self._configs["ClassifierSettings"]["height"]))*w) 83 | midy = y + h/2 84 | y1 = max(0, midy-crop_height/2) 85 | y2 = min(image.shape[0]-1, midy+crop_height/2) 86 | return image[int(y1):int(y2), int(x):int(x)+int(w)] 87 | 88 | def prepareImage(self,filename): 89 | return self.resize(cv2.imread(filename, cv2.IMREAD_GRAYSCALE)) 90 | 91 | def normalize(self,X, low, high, dtype=None): 92 | X = np.asarray(X) 93 | minX, maxX = np.min(X), np.max(X) 94 | X = X - float(minX) 95 | X = X / float((maxX - minX)) 96 | X = X * (high-low) 97 | X = X + low 98 | if dtype is None: 99 | return np.asarray(X) 100 | return np.asarray(X, dtype=dtype) 101 | 102 | def processTrainingData(self): 103 | 104 | print("Processing Training Data") 105 | rootdir=os.getcwd()+"/training/" 106 | processeddir=os.getcwd()+"/processed/" 107 | 108 | count = 0 109 | 110 | for subdir, dirs, files in os.walk(rootdir): 111 | 112 | dirname = os.path.basename(os.path.normpath(subdir)) 113 | 114 | for file in files: 115 | 116 | newPayload = cv2.imread(os.getcwd()+'/training/'+dirname+"/"+file,1) 117 | faceCascade = cv2.CascadeClassifier( os.getcwd()+'/'+self._configs["ClassifierSettings"]["HAAR_FACES"]) 118 | faces = faceCascade.detectMultiScale(newPayload, 119 | scaleFactor=self._configs["ClassifierSettings"]["HAAR_SCALE_FACTOR"], 120 | minNeighbors=self._configs["ClassifierSettings"]["HAAR_MIN_NEIGHBORS"], 121 | minSize=(30,30), 122 | flags=cv2.CASCADE_SCALE_IMAGE 123 | ) 124 | 125 | if not len(faces): 126 | faceCascade = cv2.CascadeClassifier( os.getcwd()+'/'+self._configs["ClassifierSettings"]["HAAR_FACES2"]) 127 | faces = faceCascade.detectMultiScale(newPayload, 128 | scaleFactor=self._configs["ClassifierSettings"]["HAAR_SCALE_FACTOR"], 129 | minNeighbors=self._configs["ClassifierSettings"]["HAAR_MIN_NEIGHBORS"], 130 | minSize=(30,30), 131 | flags=cv2.CASCADE_SCALE_IMAGE 132 | ) 133 | 134 | if not len(faces): 135 | faceCascade = cv2.CascadeClassifier( os.getcwd()+'/'+self._configs["ClassifierSettings"]["HAAR_FACES3"]) 136 | faces = faceCascade.detectMultiScale(newPayload, 137 | scaleFactor=self._configs["ClassifierSettings"]["HAAR_SCALE_FACTOR"], 138 | minNeighbors=self._configs["ClassifierSettings"]["HAAR_MIN_NEIGHBORS"], 139 | minSize=(30,30), 140 | flags=cv2.CASCADE_SCALE_IMAGE 141 | ) 142 | 143 | if not len(faces): 144 | faceCascade = cv2.CascadeClassifier( os.getcwd()+'/'+self._configs["ClassifierSettings"]["HAAR_PROFILES"]) 145 | faces = faceCascade.detectMultiScale(newPayload, 146 | scaleFactor=self._configs["ClassifierSettings"]["HAAR_SCALE_FACTOR"], 147 | minNeighbors=self._configs["ClassifierSettings"]["HAAR_MIN_NEIGHBORS"], 148 | minSize=(30,30), 149 | flags=cv2.CASCADE_SCALE_IMAGE 150 | ) 151 | 152 | print(os.getcwd()+'/training/'+dirname+"/"+file) 153 | 154 | if len(faces): 155 | 156 | x, y, w, h = faces[0] 157 | print("Cropping image") 158 | cropped = self.crop(newPayload, x, y, w, h) 159 | print("Writing image " + dirname+"/"+file) 160 | 161 | if not os.path.exists(processeddir+'/'+dirname): 162 | os.makedirs(processeddir+'/'+dirname) 163 | 164 | 165 | newFile=datetime.now().strftime('%Y-%m-%d-%H-%M-%S')+'.pgm' 166 | 167 | cv2.imwrite(processeddir+'/'+dirname+"/"+newFile, cropped) 168 | os.remove(os.getcwd()+'/training/'+dirname+"/"+file) 169 | 170 | else: 171 | 172 | os.remove(os.getcwd()+'/training/'+dirname+"/"+file) 173 | print('REMOVED FILE') 174 | print("Finished Processing Training Data") 175 | 176 | def trainModel(self): 177 | 178 | print("Training") 179 | 180 | rootdir=os.getcwd()+"/processed/" 181 | 182 | faceArray=[] 183 | labelArray=[] 184 | count = 0 185 | 186 | MEAN_FILE = 'model/mean.png' 187 | POSITIVE_EIGENFACE_FILE = 'model/modelEigenvector.png' 188 | 189 | for subdir, dirs, files in os.walk(rootdir): 190 | dirname = os.path.basename(os.path.normpath(subdir)) 191 | print(dirname) 192 | for file in files: 193 | print (file) 194 | faceArray.append(self.prepareImage(rootdir+'/'+dirname+'/'+file)) 195 | labelArray.append(int(dirname)) 196 | print (file) 197 | count += 1 198 | 199 | print('Collected '+str(count)+' training images') 200 | 201 | print('Training model....') 202 | 203 | model = cv2.face.createEigenFaceRecognizer() 204 | model.train(np.asarray(faceArray), np.asarray(labelArray)) 205 | model.save(self._configs["ClassifierSettings"]["Model"]) 206 | print("Model saved to "+self._configs["ClassifierSettings"]["Model"]) 207 | 208 | mean = model.getMean().reshape(faceArray[0].shape) 209 | cv2.imwrite(MEAN_FILE,self.normalize(mean, 0, 255, dtype=np.uint8)) 210 | eigenvectors = model.getEigenVectors() 211 | eigenvector = eigenvectors[:,0].reshape(faceArray[0].shape) 212 | cv2.imwrite(POSITIVE_EIGENFACE_FILE,self.normalize(eigenvector, 0, 255, dtype=np.uint8)) 213 | 214 | print("Finished Training") -------------------------------------------------------------------------------- /Computer-Vision/Python/img/TASS-Banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Computer-Vision/Python/img/TASS-Banner.png -------------------------------------------------------------------------------- /Computer-Vision/Python/img/unavailable.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Computer-Vision/Python/img/unavailable.jpg -------------------------------------------------------------------------------- /Computer-Vision/Python/media/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Computer-Vision/Python/media/__init__.py -------------------------------------------------------------------------------- /Computer-Vision/Python/model/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Computer-Vision/Python/model/__init__.py -------------------------------------------------------------------------------- /Computer-Vision/Python/model/mean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Computer-Vision/Python/model/mean.png -------------------------------------------------------------------------------- /Computer-Vision/Python/model/modelEigenvector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Computer-Vision/Python/model/modelEigenvector.png -------------------------------------------------------------------------------- /Computer-Vision/Python/processed/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Computer-Vision/Python/processed/__init__.py -------------------------------------------------------------------------------- /Computer-Vision/Python/required/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "IoTJumpWay": { 3 | "Location": 0, 4 | "Zone": 0, 5 | "Device": 0, 6 | "DeviceName" : "", 7 | "App": 0, 8 | "AppName": "" 9 | }, 10 | "Actuators": {}, 11 | "Cameras": {}, 12 | "Sensors": {}, 13 | "StreamSettings":{ 14 | "streamIP":"", 15 | "streamPort":1234 16 | }, 17 | "IoTJumpWayMQTT": { 18 | "MQTTUsername": "", 19 | "MQTTPassword": "", 20 | "AppMQTTUsername": "", 21 | "AppMQTTPassword": "" 22 | }, 23 | "ClassifierSettings":{ 24 | "HAAR_FACES": "Haarcascades/lbpcascade_frontalface_improved.xml", 25 | "HAAR_FACES2": "Haarcascades/haarcascade_frontalface_alt.xml", 26 | "HAAR_FACES3": "Haarcascades/haarcascade_frontalface_alt2.xml", 27 | "HAAR_PROFILES": "Haarcascades/haarcascade_profileface.xml", 28 | "HAAR_SMILE": "Haarcascades/haarcascade_smile.xml", 29 | "HAAR_EYE": "Haarcascades/haarcascade_eye.xml", 30 | "HAAR_SCALE_FACTOR": 1.1, 31 | "HAAR_MIN_NEIGHBORS":4, 32 | "Model":"model/TASSModel.xml", 33 | "predictionThreshold":3000.0, 34 | "height":112, 35 | "width": 92 36 | } 37 | } -------------------------------------------------------------------------------- /Computer-Vision/Python/requirements.txt: -------------------------------------------------------------------------------- 1 | JumpWayMQTT 2 | -------------------------------------------------------------------------------- /Computer-Vision/Python/training/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Computer-Vision/Python/training/__init__.py -------------------------------------------------------------------------------- /Computer-Vision/images/Blinking.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Computer-Vision/images/Blinking.jpg -------------------------------------------------------------------------------- /Computer-Vision/images/Hardware.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Computer-Vision/images/Hardware.jpg -------------------------------------------------------------------------------- /Computer-Vision/images/Raspberry-Pi-Computer-Vision-Example-Hackster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Computer-Vision/images/Raspberry-Pi-Computer-Vision-Example-Hackster.png -------------------------------------------------------------------------------- /Computer-Vision/images/Raspberry-Pi-Computer-Vision-Example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Computer-Vision/images/Raspberry-Pi-Computer-Vision-Example.png -------------------------------------------------------------------------------- /Dev-Kit-IoT-Alarm/Python/Application.py: -------------------------------------------------------------------------------- 1 | ############################################################################################ 2 | # Title: IoT JumpWay Raspberry Pi Dev Kit Alarm Application 3 | # Description: Application for connecting to IoT connected alarm using Raspberry Pi. 4 | # Last Modified: 2018-04-22 5 | ############################################################################################ 6 | 7 | import time, sys, json 8 | 9 | import JumpWayMQTT.Application as JWMQTTapplication 10 | 11 | class Application(): 12 | 13 | def __init__(self): 14 | 15 | self.jumpwayClient = None 16 | self.configs = {} 17 | 18 | with open('required/confs.json') as configs: 19 | self.configs = json.loads(configs.read()) 20 | 21 | self.startMQTT() 22 | 23 | def startMQTT(self): 24 | 25 | try: 26 | 27 | self.jumpwayClient = JWMQTTapplication.ApplicationConnection({ 28 | "locationID": self.configs["IoTJumpWay"]["Location"], 29 | "applicationID": self.configs["IoTJumpWay"]["App"], 30 | "applicationName": self.configs["IoTJumpWay"]["AppName"], 31 | "username": self.configs["IoTJumpWayMQTT"]["AppMQTTUsername"], 32 | "password": self.configs["IoTJumpWayMQTT"]["AppMQTTPassword"] 33 | }) 34 | 35 | except Exception as e: 36 | print(str(e)) 37 | sys.exit() 38 | 39 | self.jumpwayClient.connectToApplication() 40 | 41 | Application = Application() 42 | 43 | while True: 44 | 45 | Application.jumpwayClient.publishToDeviceChannel( 46 | "Commands", 47 | Application.configs["IoTJumpWay"]["Zone"], 48 | Application.configs["IoTJumpWay"]["Device"], 49 | { 50 | "Actuator":"LED", 51 | "ActuatorID":Application.configs["Actuators"]["trueLED"]["ID"], 52 | "Command":"TOGGLE", 53 | "CommandValue":"ON" 54 | } 55 | ) 56 | 57 | time.sleep(5) 58 | 59 | Application.jumpwayClient.publishToDeviceChannel( 60 | "Commands", 61 | Application.configs["IoTJumpWay"]["Zone"], 62 | Application.configs["IoTJumpWay"]["Device"], 63 | { 64 | "Actuator":"LED", 65 | "ActuatorID":Application.configs["Actuators"]["trueLED"]["ID"], 66 | "Command":"TOGGLE", 67 | "CommandValue":"OFF" 68 | } 69 | ) 70 | 71 | time.sleep(5) 72 | 73 | Application.jumpwayClient.publishToDeviceChannel( 74 | "Commands", 75 | Application.configs["IoTJumpWay"]["Zone"], 76 | Application.configs["IoTJumpWay"]["Device"], 77 | { 78 | "Actuator":"LED", 79 | "ActuatorID":Application.configs["Actuators"]["falseLED"]["ID"], 80 | "Command":"TOGGLE", 81 | "CommandValue":"ON" 82 | } 83 | ) 84 | 85 | time.sleep(5) 86 | 87 | Application.jumpwayClient.publishToDeviceChannel( 88 | "Commands", 89 | Application.configs["IoTJumpWay"]["Zone"], 90 | Application.configs["IoTJumpWay"]["Device"], 91 | { 92 | "Actuator":"LED", 93 | "ActuatorID":Application.configs["Actuators"]["falseLED"]["ID"], 94 | "Command":"TOGGLE", 95 | "CommandValue":"OFF" 96 | } 97 | ) 98 | 99 | time.sleep(5) 100 | 101 | Application.jumpwayClient.publishToDeviceChannel( 102 | "Commands", 103 | Application.configs["IoTJumpWay"]["Zone"], 104 | Application.configs["IoTJumpWay"]["Device"], 105 | { 106 | "Actuator":"LED", 107 | "ActuatorID":Application.configs["Actuators"]["Buzzer"]["ID"], 108 | "Command":"TOGGLE", 109 | "CommandValue":"ON" 110 | } 111 | ) 112 | 113 | time.sleep(5) 114 | 115 | Application.jumpwayClient.publishToDeviceChannel( 116 | "Commands", 117 | Application.configs["IoTJumpWay"]["Zone"], 118 | Application.configs["IoTJumpWay"]["Device"], 119 | { 120 | "Actuator":"LED", 121 | "ActuatorID":Application.configs["Actuators"]["Buzzer"]["ID"], 122 | "Command":"TOGGLE", 123 | "CommandValue":"OFF" 124 | } 125 | ) 126 | 127 | time.sleep(5) 128 | 129 | Application.jumpwayClient.disconnectFromApplication() -------------------------------------------------------------------------------- /Dev-Kit-IoT-Alarm/Python/Device.py: -------------------------------------------------------------------------------- 1 | ############################################################################################ 2 | # Title: IoT JumpWay Raspberry Pi Dev Kit Alarm 3 | # Description: IoT connected alarm system for Raspberry Pi and Grove IoT Kit. 4 | # Last Modified: 2018/04/19 5 | ############################################################################################ 6 | 7 | print("") 8 | print("") 9 | print("!! Welcome to the IoT JumpWay Raspberry Pi Dev Kit Alarm, please wait while the program initiates !!") 10 | print("") 11 | 12 | import time, sys, json, grovepi 13 | 14 | import JumpWayMQTT.Device as JWMQTTdevice 15 | 16 | print("-- Running on Python "+sys.version) 17 | print("") 18 | 19 | class Device(): 20 | 21 | def __init__(self): 22 | 23 | self.jumpwayClient = None 24 | self.configs = {} 25 | 26 | with open('required/confs.json') as configs: 27 | self.configs = json.loads(configs.read()) 28 | 29 | self.startMQTT() 30 | 31 | print("") 32 | print("-- IoT JumpWay Raspberry Pi Dev Kit Alarm Initiated") 33 | print("") 34 | 35 | def commandsCallback(self,topic,payload): 36 | 37 | print("Received command data: %s" % (payload)) 38 | 39 | jsonData = json.loads(payload.decode("utf-8")) 40 | 41 | if int(jsonData['ActuatorID'])==self.configs["Actuators"]["trueLED"]["ID"] and jsonData['Command']=='TOGGLE' and jsonData['CommandValue']=='ON': 42 | 43 | grovepi.digitalWrite(self.configs["Actuators"]["trueLED"]["PIN"],1) 44 | 45 | elif int(jsonData['ActuatorID'])==self.configs["Actuators"]["falseLED"]["ID"] and jsonData['Command']=='TOGGLE' and jsonData['CommandValue']=='ON': 46 | 47 | grovepi.digitalWrite(self.configs["Actuators"]["falseLED"]["PIN"],1) 48 | 49 | elif int(jsonData['ActuatorID'])==self.configs["Actuators"]["Buzzer"]["ID"] and jsonData['Command']=='TOGGLE' and jsonData['CommandValue']=='ON': 50 | 51 | grovepi.digitalWrite(self.configs["Actuators"]["Buzzer"]["PIN"],1) 52 | 53 | elif int(jsonData['ActuatorID'])==self.configs["Actuators"]["trueLED"]["ID"] and jsonData['Command']=='TOGGLE' and jsonData['CommandValue']=='OFF': 54 | 55 | grovepi.digitalWrite(self.configs["Actuators"]["trueLED"]["PIN"],0) 56 | 57 | elif int(jsonData['ActuatorID'])==self.configs["Actuators"]["falseLED"]["ID"] and jsonData['Command']=='TOGGLE' and jsonData['CommandValue']=='OFF': 58 | 59 | grovepi.digitalWrite(self.configs["Actuators"]["falseLED"]["PIN"],0) 60 | 61 | elif int(jsonData['ActuatorID'])==self.configs["Actuators"]["Buzzer"]["ID"] and jsonData['Command']=='TOGGLE' and jsonData['CommandValue']=='OFF': 62 | 63 | grovepi.digitalWrite(self.configs["Actuators"]["Buzzer"]["PIN"],0) 64 | 65 | def startMQTT(self): 66 | 67 | try: 68 | 69 | self.jumpwayClient = JWMQTTdevice.DeviceConnection({ 70 | "locationID": self.configs["IoTJumpWay"]["Location"], 71 | "zoneID": self.configs["IoTJumpWay"]["Zone"], 72 | "deviceId": self.configs["IoTJumpWay"]["Device"], 73 | "deviceName": self.configs["IoTJumpWay"]["DeviceName"], 74 | "username": self.configs["IoTJumpWayMQTT"]["MQTTUsername"], 75 | "password": self.configs["IoTJumpWayMQTT"]["MQTTPassword"] 76 | }) 77 | 78 | except Exception as e: 79 | print(str(e)) 80 | sys.exit() 81 | 82 | self.jumpwayClient.connectToDevice() 83 | self.jumpwayClient.subscribeToDeviceChannel("Commands") 84 | self.jumpwayClient.deviceCommandsCallback = self.commandsCallback 85 | 86 | print("-- IoT JumpWay Initiated") 87 | 88 | Device = Device() 89 | 90 | grovepi.pinMode(Device.configs["Actuators"]["trueLED"]["PIN"],"OUTPUT") 91 | grovepi.pinMode(Device.configs["Actuators"]["falseLED"]["PIN"],"OUTPUT") 92 | grovepi.pinMode(Device.configs["Actuators"]["Buzzer"]["PIN"],"OUTPUT") 93 | 94 | grovepi.digitalWrite(Device.configs["Actuators"]["trueLED"]["PIN"],0) 95 | grovepi.digitalWrite(Device.configs["Actuators"]["falseLED"]["PIN"],0) 96 | grovepi.digitalWrite(Device.configs["Actuators"]["Buzzer"]["PIN"],0) 97 | 98 | while True: 99 | 100 | #grovepi.digitalWrite(Device.configs["Actuators"]["trueLED"]["PIN"],1) 101 | #grovepi.digitalWrite(Device.configs["Actuators"]["falseLED"]["PIN"],1) 102 | #grovepi.digitalWrite(Device.configs["Actuators"]["Buzzer"]["PIN"],1) 103 | #time.sleep(2) 104 | #grovepi.digitalWrite(Device.configs["Actuators"]["trueLED"]["PIN"],0) 105 | #grovepi.digitalWrite(Device.configs["Actuators"]["falseLED"]["PIN"],0) 106 | #grovepi.digitalWrite(Device.configs["Actuators"]["Buzzer"]["PIN"],0) 107 | #time.sleep(2) 108 | pass 109 | 110 | Device.jumpwayClient.disconnectFromDevice() -------------------------------------------------------------------------------- /Dev-Kit-IoT-Alarm/Python/README.md: -------------------------------------------------------------------------------- 1 | # IoT JumpWay Raspberry Pi Dev Kit IoT Alarm 2 | 3 | ![IoT JumpWay Raspberry Pi Dev Kit IoT Alarm](../images/Dev-Kit-IoT-Alarm.png) 4 | 5 | ## Introduction 6 | Want to take your first steps into the magical world of the Internet of Things, or want to find out how easy it is to use the IoT JumpWay as your secure IoT communication platform? This tutorial is for you and will hold your hand through setting up your first Raspberry Pi Dev Kit IoT Alarm project powered by the IoT JumpWay. 7 | 8 | ## What Will We Build? 9 | 10 | This tutorial is a simple tutorial that will help you take your first steps to using the IoT JumpWay to connect your IoT devices and applications to the Internet of Things. 11 | 12 | The tutorial will use IoT JumpWay Python MQTT Library for communication, a Raspberry Pi with a Grove IoT Dev Kit, 2 x LEDs, 1 x buzzer, and an application that can control the LEDs and buzzer via the IoT JumpWay. 13 | 14 | ## Python Versions 15 | 16 | - 3.4 or above 17 | 18 | ## Software Requirements 19 | 20 | - [IoT JumpWay Python MQTT Client](https://github.com/iotJumpway/JumpWayMQTT "IoT JumpWay Python MQTT Client") 21 | 22 | ## Hardware requirements 23 | 24 | ![IoT JumpWay Raspberry Pi Dev Kit IoT Alarm](../images/hardware.jpg) 25 | 26 | - 1 x Raspberry Pi 3 27 | - 1 x Grove starter kit for IoT, Raspberry Pi edition 28 | - 1 x Blue LED (Grove) 29 | - 1 x Red LED (Grove) 30 | - 1 x Buzzer (Grove) 31 | 32 | ## Before You Begin 33 | 34 | There are a few tutorials that you should follow before beginning, especially if it is the first time you have followed any of our Raspberry Pi tutorials or if it is the first time you have used the IoT JumpWay Developer Program. If this is the first time you have used the IoT JumpWay in your IoT projects, you will require a developer account and some basics to be set up before you can start creating your IoT devices. Visit the following [IoT JumpWay Developer Program Docs (5-10 minute read/setup)](https://github.com/iotJumpway/IoT-JumpWay-Docs/ "IoT JumpWay Developer Program Docs (5-10 minute read/setup)") and check out the guides that take you through registration and setting up your Location Space, Zones, Devices and Applications (About 5 minutes read). 35 | 36 | - [IoT JumpWay Developer Program Docs (5-10 minute read/setup)](https://github.com/iotJumpway/IoT-JumpWay-Docs/ "IoT JumpWay Developer Program Docs (5-10 minute read/setup)") 37 | 38 | - [Preparing Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/1-Raspberry-Pi-Prep.md "Preparing Your Raspberry Pi") 39 | 40 | ## Preparing Your Raspberry Pi 3 41 | 42 | Take some time to ensure your Raspberry Pi firmware and packages are up to date, and that your device is secure by following the [Raspberry Pi 3 Preparation Doc](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/1-Raspberry-Pi-Prep.md "Raspberry Pi 3 Preparation Doc") tutorial. 43 | 44 | ## Cloning The Repo 45 | 46 | You will need to clone this repository to a location on your Raspberry Pi 3. Navigate to the directory you would like to download it to and issue the following commands. 47 | 48 | $ git clone https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples.git 49 | 50 | ## Install Requirements 51 | 52 | $ cd IoT-JumpWay-RPI-Examples/Dev-Kit-IoT-Alarm/Python 53 | $ sudo pip3 install --upgrade pip 54 | $ sudo pip3 install -r requirements.txt 55 | $ curl -kL dexterindustries.com/update_grovepi | sudo bash 56 | 57 | Then reboot your Raspberry Pi. 58 | 59 | ## Setting Up Your Raspberry Pi 60 | 61 | ![IoT JumpWay Raspberry Pi Dev Kit IoT Alarm](../images/blinking.jpg) 62 | 63 | First of all you need to connect up an LED to your Raspberry Pi. 64 | 65 | 1. Connect your Grove IoT Dev Kit to your Raspberry Pi. 66 | 2. Connect one of your LEDs to pin D5 on your Grove shield, this will be your **"OK"** status LED. 67 | 3. Connect one of your LEDs to pin D6 on your Grove shield, this will be your **"WARNING"** status LED. 68 | 4. Connect your buzzer to D2 on Grove shield. 69 | 70 | ## Device / Application Connection Credentials & Sensor Settings 71 | 72 | - Follow the [IoT JumpWay Developer Program (BETA) Location Device Doc](https://github.com/iotJumpway/IoT-JumpWay-Docs/blob/master/4-Location-Devices.md "IoT JumpWay Developer Program (BETA) Location Device Doc") to set up your device, and the [IoT JumpWay Developer Program (BETA) Location Application Doc](https://github.com/iotJumpway/IoT-JumpWay-Docs/blob/master/5-Location-Applications.md "IoT JumpWay Developer Program (BETA) Location Application Doc") to set up your application. 73 | 74 | ![IoT JumpWay Raspberry Pi Dev Kit IoT Alarm](../../images/main/Device-Creation.png) 75 | 76 | - Retrieve your connection credentials and update the config.json file with your new connection credentials and actuator (falseLED, trueLED & Buzzer) settings. 77 | 78 | ``` 79 | "IoTJumpWay": { 80 | "Location": 0, 81 | "Zone": 0, 82 | "Device": 0, 83 | "DeviceName" : "", 84 | "App": 0, 85 | "AppName": "" 86 | } 87 | ``` 88 | 89 | ``` 90 | "Actuators": { 91 | "falseLED": { 92 | "ID": 0, 93 | "PIN": 5 94 | }, 95 | "trueLED": { 96 | "ID": 0, 97 | "PIN": 6 98 | }, 99 | "Buzzer": { 100 | "ID": 0, 101 | "PIN": 2 102 | } 103 | } 104 | ``` 105 | 106 | ``` 107 | "IoTJumpWayMQTT": { 108 | "MQTTUsername": "", 109 | "MQTTPassword": "", 110 | "AppMQTTUsername": "", 111 | "AppMQTTPassword": "" 112 | } 113 | ``` 114 | 115 | ## Execute The Programs 116 | 117 | $ sudo python/python3 Device.py 118 | $ sudo python/python3 Application.py 119 | 120 | ## Viewing Your Data 121 | 122 | Each command sent to the device is stored in the [IoT JumpWay](https://iot.techbubbletechnologies.com/ "IoT JumpWay"). You will be able to access the data in the [IoT JumpWay Developers Area](https://iot.techbubbletechnologies.com/developers/dashboard/ "IoT JumpWay Developers Area"). Once you have logged into the Developers Area, visit the [IoT JumpWay Location Devices Page](https://iot.techbubbletechnologies.com/developers/location-devices "Location Devices page"), find your device and then visit the Commands Data page to view the data sent from your device. 123 | 124 | ![IoT JumpWay Raspberry Pi Dev Kit IoT Alarm](../../images/main/SensorData.png) 125 | 126 | ![IoT JumpWay Raspberry Pi Dev Kit IoT Alarm](../../images/main/WarningData.png) 127 | 128 | ## Bugs/Issues 129 | 130 | Please feel free to create issues for bugs and general issues you come across whilst using the IoT JumpWay Raspberry Pi Examples. You may also use the issues area to ask for general help whilst using the IoT JumpWay Raspberry Pi Examples in your IoT projects. 131 | 132 | ## Contributors 133 | 134 | [![Adam Milton-Barker, Intel® Software Innovator](../../images/main/Intel-Software-Innovator.jpg)](https://github.com/AdamMiltonBarker) -------------------------------------------------------------------------------- /Dev-Kit-IoT-Alarm/Python/required/confs.json: -------------------------------------------------------------------------------- 1 | { 2 | "IoTJumpWay": { 3 | "Location": 0, 4 | "Zone": 0, 5 | "Device": 0, 6 | "DeviceName" : "", 7 | "App": 0, 8 | "AppName": "" 9 | }, 10 | "Actuators": { 11 | "falseLED": { 12 | "ID": 0, 13 | "PIN": 5 14 | }, 15 | "trueLED": { 16 | "ID": 0, 17 | "PIN": 6 18 | }, 19 | "Buzzer": { 20 | "ID": 0, 21 | "PIN": 2 22 | } 23 | }, 24 | "Cameras": {}, 25 | "Sensors": {}, 26 | "IoTJumpWayMQTT": { 27 | "MQTTUsername": "", 28 | "MQTTPassword": "", 29 | "AppMQTTUsername": "", 30 | "AppMQTTPassword": "" 31 | } 32 | } -------------------------------------------------------------------------------- /Dev-Kit-IoT-Alarm/Python/requirements.txt: -------------------------------------------------------------------------------- 1 | JumpWayMQTT -------------------------------------------------------------------------------- /Dev-Kit-IoT-Alarm/images/Dev-Kit-IoT-Alarm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Dev-Kit-IoT-Alarm/images/Dev-Kit-IoT-Alarm.png -------------------------------------------------------------------------------- /Dev-Kit-IoT-Alarm/images/blinking.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Dev-Kit-IoT-Alarm/images/blinking.jpg -------------------------------------------------------------------------------- /Dev-Kit-IoT-Alarm/images/hardware.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/Dev-Kit-IoT-Alarm/images/hardware.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IoT JumpWay Raspberry Pi Examples 2 | 3 | ![IoT JumpWay Docs](images/main/Raspberry-Pi-Examples.png) 4 | 5 | ## Introduction 6 | 7 | IoT JumpWay is an IoT PaaS that allows anyone to connect IoT devices such as Raspberry Pi, Intel® Galileo, Arduino, ESP8266 and even phones,PCs, Macs and laptops to the Internet of Things. The various IoT JumpWay libraries and samples allow you to connect devices and sensors to the IoT JumpWay and control/monitor sensors/actuators and data to and from the devices. 8 | 9 | The Raspberry Pi examples provide example projects that you can use to get started with using the IoT JumpWay for your IoT projects. 10 | 11 | ## Examples 12 | 13 | - [Basic: Basic LED Python Example](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/tree/master/Basic-LED/Python "Basic: Basic LED Python Example") 14 | 15 | - [Computer Vision: Facial Recognition & Identification Python Example](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/tree/master/Computer-Vision/Python "Computer Vision: Facial Recognition & Identification Python Example") 16 | 17 | ## Docs 18 | 19 | - [Preparing Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/1-Raspberry-Pi-Prep.md "Preparing Your Raspberry Pi") 20 | 21 | - [Setup Domain Name & SSL For Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/3-Raspberry-Pi-Domain-And-SSL.md "Setup Domain Name & SSL For Your Raspberry Pi") 22 | 23 | - [Installing OpenCV 3.2.0 On Your Raspberry Pi (LATEST RELEASE)](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/2-Installing-OpenCV-3-2-0.md "Installing OpenCV 3.2.0 On Your Raspberry Pi (LATEST RELEASE)") 24 | 25 | - [Installing OpenCV 3.1.0 On Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/2-Installing-OpenCV.md "Installing OpenCV 3.1.0 On Your Raspberry Pi") 26 | 27 | - [Installing Linux Motion On Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/5-Installing-Motion.md "Installing Linux Motion On Your Raspberry Pi") 28 | 29 | - [Installing Secure Nginx Server For Linux Motion On Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/6-Secure-Nginx-Server-For-Motion.md "Installing Secure Nginx Server For Linux Motion On Raspberry Pi") 30 | 31 | - [Securing Your Raspberry Pi With IPTables](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/4-Securing-Your-Raspberry-Pi-With-IPTables.md "Securing Your Raspberry Pi With IPTables") 32 | 33 | ## Bugs/Issues 34 | 35 | Please feel free to create issues for bugs and general issues you come across whilst using the IoT JumpWay Raspberry Pi Examples. You may also use the issues area to ask for general help whilst using the IoT JumpWay Raspberry Pi Examples in your IoT projects. 36 | 37 | ## Contributors 38 | 39 | [![Adam Milton-Barker, Intel® Software Innovator](images/main/Intel-Software-Innovator.jpg)](https://github.com/AdamMiltonBarker) -------------------------------------------------------------------------------- /_DOCS/1-Raspberry-Pi-Prep.md: -------------------------------------------------------------------------------- 1 | # Preparing your Raspberry Pi 2 | 3 | ![IoT JumpWay Docs](../images/main/Raspberry-Pi-Documentation.png) 4 | 5 | ## Introduction 6 | 7 | The following information will help you setup and secure your Raspberry Pi. 8 | 9 | ## Hardware Requirements 10 | 11 | 1. Raspberry Pi. 12 | 13 | ## Software Requirements 14 | 15 | 1. Jessie 16 | 17 | ## Guide 18 | 19 | 1. Expand your root file system: 20 | 21 | ``` 22 | $ sudo raspi-config --expand-rootfs 23 | $ sudo reboot 24 | ``` 25 | 26 | 2. Firmware update: 27 | 28 | ``` 29 | $ sudo rpi-update 30 | ``` 31 | 32 | 3. Update certificates: 33 | 34 | ``` 35 | $ sudo apt-get install ca-certificates 36 | ``` 37 | 38 | 3. Software update / upgrade: 39 | 40 | ``` 41 | $ sudo apt-get update 42 | $ sudo apt-get upgrade 43 | $ sudo apt-get dist-upgrade 44 | ``` 45 | 46 | 4. Create new superuser: 47 | 48 | ``` 49 | $ sudo useradd -m USERNAME -G sudo 50 | ``` 51 | 52 | 5. Change user password for new superuser: 53 | 54 | $ sudo passwd USERNAME 55 | 56 | 6. Reboot and login with new superuser 57 | 58 | ``` 59 | $ sudo reboot 60 | ``` 61 | 62 | 8. Check sudo powers: 63 | 64 | ``` 65 | $ sudo visudo 66 | ``` 67 | 68 | 9. Remove default Pi user and directory: 69 | 70 | ``` 71 | $ sudo deluser -remove-home pi 72 | ``` 73 | 74 | 10. Reboot 75 | 76 | ``` 77 | $ sudo reboot 78 | ``` 79 | 80 | ## Bugs/Issues 81 | 82 | Please feel free to create issues for bugs and general issues you come across whilst using the IoT JumpWay Raspberry Pi Examples. You may also use the issues area to ask for general help whilst using the IoT JumpWay Raspberry Pi Examples in your IoT projects. 83 | 84 | ## Contributors 85 | 86 | [![Adam Milton-Barker, Intel® Software Innovator](../images/main/Intel-Software-Innovator.jpg)](https://github.com/AdamMiltonBarker) -------------------------------------------------------------------------------- /_DOCS/2-Installing-OpenCV-3-2-0.md: -------------------------------------------------------------------------------- 1 | # Installation Of OpenCV 3.2.0 On Raspberry Pi 2 | 3 | ![IoT JumpWay Docs](../images/main/Raspberry-Pi-Documentation.png) 4 | 5 | #WARNING: This issue seems to be unstable with the Raspberry Pi, please feel to try it but at this moment it seems best to stick with 3.1.0 6 | 7 | ## Introduction 8 | 9 | The following information will help you install the latest version of OpenCV, 3.2.0, on your Raspberry Pi. This installation includes the additional modules required for facial identification. 10 | 11 | ## Hardware Requirements 12 | 13 | 1. Raspberry Pi. 14 | 2. 16 GB Card 15 | 16 | ## Software Requirements 17 | 18 | 1. Jessie 19 | 20 | ## Guide 21 | 22 | 1. Update apt-get: 23 | 24 | ``` 25 | $ sudo rpi-update 26 | $ sudo apt-get update 27 | $ sudo apt-get upgrade 28 | ``` 29 | 30 | 2. Install developer tools: 31 | 32 | ``` 33 | $ sudo apt-get install build-essential cmake cmake-curses-gui pkg-config 34 | ``` 35 | 36 | 3. Install required libraries: 37 | 38 | ``` 39 | $ sudo apt-get install \ 40 | libjpeg-dev \ 41 | libtiff5-dev \ 42 | libjasper-dev \ 43 | libpng12-dev \ 44 | libavcodec-dev \ 45 | libavformat-dev \ 46 | libswscale-dev \ 47 | libeigen3-dev \ 48 | libxvidcore-dev \ 49 | libx264-dev \ 50 | libgtk2.0-dev 51 | ``` 52 | 53 | 4. Install libraries used to optimize OpenCV: 54 | 55 | ``` 56 | $ sudo apt-get install libatlas-base-dev gfortran 57 | ``` 58 | 59 | 5. Install Python development libraries & Numpy: 60 | 61 | ``` 62 | $ sudo apt-get install python2.7-dev 63 | $ sudo apt-get install python3-dev 64 | ``` 65 | 66 | 6. Install Numpy: 67 | 68 | ``` 69 | $ pip install numpy 70 | $ pip3 install numpy 71 | ``` 72 | 73 | 7. Create a directory to home OpenCV and enter it: 74 | 75 | ``` 76 | $ mkdir opencv && cd opencv 77 | ``` 78 | 79 | 8. Checkout current OpenCV 3.2.0 & the contribs: 80 | 81 | ``` 82 | $ wget https://github.com/opencv/opencv/archive/3.2.0.zip -O opencv_source.zip 83 | $ wget https://github.com/opencv/opencv_contrib/archive/3.2.0.zip -O opencv_contrib.zip 84 | ``` 85 | 86 | 9. Unzip the code: 87 | 88 | ``` 89 | $ unzip opencv_source.zip 90 | $ unzip opencv_contrib.zip 91 | ``` 92 | 93 | 10. Move into the 3.2.0 directory, make the build dir and move into it: 94 | 95 | ``` 96 | $ cd ~/opencv/opencv-3.2.0 && mkdir build && cd build 97 | ``` 98 | 99 | 11. Configure the build: 100 | 101 | ``` 102 | $ sudo cmake -D CMAKE_BUILD_TYPE=RELEASE \ 103 | -D CMAKE_INSTALL_PREFIX=/usr/local \ 104 | -D BUILD_WITH_DEBUG_INFO=OFF \ 105 | -D BUILD_DOCS=OFF \ 106 | -D BUILD_EXAMPLES=OFF \ 107 | -D BUILD_TESTS=OFF \ 108 | -D BUILD_opencv_ts=OFF \ 109 | -D BUILD_PERF_TESTS=OFF \ 110 | -D INSTALL_C_EXAMPLES=OFF \ 111 | -D INSTALL_PYTHON_EXAMPLES=ON \ 112 | -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.2.0/modules \ 113 | -D ENABLE_NEON=ON \ 114 | -D WITH_LIBV4L=ON \ 115 | ../ 116 | ``` 117 | 12. If everything went ok you should see the following: 118 | 119 | ``` 120 | -- Configuring done 121 | -- Generating done 122 | ``` 123 | 124 | 13. Build OpenCV, grab a beer as this will take a while, come back and check at intervals to see if there has been any errors: 125 | 126 | ``` 127 | $ sudo make -j4 128 | ``` 129 | 130 | 14. Once complete you should see the following: 131 | 132 | ``` 133 | [100%] Built target ... 134 | ``` 135 | 136 | 15. Install OpenCV: 137 | 138 | ``` 139 | $ sudo make install 140 | $ sudo ldconfig 141 | ``` 142 | 143 | 16. Test the installation: 144 | 145 | ``` 146 | $ python/python3 147 | >> import cv2 148 | >> print (cv2.__version__) 149 | >> import face 150 | ``` 151 | 152 | 17. If you do not see any errors here, congratulations, you have successfully installed the latest version of OpenCV on your Raspberry Pi, grab another beer to celebrate your accomplishment. 153 | 154 | ## Bugs/Issues 155 | 156 | Please feel free to create issues for bugs and general issues you come across whilst using the IoT JumpWay Raspberry Pi Examples. You may also use the issues area to ask for general help whilst using the IoT JumpWay Raspberry Pi Examples in your IoT projects. 157 | 158 | ## Contributors 159 | 160 | [![Adam Milton-Barker, Intel® Software Innovator](../images/main/Intel-Software-Innovator.jpg)](https://github.com/AdamMiltonBarker) -------------------------------------------------------------------------------- /_DOCS/2-Installing-OpenCV.md: -------------------------------------------------------------------------------- 1 | # Installation Of OpenCV 3.1.0 On Raspberry Pi 2 | 3 | ![IoT JumpWay Docs](../images/main/Raspberry-Pi-Documentation.png) 4 | 5 | ## Introduction 6 | 7 | The following information will help you install OpenCV3.1.0 on your Raspberry Pi. This installation includes the additional modules required for facial identification. 8 | 9 | ## Hardware Requirements 10 | 11 | 1. Raspberry Pi. 12 | 2. 16 GB Card 13 | 14 | ## Software Requirements 15 | 16 | 1. Jessie 17 | 18 | ## Guide 19 | 20 | 1. Update apt-get: 21 | 22 | ``` 23 | $ sudo apt-get update 24 | $ sudo apt-get upgrade 25 | ``` 26 | 27 | 2. Install developer tools: 28 | 29 | ``` 30 | $ sudo apt-get install build-essential cmake git pkg-config 31 | ``` 32 | 33 | 3. Install image I/O packages: 34 | 35 | ``` 36 | $ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev 37 | ``` 38 | 39 | 4. Install GTK development library: 40 | 41 | ``` 42 | $ sudo apt-get install libgtk2.0-dev 43 | ``` 44 | 45 | A member pointed out they had issues with this library, if so you may also want to try: 46 | 47 | ``` 48 | $ sudo apt-get install libgtk2.0-dev pkg-config 49 | ``` 50 | 51 | 5. Install video processing software: 52 | 53 | ``` 54 | $ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev 55 | ``` 56 | 57 | 6. Install libraries used to optimize OpenCV: 58 | 59 | ``` 60 | $ sudo apt-get install libatlas-base-dev gfortran 61 | ``` 62 | 63 | 7. Install Python 2.7 development libraries: 64 | 65 | ``` 66 | $ sudo apt-get install python2.7-dev 67 | ``` 68 | 69 | 8. Install Numpy: 70 | 71 | ``` 72 | $ pip install numpy 73 | ``` 74 | 75 | 9. Checkout current OpenCV 3.1.0: 76 | 77 | ``` 78 | $ cd ~ 79 | $ git clone https://github.com/Itseez/opencv.git 80 | $ cd opencv 81 | $ git checkout 3.1.0 82 | ``` 83 | 84 | 10. Checkout OpenCV Modules 3.1.0: 85 | 86 | ``` 87 | $ cd ~ 88 | $ git clone https://github.com/Itseez/opencv_contrib.git 89 | $ cd opencv_contrib 90 | $ git checkout 3.1.0 91 | ``` 92 | 93 | 11. There is an issue with some of the code that needs to be fixed before you can build: 94 | 95 | ``` 96 | $ nano ~/opencv_contrib/blob/master/modules/face/include/opencv2/face.hpp 97 | ``` 98 | 99 | Change line 259 to: 100 | 101 | ``` 102 | CV_WRAP_AS(predict_label) int predict(InputArray src) const; 103 | ``` 104 | 105 | 12. Setup the build: 106 | 107 | ``` 108 | $ cd ~/opencv 109 | $ mkdir build 110 | $ cd build 111 | $ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules -D BUILD_EXAMPLES=ON .. 112 | ``` 113 | 114 | 13. Make and make install the build: 115 | 116 | ``` 117 | $ make -j4 118 | $ sudo make install 119 | $ sudo ldconfig 120 | ``` 121 | 122 | ## Bugs/Issues 123 | 124 | Please feel free to create issues for bugs and general issues you come across whilst using the IoT JumpWay Raspberry Pi Examples. You may also use the issues area to ask for general help whilst using the IoT JumpWay Raspberry Pi Examples in your IoT projects. 125 | 126 | ## Contributors 127 | 128 | [![Adam Milton-Barker, Intel® Software Innovator](../images/main/Intel-Software-Innovator.jpg)](https://github.com/AdamMiltonBarker) -------------------------------------------------------------------------------- /_DOCS/3-Raspberry-Pi-Domain-And-SSL.md: -------------------------------------------------------------------------------- 1 | 2 | # Setup Domain Name & SSL For Your Raspberry Pi 3 | 4 | ![IoT JumpWay Docs](../images/main/Raspberry-Pi-Documentation.png) 5 | 6 | ## Introduction 7 | 8 | To help ensure that data passed between your Raspberry Pi and any connecting web services is encrypted an important thing to do is to add SSL encryption to your requests. The following information will help you setup a domain name for your Raspberry Pi, forward the domain to your device IP, and secure the connection with SSL. 9 | 10 | ## Guide 11 | 12 | 1. Ensure your local network has a static IP, you will be able to purchase one from your ISP. You can use service such as no-ip.com but this is not the preferred method and is out of the scope of this tutorial. 13 | 14 | 2. Ensure all ports are closed on your router with the exception of ones that you need for your applications. 15 | 16 | 3. Purchase a domain name and install it on a web server, I get mine from NameCheap.com. In the following steps we will use subdomain of this domain to point towards your local network. 17 | 18 | 4. Purchase your SSL certificate, I get mine from NameCheap.com, when you buy a domain name from Namecheap you can get an SSL for $1.99 for the first year. 19 | 20 | 5. Once your domain is installed on your server, find and edit the domain zone file to include a sub domain that uses an A record to point to the static IP of your local network. 21 | 22 | 6. Set up a port forward from your router to the local IP address of your Raspberry Pi. 23 | 24 | 7. Login to your Raspberry Pi via SSH and generate an RSA key and a CSR that will be used to activate your SSL certificate. Use the following command to generate your RSA key. If you have come to this document via a tutorial for our example projects, the tutorial will tell you the path to use below: 25 | 26 | ``` 27 | $ openssl genrsa -out ~/PATH_TO_YOUR_CERT_FOLDER/YOUR_KEY_FILE.key 2048 28 | ``` 29 | 30 | 8. Use the following command to generate your CSR. If you have come to this document via a tutorial for our example projects, the tutorial will tell you the path to use below: 31 | 32 | ``` 33 | $ openssl req -new -sha256 -key ~/PATH_TO_YOUR_CERT_FOLDER/YOUR_KEY_FILE.key -out ~/PATH_TO_YOUR_CERT_FOLDER/YOUR_CSR_FILE.csr 34 | ``` 35 | 36 | 37 | 9. You will be asked a few questions at this stage, complete them all but ensure to not enter a password when prompted to, just hit enter. 38 | 39 | 10. Head over to where you bought the SSL certificate from and activate your SSL cert using the CSR you generated on your Raspberry Pi, once verified you will receive your SSL certificate files. 40 | 41 | 11. Connect to your Raspberry Pi using SFTP, for this I always WinSCP on Windows but you can use FileZilla or the FTP client of your choice. Once connected, upload your SSL .crt file to the certs folder specified in the related guide for the project you are setting up. 42 | 43 | ## Bugs/Issues 44 | 45 | Please feel free to create issues for bugs and general issues you come across whilst using the IoT JumpWay Raspberry Pi Examples. You may also use the issues area to ask for general help whilst using the IoT JumpWay Raspberry Pi Examples in your IoT projects. 46 | 47 | ## Contributors 48 | 49 | [![Adam Milton-Barker, Intel® Software Innovator](../images/main/Intel-Software-Innovator.jpg)](https://github.com/AdamMiltonBarker) -------------------------------------------------------------------------------- /_DOCS/4-Securing-Your-Raspberry-Pi-With-IPTables.md: -------------------------------------------------------------------------------- 1 | # Securing Your Raspberry Pi With IPTables 2 | 3 | ![IoT JumpWay Docs](../images/main/Raspberry-Pi-Documentation.png) 4 | 5 | ## Introduction 6 | 7 | If youa re going to have your Raspberry Pi accessible via the outside world, the minimum security step you should take is to ensure that only ports that you absolutely require to be open are open. IPTables allows you to specify which ports are accessible on your Raspberry Pi by blocking them all and allowing access to only the ports that you white list. IPTables has a lot of features and methods here are the basics: 8 | 9 | ## Guide 10 | 11 | 1. Check that IPTables is installed using the following command, if it is, you will see a message saying so, if it is not, it will be installed: 12 | 13 | ``` 14 | $ sudo apt-get install iptables 15 | ``` 16 | 17 | 2. If/once installed you can check your current configs by running one of the following commands: 18 | 19 | ``` 20 | $ sudo iptables -L 21 | ``` 22 | or 23 | 24 | ``` 25 | $ sudo iptables -L -v 26 | ``` 27 | 28 | 3. Next, create a new config file for IPTables and modify the code to your liking. This will block all traffic to your Raspberry Pi except SSH and the specified ports you white list. To create your new config file you would issue the following command: (I am using nano but you can use your favorite text editor) 29 | 30 | ``` 31 | $ sudo nano /etc/iptables 32 | ``` 33 | 34 | 4. Next, add the following code and modify to your preference (You may need to remove indentation and whitespace): 35 | 36 | ``` 37 | *filter 38 | 39 | # Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0 40 | 41 | -A INPUT -i lo -j ACCEPT 42 | 43 | -A INPUT -d 127.0.0.0/8 -j REJECT 44 | 45 | # Accept all established inbound connections 46 | 47 | -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT 48 | 49 | # Allow all outbound traffic - you can modify this to only allow certain traffic 50 | 51 | -A OUTPUT -j ACCEPT 52 | 53 | # Allow HTTP and HTTPS connections from the port number you specified in your project config.json file, replace YOUR PORT NUMBER with your specified port number. 54 | 55 | -A INPUT -p tcp --dport YOUR PORT NUMBER -j ACCEPT 56 | 57 | # Allow SSH connections, the -dport number should be the same port number you set in sshd_config 58 | 59 | -A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT 60 | 61 | # Allow ping 62 | 63 | -A INPUT -p icmp -j ACCEPT 64 | 65 | # Log iptables denied calls 66 | 67 | -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7 68 | 69 | # Drop all other inbound - default deny unless explicitly allowed policy 70 | 71 | -A INPUT -j DROP 72 | 73 | -A FORWARD -j DROP 74 | 75 | COMMIT 76 | ``` 77 | 78 | 5. Once you have modified and saved your config file, add a rule to /etc/network/interfaces by opening it: 79 | 80 | ``` 81 | $ sudo nano /etc/network/interfaces 82 | ``` 83 | 84 | 6. To ensure that the firewall is loaded each and everytime you boot up your Raspberry Pi, add the following line to the end of the file then save: 85 | 86 | ``` 87 | pre-up iptables-restore < /etc/iptables 88 | ``` 89 | 90 | 7. Load the new rules: 91 | 92 | ``` 93 | $ sudo iptables-restore < /etc/iptables 94 | ``` 95 | 96 | 8. Check if it has worked, you should see the rules you added in the output of the following command. 97 | 98 | ``` 99 | $ sudo iptables-save 100 | 101 | ``` 102 | 103 | 9. Reboot your Raspberry Pi and your firewall should boot up on startup everytime now. 104 | 105 | ## Bugs/Issues 106 | 107 | Please feel free to create issues for bugs and general issues you come across whilst using the IoT JumpWay Raspberry Pi Examples. You may also use the issues area to ask for general help whilst using the IoT JumpWay Raspberry Pi Examples in your IoT projects. 108 | 109 | ## Contributors 110 | 111 | [![Adam Milton-Barker, Intel® Software Innovator](../images/main/Intel-Software-Innovator.jpg)](https://github.com/AdamMiltonBarker) -------------------------------------------------------------------------------- /_DOCS/5-Installing-Motion.md: -------------------------------------------------------------------------------- 1 | # Installation Of Linux Motion On Raspberry Pi 2 | 3 | ![IoT JumpWay Docs](../images/main/Raspberry-Pi-Documentation.png) 4 | 5 | ## Introduction 6 | 7 | The following information will help you install Linux Motion on your Raspberry Pi. 8 | 9 | PLEASE NOTE: 10 | 11 | - This is a basic tutorial that will result in an insecure stream, in project tutorials where we use Linux Motion, we will take you through creating a secure stream. 12 | - Motion will store images and videos on your Raspberry Pi, if you do not keep on top of them your diskspace will quickly fill up, check out section 10 of this guide for more info. 13 | 14 | ## Hardware Requirements 15 | 16 | 1. Raspberry Pi 17 | 18 | ## Guide 19 | 20 | 1. Update your packages and install Motion: 21 | 22 | ``` 23 | $ sudo apt-get update 24 | $ sudo apt-get upgrade 25 | $ sudo apt-get install motion 26 | ``` 27 | 28 | 2. Execute the following to open up the configuration file: 29 | 30 | ``` 31 | $ sudo nano /etc/motion/motion.conf 32 | ``` 33 | 34 | 3. Make the following changes: 35 | 36 | ``` 37 | DAEMON = OFF 38 | stream_localhost off 39 | ``` 40 | 41 | 4. If you want to change the port that the webcam is streamed to change the following value. It is a good idea to change the port so that it does not use the default port. 42 | 43 | ``` 44 | stream_port = 8081 45 | ``` 46 | 47 | 5. In my case I am using a camera that is 1280 x 780, motion may not work if you do not have the correct resolution set for your camera, to modify the dimensions find and edit the following in the config file: 48 | 49 | ``` 50 | width 640 51 | height 380 52 | ``` 53 | 54 | 6. If you want to change the quality of the images and video stream, change the following line: 55 | 56 | ``` 57 | quality 90 58 | stream_quality 90 59 | ``` 60 | 61 | 7. We want our stream to be as fast possible, in order to do so, find and modify the following line, I use 30 as my camera is 30 fps: 62 | 63 | ``` 64 | framerate 2 65 | stream_maxrate 1 66 | ``` 67 | 68 | 8. If you want to be able to see where it picks up motion on the stream, set the following to on: 69 | 70 | ``` 71 | locate_motion_mode off 72 | ``` 73 | 74 | 9. If you want to change the location that the images and videos are saved to, change the following location: 75 | 76 | ``` 77 | target_dir 78 | ``` 79 | 80 | If you change this value you should make sure you have given the correct permissions for Motion: 81 | 82 | ``` 83 | chgrp motion PATH_TO_YOUR_DIRECTORY 84 | chmod g+rwx PATH_TO_YOUR_DIRECTORY 85 | chmod -R g+w PATH_TO_YOUR_DIRECTORY 86 | ``` 87 | 88 | 10. Using Motion with the default settings will result in images being saved to the target_dir which will eventually use up all of your diskspace. If you would like to turn this feature off so that only videos are saved, find and edit the following line: 89 | 90 | ``` 91 | output_pictures off 92 | ``` 93 | 94 | 11. Close the file and save your changes. 95 | 96 | 12. Execute the following to open up the daemon configuration: 97 | 98 | ``` 99 | $ sudo nano /etc/default/motion 100 | ``` 101 | 102 | 13. Make the following change: 103 | 104 | ``` 105 | start_motion_daemon = yes 106 | ``` 107 | 108 | 14. Check Linux Motion is working, execute the following command and then navigate to YOUR_RPI_IP:8081 109 | 110 | ``` 111 | sudo service motion start 112 | ``` 113 | 114 | These are just some settings that we think will be useful to you, review the full motion.conf file for all possible settings. 115 | 116 | ## Bugs/Issues 117 | 118 | Please feel free to create issues for bugs and general issues you come across whilst using the IoT JumpWay Raspberry Pi Examples. You may also use the issues area to ask for general help whilst using the IoT JumpWay Raspberry Pi Examples in your IoT projects. 119 | 120 | ## Contributors 121 | 122 | [![Adam Milton-Barker, Intel® Software Innovator](../images/main/Intel-Software-Innovator.jpg)](https://github.com/AdamMiltonBarker) -------------------------------------------------------------------------------- /_DOCS/6-Secure-Nginx-Server-For-Motion.md: -------------------------------------------------------------------------------- 1 | # Installation Of SECURE Nginx Server For Motion On Raspberry Pi 2 | 3 | ![IoT JumpWay Docs](../images/main/Raspberry-Pi-Documentation.png) 4 | 5 | ## Introduction 6 | 7 | The following information will help you install a secure Nginx server for your Motion stream on your Raspberry Pi. 8 | 9 | ## Hardware Requirements 10 | 11 | 1. Raspberry Pi 12 | 13 | ## Before You Begin 14 | 15 | Before you begin you should follow the tutorials below as this tutorial is for securing the Linux Motion stream, you should follow the [Installing Linux Motion On Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/4-Securing-Your-Raspberry-Pi-With-IPTables.md "Installing Linux Motion On Your Raspberry Pi") tutorial first. This tutorial will not work without following the [Setup Domain Name & SSL For Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/3-Raspberry-Pi-Domain-And-SSL.md "Setup Domain Name & SSL For Your Raspberry Pi") tutorial. 16 | 17 | - [Installing Linux Motion On Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/4-Securing-Your-Raspberry-Pi-With-IPTables.md "Installing Linux Motion On Your Raspberry Pi") 18 | 19 | - [Setup Domain Name & SSL For Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/3-Raspberry-Pi-Domain-And-SSL.md "Setup Domain Name & SSL For Your Raspberry Pi") 20 | 21 | - [Securing Your Raspberry Pi With IPTables](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/4-Securing-Your-Raspberry-Pi-With-IPTables.md "Securing Your Raspberry Pi With IPTables") 22 | 23 | ## Guide 24 | 25 | 1. Update your packages and install Nginx: 26 | 27 | ``` 28 | $ sudo apt-get update 29 | $ sudo apt-get upgrade 30 | $ sudo apt-get install nginx 31 | ``` 32 | 33 | 2. Start Nginx and check it is working by visting the IP address of your Raspberry Pi: 34 | 35 | ``` 36 | $ sudo service nginx start 37 | ``` 38 | 39 | 3. Execute the followin commands, this will take some time so kick back with a beer. 40 | 41 | ``` 42 | $ cd /etc/nginx 43 | $ sudo openssl dhparam -out dh2048.pem 2048 44 | ``` 45 | 46 | 4. After following the [Setup Domain Name & SSL For Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/3-Raspberry-Pi-Domain-And-SSL.md "Setup Domain Name & SSL For Your Raspberry Pi") tutorial, place your ca.crt, crt.crt and key.key files into the /etc/nginx folder. 47 | 48 | 5. Execute the following to open up the configuration file: 49 | 50 | ``` 51 | $ sudo nano /etc/nginx/sites-enabled/default 52 | ``` 53 | 54 | 6. Replace its contents with the following: 55 | 56 | ``` 57 | server { 58 | listen 80; 59 | return 301 https://$host$request_uri; 60 | } 61 | server { 62 | listen 443 ssl; 63 | server_name YOUR_DOMAIN_NAME; 64 | 65 | add_header Strict-Transport-Security max-age=31536000; 66 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 67 | ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS; 68 | ssl_buffer_size 8k; 69 | ssl_prefer_server_ciphers on; 70 | ssl_session_cache shared:SSL:30m; 71 | ssl_session_timeout 30m; 72 | 73 | ssl_certificate /etc/nginx/crt.crt; 74 | ssl_certificate_key /etc/nginx/key.key; 75 | 76 | ssl_stapling on; 77 | resolver 8.8.8.8; 78 | ssl_stapling_verify on; 79 | 80 | ssl_dhparam /etc/nginx/dh2048.pem; 81 | ssl_trusted_certificate /etc/nginx/ca.crt; 82 | 83 | location / { 84 | proxy_pass http://YOUR_RPI_IP:YOUR_MOTION_STREAM_PORT; 85 | } 86 | 87 | } 88 | ``` 89 | 90 | 7. Replace the following in the above script: 91 | 92 | ``` 93 | YOUR_DOMAIN_NAME -> Your SSL secured domain name 94 | YOUR_RPI_IP -> Your Raspberry Pi IP address 95 | YOUR_MOTION_STREAM_PORT -> The port on your Raspberry Pi that you set Motion to stream to 96 | ``` 97 | 98 | 8. Reload / Restart Nginx: 99 | 100 | ``` 101 | sudo service nginx reload 102 | ``` 103 | 104 | 10. Commands to reload / start / stop the Nginx server: 105 | 106 | ``` 107 | sudo service nginx start 108 | sudo service nginx stop 109 | sudo service nginx reload 110 | ``` 111 | 112 | ## Bugs/Issues 113 | 114 | Please feel free to create issues for bugs and general issues you come across whilst using the IoT JumpWay Raspberry Pi Examples. You may also use the issues area to ask for general help whilst using the IoT JumpWay Raspberry Pi Examples in your IoT projects. 115 | 116 | ## Contributors 117 | 118 | [![Adam Milton-Barker, Intel® Software Innovator](../images/main/Intel-Software-Innovator.jpg)](https://github.com/AdamMiltonBarker) -------------------------------------------------------------------------------- /_DOCS/README.md: -------------------------------------------------------------------------------- 1 | # IoT JumpWay Raspberry Pi Documentation & Tutorials 2 | 3 | ![IoT JumpWay Docs](../images/main/Raspberry-Pi-Documentation.png) 4 | 5 | ## Introduction 6 | 7 | Here you will find an index of the documentation and tutorials available in the IoT JumpWay Raspberry Pi Documentation & Tutorials 8 | 9 | ## Documentation & Tutorials 10 | 11 | - [Preparing Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/1-Raspberry-Pi-Prep.md "Preparing Your Raspberry Pi") 12 | 13 | - [Setup Domain Name & SSL For Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/3-Raspberry-Pi-Domain-And-SSL.md "Setup Domain Name & SSL For Your Raspberry Pi") 14 | 15 | - [Installing OpenCV 3.2.0 On Your Raspberry Pi (LATEST RELEASE)](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/2-Installing-OpenCV-3-2-0.md "Installing OpenCV 3.2.0 On Your Raspberry Pi (LATEST RELEASE)") 16 | 17 | - [Installing OpenCV 3.1.0 On Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/2-Installing-OpenCV.md "Installing OpenCV 3.1.0 On Your Raspberry Pi") 18 | 19 | - [Installing Linux Motion On Your Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/5-Installing-Motion.md "Installing Linux Motion On Your Raspberry Pi") 20 | 21 | - [Installing Secure Nginx Server For Linux Motion On Raspberry Pi](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/6-Secure-Nginx-Server-For-Motion.md "Installing Secure Nginx Server For Linux Motion On Raspberry Pi") 22 | 23 | - [Securing Your Raspberry Pi With IPTables](https://github.com/iotJumpway/IoT-JumpWay-RPI-Examples/blob/master/_DOCS/4-Securing-Your-Raspberry-Pi-With-IPTables.md "Securing Your Raspberry Pi With IPTables") 24 | 25 | ## Bugs/Issues 26 | 27 | Please feel free to create issues for bugs and general issues you come across whilst using the IoT JumpWay Raspberry Pi Examples. You may also use the issues area to ask for general help whilst using the IoT JumpWay Raspberry Pi Examples in your IoT projects. 28 | 29 | ## Contributors 30 | 31 | [![Adam Milton-Barker, Intel® Software Innovator](../images/main/Intel-Software-Innovator.jpg)](https://github.com/AdamMiltonBarker) -------------------------------------------------------------------------------- /images/main/Device-Autonomous-Communication.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/images/main/Device-Autonomous-Communication.png -------------------------------------------------------------------------------- /images/main/Device-Creation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/images/main/Device-Creation.png -------------------------------------------------------------------------------- /images/main/Intel-Software-Innovator.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/images/main/Intel-Software-Innovator.jpg -------------------------------------------------------------------------------- /images/main/Raspberry-Pi-Documentation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/images/main/Raspberry-Pi-Documentation.png -------------------------------------------------------------------------------- /images/main/Raspberry-Pi-Examples.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/images/main/Raspberry-Pi-Examples.png -------------------------------------------------------------------------------- /images/main/SensorData.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/images/main/SensorData.png -------------------------------------------------------------------------------- /images/main/WarningData.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotJumpway/RPI-Examples/3c918db278d5ffb2508b28b249cd1aa707237816/images/main/WarningData.png --------------------------------------------------------------------------------