Module2. Streaming - GachonCapstoneDesign/DoorWatcher GitHub Wiki
Streaming scenes using a camera of Raspberry Pie to your smartphone.
Here are the files we need to use to use streaming.
app.py
camera.py
index.html
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
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.
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
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:" "`.
If you run app.py from Raspberry Pie and install the project on your smartphone and run it, you can stream it.
๋ผ์ฆ๋ฒ ๋ฆฌํ์ด์ ์นด๋ฉ๋ผ๋ฅผ ์ด์ฉํด์ ์คํธ๋ฆฌ๋ฐํ๋ ์ฅ๋ฉด์ ์ค๋งํธํฐ์ผ๋ก ์คํธ๋ฆฌ๋ฐ ํฉ๋๋ค.
์ ํฌ๊ฐ ์ ๊ณตํ๋ Streaming ์ ์ด์ฉํ๊ธฐ ์ํด ์ฌ์ฉํด์ผ ํ๋ ํ์ผ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
app.py
camera.py
index.html
SplashActivity.java
MainActivity.java
StreamingActivity.java
GCMBroadcastReceiver.java
QuickstartPreferences.java
RegistrationIntentService.java
์ด ์ฝ๋๋ ํ์ฌ ๊นํ๋ธ์ ์ฌ๋ ค๋จ์ต๋๋ค.
- Github. ํ์ดํผ๋งํฌ๋ฅผ ํด๋ฆญํ์๋ฉด ๊นํ๋ธ ํ์ด์ง๋ก ์ด๋ํฉ๋๋ค.
์ธ๋ถ๋ง์์ ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด์ ์ ๊ทผํ๊ธฐ์ํด์ ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด์ ์ฐ๊ฒฐ๋ ์ธํฐ๋ท์ IP address๋ฅผ ์ธ๋ถ๋ง์์ ์ ์ํ ์ ์๊ฒ ์ค์ ํด ๋์ต๋๋ค.
์ธ๋ถ๋ง์์ ์ ์ ๊ฐ๋ฅํ๊ฒ ์ค์ ํ๋ ๋ฐฉ๋ฒ์ ์๋ URL์ ํด๋ฆญํ์๋ฉด ์์ธํ๊ฒ ์ค๋ช
๋์ด ์์ต๋๋ค.
- ์ค๋ช ์ ๋ณด๊ณ ์ถ์ผ์๋ฉด URL์ ํด๋ฆญํด ์ฃผ์ธ์.
์ด ํ์ผ์ ์คํํ๊ฒ๋๋ฉด ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด ์์ฒด์ ์ผ๋ก ์น์๋ฒ๋ฅผ ์ด๊ฒ๋ฉ๋๋ค.
์ด์ด๋์ ์น์๋ฒ์ ์ ๊ทผ ์์ฒญ์ด ์ค๋ฉด ์์ฒญ์์๊ฒ templates ํด๋์์ index.html์ ๋์์ค๋๋ค.
๋ํ ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด ์นด๋ฉ๋ผ ๋ชจ๋์ด ์ฐ๋ frame์ index.html์ ๋์์ค๋๋ค.
๊ณ์ํด์ ์นด๋ฉ๋ผ ๋ชจ๋์์ ์ฐ๋ ํ๋ฉด์ index.html์ ๋์์ฃผ๋๊ฑธ ์ ์ ๊ฐ ๋ด์ผ๋ก์จ ์คํธ๋ฆฌ๋ฐ์ด ์ด๋ฃจ์ด์ง๋๋ค.
์ด๋ ์น์ Access ์์ฒญ์ด ์ค๋ฉด ์คํธ๋ฆฌ๋ฐ์ด ๋๋ฏ๋ก ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด์ ๋ถํ๋ฅผ ์ค์ฌ์ค๋๋ค.
์น์ ์ ๊ทผ์ ์๋์ ๊ฐ์ ์ฃผ์๋ก ์ ๊ทผํฉ๋๋ค.
[๋ผ์ฆ๋ฒ ๋ฆฌ ํ์ด IP์ฃผ์]:5000
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 : "" ์ผ๋ก ์ค์ ๋์ด ์์ต๋๋ค.
๋ผ์ฆ๋ฒ ๋ฆฌํ์ด์์ app.py๋ฅผ ์คํํ ์ํ์์ ํ๋ก์ ํธ๋ฅผ ์ค๋งํธํฐ์ ์ค์นํ๊ณ ์คํํ๊ฒ ์คํธ๋ฆฌ๋ฐ์ด ๊ฐ๋ฅํฉ๋๋ค.