Skip to content
This repository was archived by the owner on Jun 6, 2019. It is now read-only.

Commit ec91809

Browse files
wanghongjuanDonnaWuDongxia
authored andcommitted
[samples] add ocf realsense samples (#229)
* [samples] add ocf realsense samples to this folder - add two samples for ocf realsense samples to this repository * [samples] format all js files using eslint
1 parent 7a1c636 commit ec91809

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+131624
-0
lines changed

samples/ocf-realsense/README.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# RealSense OCF Demos
2+
These samples illustrate how to develop applications using Intel® RealSense™ JavaScript [API](https://01org.github.io/node-realsense/doc/spec) and Open Connectivity Foundation™ ([OCF](https://openconnectivity.org)) JavaScript [API](https://github.com/01org/zephyr.js/blob/master/docs/ocf.md).
3+
4+
## Architecture
5+
6+
![Image](./doc/sh-ocf-arc.png?raw=true)
7+
8+
## Demos
9+
The following demos are provided in this release.
10+
- **Control light by distance**(demo1): This sample app illustrates the use of libRealsense, libPT, and the Linux SDK Framework to use the ZR300 camera's depth and color sensors to detect people in the scene. Detected person in the scene will be displayed with the distance information on screen. Meanwhile, the led light will be on and off according to the person's position changing.
11+
- **Control light/buzzer by person recognition**(demo2):This sample app illustrates how to register new users to the database, upload the database to identify them when they appear in the scene. Recognized person in the scene will light a green led, otherwise light a red one and open buzzer.
12+
13+
## Get Start
14+
15+
### Hardware
16+
- PC with Ubuntu 16.04
17+
- [MinnowBoard Turbot](https://store.netgate.com/Turbot2.aspx)
18+
- [Intel® RealSense™ Camera ZR300](https://newsroom.intel.com/chip-shots/intel-announces-tools-realsense-technology-development/)
19+
- [Grove Chainable RGB LED](http://www.seeedstudio.com/depot/twig-chainable-rgb-led-p-850.html?cPath=156_157)
20+
- [Grove Buzzer](http://wiki.seeed.cc/Grove-Buzzer/)
21+
22+
### Setup RealSense Execution Environment on Ubuntu
23+
24+
1. Please refer to this [tutorial](https://github.com/01org/node-realsense/blob/master/doc/setup_environment.md) to set up RealSense test environment on Ubuntu.
25+
26+
2. Execute belows commands to start this demo journey:
27+
```bash
28+
# git clone https://github.com/wanghongjuan/ocf-realsense-demos.git
29+
# cd ocf-realsense-demos
30+
# export API_SERVER_HOST=<The-OCF-Server-board-ip>
31+
```
32+
Please follow below guide to set up ocf server environment at first, then you can enter directory "demo1" or "demo2", following the corresponding README file to launch the demo.
33+
34+
35+
### Setup OCF Server Test Environment on MinnowBoard Turbot
36+
1. Please follow this [instruction](https://minnowboard.org/tutorials/installing-ubuntu-16.04-on-minnowboardmax) to install Ubuntu 16.04 on MinnowBoard Turbot.
37+
38+
2. Install Node.js at first, v6.11.2 preferred(https://nodejs.org/en/download/package-manager/)
39+
3. There are some dependencies(uuid-dev, libcure4-openssl-dev and a C++ compiler (gcc-5 or later) etc.) need to install at first, you can install them via command:
40+
```bash
41+
# sudo apt-get install uuid-dev libcurl4-openssl-dev libboost-all-dev sqlite3 libsqlite3-dev glib2.0-dev scons git
42+
```
43+
4. Install [`iot-rest-api-server`](https://github.com/01org/iot-rest-api-server) via command `npm install iot-rest-api-server`, for detail information, please refer to [here](https://github.com/01org/iot-rest-api-server/blob/master/README.md). Launch the rest api server:
44+
```bash
45+
# cd node_modules/iot-rest-api-server
46+
# node index.js &
47+
```
48+
5. The other dependence is `libmraa` that Low Level Skeleton Library for Communication on GNU/Linux platforms, you can install it via `npm install mraa`.
49+
50+
6. Please refer to this [guidance](./ocf-servers/README.md#setting-up-the-hw) to setup the sensors on this board
51+
52+
7. Copy the downloaded repo "ocf-realsense-demo/ocf-servers" from the host to this board, then execute below commands to launch all sensors server as administrator(user "root").
53+
```bash
54+
# which node #Remember this node path
55+
# pwd #Remember this ocf-servers path
56+
# sudo -i
57+
# export PATH=$PATH:[path-to-node]
58+
# cd [path-to-ocf-servers]
59+
# npm install
60+
# export NODE_DEBUG=buzzer;node buzzer.js &
61+
# export NODE_DEBUG=rgb_led;node rgb_led.js &
62+
```
63+
Check these launched server resources whether can be found via iot-rest-api-server
64+
```bash
65+
# cd <path-of-restapi-install>
66+
# ./test/oic-get /res
67+
```
68+
Then you can find the registered resource `/a/buzzer` and `/a/rgbled`.

samples/ocf-realsense/demo1/README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Demo 1
2+
3+
This GUI app displays the live color preview from the camera within a browser and draw red rectangles around the person(s) detected in the camera frame with a color dot indicating the center of mass for the detected persons in the frame. It also displays the Person ID (pid) for every person and the distance from person to camera. Upon the distance, app could control the light turn on/off automatically.
4+
When people in the 0.5 ~ 1 meter from camera, light will be on blue, and when people move to 1 ~ 1.5 meter from camera light will be on red. The expected of light color should be as below:
5+
6+
| Distance(Meter) | Expected Behavior |
7+
|:--------:|:------:|
8+
| 0.5 ~ 1 | Blue |
9+
| 1 ~ 1.5 | Red |
10+
| 1.5 ~ 2 | White |
11+
| 2 ~ 2.5 | Green |
12+
13+
## Bootstrap
14+
15+
```
16+
$ npm install
17+
```
18+
19+
## Run
20+
21+
```
22+
$ node main.js
23+
```
24+
25+
Note: Open a brower in any remote machine that is on the same network as target, enter url "TargetIPaddr:8000/view.html". Ex:10.30.90.130:8000/view.html, it without network, please open url "127.0.0.1:8000/view.html".
26+
27+
## Screenshot
28+
29+
When person in front of camera at different distance, light* turns on blue color(* means blue, red, white, green).
30+
31+
<img width="600" alt="Image" src="../doc/demo1/demo1_browser_ONE.png">
32+
<img width="300" alt="Image" src="../doc/demo1/demo1_blue_ONE.png">
33+
34+
* Known issue: This demo doesn't support recognized mutil-user at the same time as it can't contorl mutil-led which using same resourceType, see issue [#1383](https://github.com/01org/zephyr.js/issues/1383), if there are two persons in front of camera at different distance, this demo will choose the person which pid is smaller. The data of pid and distance have been showed in the red rectangless. For example, person A's pid is 1, person B is 2, this demo will according to the distance of A to display which color.

0 commit comments

Comments
 (0)