Module2. Streaming - GachonCapstoneDesign/DoorWatcher GitHub Wiki

Summary:

Streaming scenes using a camera of Raspberry Pie to your smartphone.

Introduction

Here are the files we need to use to use streaming.

python file

app.py
camera.py

HTML file

index.html

Android file

SplashActivity.java
MainActivity.java
StreamingActivity.java
GCMBroadcastReceiver.java
QuickstartPreferences.java
RegistrationIntentService.java

This code is now on the github.

  • Github. Click the hyperlink to go to the github repository

1. External network configuration

In order to access Raspberry Pi from external network, we set the IP address of Internet connected to Raspberry Pi to connect from external network. How to set up connection from external network is explained in detail by clicking URL below.

  • If you want to see an explanation, please click URL.

2. Run 'app.py' from the raspberry pi

When you run this file, Raspberry Pi will open its own web server. When an access request is made to the opened web server, the requestor displays index.html in the templates folder. It also displays the frame that the Raspberry pi camera module takes on index.html. The streaming is doing by the user to show the screen shot by the camera on the index.html. At this time, Access requests to the web streaming will reduce the load of Raspberry pi. Access to the web is addressed to:

[Raspberry Pi IP address]:5000

3. Enter the Android project and open 'StreamingActivity.java'

browser = (WebView) findViewById(R.id.webview1);
browser.getSettings().setJavaScriptEnabled(true);
browser.loadUrl("http:/192.168.0.12:5000/");

In the upper part, change the IP Address to your Raspberry IP Address. You can also set password and id after login activity. The default is `id:" ", pwd:" "`.

4. Turn on the application and check the streaming

If you run app.py from Raspberry Pie and install the project on your smartphone and run it, you can stream it.





[ ํ•œ๊ธ€ ์œ„ํ‚ค ]

Summary:

๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์˜ ์นด๋ฉ”๋ผ๋ฅผ ์ด์šฉํ•ด์„œ ์ŠคํŠธ๋ฆฌ๋ฐํ•˜๋Š” ์žฅ๋ฉด์„ ์Šค๋งˆํŠธํฐ์œผ๋กœ ์ŠคํŠธ๋ฆฌ๋ฐ ํ•ฉ๋‹ˆ๋‹ค.

Introduction

์ €ํฌ๊ฐ€ ์ œ๊ณตํ•˜๋Š” Streaming ์„ ์ด์šฉํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋Š” ํŒŒ์ผ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

python file

app.py
camera.py

HTML file

index.html

Android file

SplashActivity.java
MainActivity.java
StreamingActivity.java
GCMBroadcastReceiver.java
QuickstartPreferences.java
RegistrationIntentService.java

์ด ์ฝ”๋“œ๋Š” ํ˜„์žฌ ๊นƒํ—ˆ๋ธŒ์— ์˜ฌ๋ ค๋†จ์Šต๋‹ˆ๋‹ค.

  • Github. ํ•˜์ดํผ๋งํฌ๋ฅผ ํด๋ฆญํ•˜์‹œ๋ฉด ๊นƒํ—ˆ๋ธŒ ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.

1.์™ธ๋ถ€๋ง์—์„œ ์ ‘๊ทผ ๊ฐ€๋Šฅํ•˜๋„๋ก ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

์™ธ๋ถ€๋ง์—์„œ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์— ์ ‘๊ทผํ•˜๊ธฐ์œ„ํ•ด์„  ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์— ์—ฐ๊ฒฐ๋œ ์ธํ„ฐ๋„ท์˜ IP address๋ฅผ ์™ธ๋ถ€๋ง์—์„œ ์ ‘์†ํ•  ์ˆ˜ ์žˆ๊ฒŒ ์„ค์ •ํ•ด ๋†“์Šต๋‹ˆ๋‹ค.
์™ธ๋ถ€๋ง์—์„œ ์ ‘์† ๊ฐ€๋Šฅํ•˜๊ฒŒ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์•„๋ž˜ URL์„ ํด๋ฆญํ•˜์‹œ๋ฉด ์ž์„ธํ•˜๊ฒŒ ์„ค๋ช…๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

  • ์„ค๋ช…์„ ๋ณด๊ณ ์‹ถ์œผ์‹œ๋ฉด URL์„ ํด๋ฆญํ•ด ์ฃผ์„ธ์š”.

2.๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์—์„œ app.py ๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

์ด ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜๊ฒŒ๋˜๋ฉด ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด ์ž์ฒด์ ์œผ๋กœ ์›น์„œ๋ฒ„๋ฅผ ์—ด๊ฒŒ๋ฉ๋‹ˆ๋‹ค.
์—ด์–ด๋†“์€ ์›น์„œ๋ฒ„์— ์ ‘๊ทผ ์š”์ฒญ์ด ์˜ค๋ฉด ์š”์ฒญ์ž์—๊ฒŒ templates ํด๋”์†์˜ index.html์„ ๋„์›Œ์ค๋‹ˆ๋‹ค.
๋˜ํ•œ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด ์นด๋ฉ”๋ผ ๋ชจ๋“ˆ์ด ์ฐ๋Š” frame์„ index.html์— ๋„์›Œ์ค๋‹ˆ๋‹ค. ๊ณ„์†ํ•ด์„œ ์นด๋ฉ”๋ผ ๋ชจ๋“ˆ์—์„œ ์ฐ๋Š” ํ™”๋ฉด์„ index.html์— ๋„์›Œ์ฃผ๋Š”๊ฑธ ์œ ์ €๊ฐ€ ๋ด„์œผ๋กœ์จ ์ŠคํŠธ๋ฆฌ๋ฐ์ด ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค.
์ด๋•Œ ์›น์— Access ์š”์ฒญ์ด ์˜ค๋ฉด ์ŠคํŠธ๋ฆฌ๋ฐ์ด ๋˜๋ฏ€๋กœ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์˜ ๋ถ€ํ•˜๋ฅผ ์ค„์—ฌ์ค๋‹ˆ๋‹ค.
์›น์˜ ์ ‘๊ทผ์€ ์•„๋ž˜์™€ ๊ฐ™์€ ์ฃผ์†Œ๋กœ ์ ‘๊ทผํ•ฉ๋‹ˆ๋‹ค.

[๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด IP์ฃผ์†Œ]:5000

3.Android project์— ๋“ค์–ด๊ฐ€์„œ StreamingActivity.java๋ฅผ ์—ฝ๋‹ˆ๋‹ค.

browser = (WebView) findViewById(R.id.webview1);
browser.getSettings().setJavaScriptEnabled(true);
browser.loadUrl("http:/192.168.0.12:5000/");

์œ„ ๋ถ€๋ถ„์— IP Address๋ฅผ ์ž์‹ ์˜ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด IP Address๋กœ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.
๋˜ํ•œ Login Activity์— ๋“ค์–ด๊ฐ€๋ฉด ๋น„๋ฐ€๋ฒˆํ˜ธ์™€ ์•„์ด๋’ค ์„ค์ •์„ ํ•  ์ˆ˜์žˆ์Šต๋‹ˆ๋‹ค.
๊ธฐ๋ณธ๊ฐ’์œผ๋กœ id : "", pwd : "" ์œผ๋กœ ์„ค์ •๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

4.์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์ผœ๊ณ  ์ŠคํŠธ๋ฆฌ๋ฐ์„ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์—์„œ app.py๋ฅผ ์‹คํ–‰ํ•œ ์ƒํƒœ์—์„œ ํ”„๋กœ์ ํŠธ๋ฅผ ์Šค๋งˆํŠธํฐ์— ์„ค์น˜ํ•˜๊ณ  ์‹คํ–‰ํ•˜๊ฒŒ ์ŠคํŠธ๋ฆฌ๋ฐ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

โš ๏ธ **GitHub.com Fallback** โš ๏ธ