Skip to content

Commit

Permalink
Replaced python3 version with golang version on master
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Apr 16, 2016
1 parent 7b589ff commit e129c53
Show file tree
Hide file tree
Showing 212 changed files with 20,065 additions and 15,215 deletions.
37 changes: 37 additions & 0 deletions BENCHMARKS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

# Benchmarks 04/16/2016

Current coverage (`go test -cover`): 21.2%.

To test first start process on one terminal `./gofind`, and then in another window `./testing/testdb.sh`. Then you can close `./gofind` and run with `go test -bench=. -test.benchmem`.

### i7-3370 @ 3.4GHz

2,058 fingerprints
```
BenchmarkPutFingerprintInDatabase-8 100 19446095 ns/op 1496173 B/op 212 allocs/op
BenchmarkGetFingerprintInDatabase-8 1000 1544347 ns/op 53459 B/op 94 allocs/op
BenchmarkLoadFingerprint-8 200000 10224 ns/op 2481 B/op 32 allocs/op
BenchmarkLoadCompressedFingerprint-8 50000 48337 ns/op 44866 B/op 40 allocs/op
BenchmarkDumpFingerprint-8 200000 6906 ns/op 2388 B/op 44 allocs/op
BenchmarkDumpCompressedFingerprint-8 2000 894943 ns/op 1463963 B/op 119 allocs/op
BenchmarkLoadParameters-8 100 13045162 ns/op 1616906 B/op 3752 allocs/op
BenchmarkGetParameters-8 50 34637830 ns/op 5575188 B/op 33086 allocs/op
BenchmarkCalculatePosteriors1-8 50000 31700 ns/op 2687 B/op 12 allocs/op
BenchmarkOptimizePriors-8 2 863536600 ns/op 180279556 B/op 335850 allocs/op
BenchmarkOptimizePriorsThreaded-8 3 424329900 ns/op 159378608 B/op 326170 allocs/op
BenchmarkOptimizePriorsThreadedNot-8 3 454433666 ns/op 155175656 B/op 233557 allocs/op
BenchmarkCrossValidation-8 10 102343250 ns/op 6530782 B/op 26685 allocs/op
BenchmarkCalculatePriors-8 100 15477659 ns/op 954329 B/op 4706 allocs/op
```



### [Python](https://github.com/schollz/find/tree/python3) vs. GO

Both benchmarked using `testing/testdb.sh` which has 344 fingerprints in 3 locations using Intel i7-3370.

| Version | Fingerprints sent to /learn | Optimizing priors through /calculate |
|---------|-----------------------------|--------------------------------------|
| [Python](https://github.com/schollz/find/tree/python3) | 15 fingerprints/sec | 3 calculations/min |
| Go | 76 fingerprints/sec | 619 calculations/min |
863 changes: 201 additions & 662 deletions LICENSE

Large diffs are not rendered by default.

197 changes: 88 additions & 109 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,162 +1,141 @@
[![Join the chat at https://gitter.im/schollz/find](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/schollz/find?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Version 0.21prealpha](https://img.shields.io/badge/version-0.21prealpha-brightgreen.svg)](https://www.internalpositioning.com/guide/development/)
<center>
# ![Image](https://www.internalpositioning.com/guide/img/wifi-marker-darkgrey-small.png) FIND

![Image](https://www.internalpositioning.com/guide/img/wifi-marker-darkgrey-small.png)
[![Join the chat at https://gitter.im/schollz/find](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/schollz/find?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Version 2.0](https://img.shields.io/badge/version-2.0-brightgreen.svg)](https://www.internalpositioning.com/guide/development/)
[![Go Report Card](https://goreportcard.com/badge/github.com/schollz/gofind)](https://goreportcard.com/report/github.com/schollz/gofind)

</center>

- [Requirements](#requirements)
- [Server setup](#server-setup)
- [Using FIND](#using-find)
- [1. Fingerprint locations](#1-fingerprint-locations)
- [2. Analyze fingerprints](#2-analyze-fingerprints)
- [3. Track locations](#3-track-locations)

- [Screenshots](#screenshots)
- [Contact us](#contact-us)

**The Framework for Internal Navigation and Discovery** (_FIND_) allows you to use your smartphone or laptop to determine your position within your home or office. You can easily use this system in place of motion sensors as its resolution will allow your phone to distinguish whether you are in the living room, the kitchen or the bedroom, etc. The position information can then be used in a variety of ways including home automation, way-finding, or tracking!
**The Framework for Internal Navigation and Discovery** (_FIND_) allows you to use your (Android) smartphone or laptop to determine your position within your home or office. You can easily use this system in place of motion sensors as its resolution will allow your phone to distinguish whether you are in the living room, the kitchen or the bedroom, etc. The position information can then be used in a variety of ways including home automation, way-finding, or tracking!
<blockquote>Simply put, FIND will allow you to replace <em>tons</em> of motion sensors with a <em>single</em> smartphone!</blockquote>

The system is built on two main components - a server and a fingerprinting device. The fingerprinting device (computer or android app) sends the specified data to the machine learning server which stores the fingerprints and analyzes them. It then returns the result to the device and stores the result on the server for accessing via a web browser or triggering via hooks.

More information? Check out [our splash page overview](http://www.internalpositioning.com/), the [FAQ](https://www.internalpositioning.com/guide/faq/), and the [API](http://www.internalpositioning.com/guide/api/).

# Requirements
To use this system you need to have the following
- Linux / Mac / Cygwin (Windows). Windows is not yet supported (but will be soon). Raspberry Pi is supported!
- Python3 installed
- Either WiFi capable laptop or Android smartphone
- (Optional) Android Studio installed ([in case you want to build the app yourself](https://www.internalpositioning.com/guide/deploy/#building-android-app))

# Server setup
_Note: you don't have to setup a server at all. If you'd like, you can use [our demo server](http://finddemo.duckdns.org) - simply [follow the quickstart guide](https://www.internalpositioning.com/guide/getting-started/) to get going._
# Features

Installation is very simple. Simply download the latest source code:
- SSL support
- Compression to keep DBs small
- [Fast]() (20-200x faster than the [previous Python version]())

```
git clone https://github.com/schollz/find.git
cd find/
sudo python3 setup.py
```
# Requirements
To use this system you need to have the following:
- A device (laptop/Raspberry Pi/Android smartphone) that has access to WiFi
- (Optional) A computer (OS X/Windows/Linux) to run the server. If you don't have this, use [ours](https://ml.internalpositioning.com).

and then install:

_Note: when you run the installation you will be downloading binaries containing the classification (stored in [releases](https://github.com/schollz/find/releases)). This is the only part of the code that is not open. The classification algorithm is compiled in an attempt to obfuscate how it works. Even though the algorithm is solely and unequivocally my own original creation, there are currently tons of patents being submitted about Wifi-based positioning. I don't want to be responsible for possibly causing people to accidentally infringe on patent-holders, so I opted to make it more difficult for a patent holder to find my exact implementation. I suppose I could check all the patents to make sure I'm not infringing, but I rather stay ignorant to what they've done in order to better my case that mine is an original work._
# Setup

```
sudo python3 setup.py
```
## 1. Server (optional)

After which you will be prompted to enter the `address` and `port` of your server. If you want to run on a home network run `ifconfig` to check your address (it will be something like `192.168.X.Y` usually). If you want to use an public address you can also use that. Note: if you are using a reverse proxy you can also set the `external address`, but if not, you can just leave that blank.
_Note:_ You are welcome to skip this step and use [our server](https://ml.internalpositioning.com), just make sure to point the server address to https://ml.internalpositioning.com.

To run **FIND** simply use:
```bash
$ git clone https://github.com/schollz/gofind.git
$ cd gofind
$ go get ./...
$ go build
$ ./gofind
-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----
,_ . ._. _. .
, _-\','|~\~ ~/ ;-'_ _-' ,;_;_, ~~-
/~~-\_/-'~'--' \~~| ', ,' / / ~|-_\_/~/~ ~~--~~~~'--_
/ ,/'-/~ '\ ,' _ , '|,'|~ ._/-, /~
~/-'~\_, '-,| '|. ' ~ ,\ /'~ / /_ /~
.-~ '| '',\~|\ _\~ ,_ , /|
'\ /'~ |_/~\\,-,~ \ " ,_,/ |
| / ._-~'\_ _~| \ ) /
\ __-\ '/ ~ |\ \_ / ~
., '\ |, ~-_ - | \\_' ~| /\ \~ ,
~-_' _; '\ '-, \,' /\/ |
'\_,~'\_ \_ _, /' ' |, /|'
/ \_ ~ | / \ ~'; -,_.
| ~\ | | , '-_, ,; ~ ~\
\, / \ / /| ,-, , -,
| ,/ | |' |/ ,- ~ \ '.
,| ,/ \ ,/ \ |
/ | ~ -~~-, / _
| ,-' ~ /
/ ,' ~
',| ~
~'
-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----
_________ _____
/ __/ _/ |/ / _ \ ______ _____ _____ ____
/ _/_/ // / // / (_-< -_) __/ |/ / -_) __/
/_/ /___/_/|_/____/ /___|__/_/ |___/\__/_/
(version 2.X) is up and running on http://192.168.1.2:8003
-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----
```
python3 server.py
```
To actually use the system you will need a fingerprinting device. The easiest thing to do is to use [our app from Google Play](https://play.google.com/store/apps/details?id=com.hcp.find&hl=en) or [build the app yourself](https://www.internalpositioning.com/guide/deploy/#building-android-app). Alternatively, you don't have to build an app at all and can simply use your laptop via the [the fingerprinting program](https://github.com/schollz/find/blob/master/computer/fingerprinting.py), more details [here](https://www.internalpositioning.com/guide/deploy/#laptop-computer).
## 2. Client
# Using FIND
## 1. Fingerprint locations
### If you want to use the app...
First [download the app from the Google Play store](https://play.google.com/store/apps/details?id=com.hcp.find).
The client gathers WiFi fingerprints and sends them to the server.
![Guide to starting app](http://www.internalpositioning.com/guide/img/guide_app_guide_1.png)
If you want to use an Android device, [download our app](https://play.google.com/store/apps/details?id=com.hcp.find), or [build the app yourself]().
To begin fingerprinting, stand in a location and enter the location name into the app. Then hit the "learn" button in the app. Then simply press `ON`. The app will then run at the specified interval, even in the background. To stop the fingerprinting you have to press `OFF` and to stop the program entirely you have to press `EXIT`.
If you want to use a computer (laptop/Raspberry Pi/etc.), [download our client](), or [build it yourself]().
### If you want to use a laptop...
Any computer with a WiFi card or laptops will be able to use FIND as well. Its simple to get started. If you cloned the repository, goto `computer/` to find `fingerprinting.py`. If you haven't cloned the repository, you can simply [download the fingerprinting.py script]([the fingerprinting program](https://github.com/schollz/find/blob/master/computer/fingerprinting.py)).
# Usage
To fingerprint locations simply use
## App
```bash
python3 fingerprinting.py -l "some location" -u "some user" -g "some group" -s "localhost" -p 8888 -c 10 -r learn
```
When you start up the app you will be asked for a username (enter whatever you want) and you'll be assigned a unique group name. Then you'll see the following:
![App1](https://i.imgur.com/bGVVQeW.png =100x)
which will send 10 fingerprints to the server located at `localhost:8888` of "some location" for "some user" in "some group." If you are using the demo server, simply set "server" to `finddemo.duckdns.org` and do not include the port. If you are running locally you probably want "server" to be "localhost" and port to be whatever you specified. The name of "your group" can be whatever you want.
Simply click "Learn" and you'll be prompted for a location name.
Repeat this process for a few different locations, making sure to change "some location" to whatever location you are currently located.
![App2](https://i.imgur.com/cqab0bl.png)
## 2. Analyze fingerprints
Now that you have learned several fingerprints, open a web browser and navigate to the dashboard page at `http://address:port/` or [http://finddemo.duckdns.org](http://finddemo.duckdns.org) if you are using the demo server. Login with the name of your group that you specified in the app or in the script.
After you enter a location, the app will connect to the server and then submit fingerprints.
Once you login you'll be able to access the "Dashboard." This dashboard page contains all the information about the learned fingerprints and the analysis. More information about the dashboard page can be found on the [API documentation](/api/#webpages).
![App3](https://i.imgur.com/kwwLVGL.png)
The dashboard has many options and edits that you can do. For now, the only thing you need to do is press the button `Calculate All and Find Parameters` which will automatically optimize the parameters and generate the dataset you need for tracking.
After you've learned some locations, just hit "Track" and you'll see your calculated location.
![Guide to analyzing fingerprints with app](http://www.internalpositioning.com/guide/img/guide_dashboard.png)
![App4](https://i.imgur.com/3mMV7e7.png)
## 3. Track locations
To see your current position classification, simply hit "Classifications" from the webpage that you visited to see the dashboard. This classifications are automatically updated as new information is available from the app/laptop. Sending the tracking information is very easy:
To see more detailed information, goto [the server](https://ml.internalpositioning.com) and login with your group name
### If you want to use the app...
Simply go back to the app and click the "track" button and then hit `ON`. Now you are tracking!
![Guide to analyzing fingerprints](http://www.internalpositioning.com/guide/img/guide_tracking.png)
## Client program
### If you want to use a laptop...
To track locations simply use
To start learning locations simply use
```bash
python3 fingerprinting.py -u "user name" -g "your group" -s "server" -p "port" -c 1000 -r track
./fingerprint -e
```
which will run 1000 times.

# Screenshots
## Sign-in
<center>

![Screenshot of the signin](https://www.internalpositioning.com/guide/img/signin1.png)
and then to track your location use
</center>

<br>
<center>

![Landing](https://www.internalpositioning.com/guide/img/landing2.png) _Screenshot of the landing page_

</center><br>
```bash
./fingerprint
```
## Monitor location in realtime
<center>
There are other options, you can learn more by [looking at the README](). To see more detailed information, goto [the server](https://ml.internalpositioning.com) and login with your group name
![Screenshot of the classifications page](https://www.internalpositioning.com/guide/img/classifications1.png)
## Server
</center><br>
You can see statistics about your fingeprints by logging on to the server and signing in with your group name.
## Visualize accuracy and errors
<center>
![stats](https://i.imgur.com/HSGVyDb.jpg)
![Charts show a clear diagnostics of the accuracy for each room](https://www.internalpositioning.com/guide/img/stats1.png)
You can see fingerprints of individual places by clicking on them
</center><br>
<center>
![places](https://i.imgur.com/3l5UPub.jpg)
![Pie charts lets you visualize the classification errors](https://www.internalpositioning.com/guide/img/pies1.png)
and then you can click on mac addresses to see there statistics across rooms
</center><br>
![macs](https://i.imgur.com/Udi3xrn.jpg)
## Visualize raw data
<center>
The server also reveals realtime tracking
![In-depth analysis of the raw fingerprint data](https://www.internalpositioning.com/guide/img/signals1.png)
![realtime](https://i.imgur.com/IAn5Hss.jpg)
</center><br>
## Tip of the iceberg
![Tip of the iceberg](http://www.internalpositioning.com/guide/img/iceberg.png)
# Acknowledgements
There are lots of other features available which you can start investigating when you get used to the app and server. Some things to check out:
- [Build your own app](http://www.internalpositioning.com/guide/deploy/#building-android-app) with internal positioning builtin.
- [Use the RESTFUL API](http://www.internalpositioning.com/guide/api/#routes) for your own applications, like home automation.
- [Deploy the server at home](http://www.internalpositioning.com/guide/deploy/#server-setup).
Thanks to [patorjk](http://patorjk.com/software/taag/) and [asciiworld](http://www.asciiworld.com/) for the ASCII art.
# Contact us
- Email: [[email protected]]([email protected])
- Gitter: [Join room](https://gitter.im/schollz/find)
- Github Issues: [Open an issue](https://github.com/schollz/find/issues/new)
- Subscribe: [Get latest updates](http://hypercubeplatforms.us10.list-manage1.com/subscribe?u=885d1826479b36238603d935c&id=dfc8e534c4)
[Imgur](https://imgur.com/a/yjvci) for [hosting](https://imgur.com/a/3yGjV) images
5 changes: 0 additions & 5 deletions TODO.md

This file was deleted.

21 changes: 21 additions & 0 deletions android/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Zack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit e129c53

Please sign in to comment.