Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Streaming camera for Hamster - Using Raspberry Pi and PHP’s Swoole -

April 24, 2019

Streaming camera for Hamster - Using Raspberry Pi and PHP’s Swoole -


April 24, 2019

More Decks by memory

Other Decks in Programming


  1. Streaming camera for Hamster - Using Raspberry Pi and PHP’s

    Swoole - 04/24/2019 PHP study meetup at Tokyo In Japan memory (@m3m0r7)
  2. memory (@m3m0r7) I’m a server-side and front-end engineer. I like

    PHP and React.js. And I’m working at an IT company in Japan.
  3. Lily Sex: female Birthday: 11/01/2018 Likes: biscuits and apple-tree branches

    Dislikes: pear-tree branches Hobby: biting at a waterer
  4. - Raspbian (Raspberry Pi) - PHP 7.3 - Swoole v4

    - Python 3 - React.js (+ Gulp) Mainly five technologies
  5. - Raspberry Pi 3 Model B * 2 ≒ 5,200

    * 2 ≒ 10,000 JPY - Camera modules * 2 ≒ 5,000 * 2 ≒ 10,000 JPY - VPS (ConoHa[1]) ≒ 2,500/mo JPY - Router ≒ 15,000 JPY Initial costs ≒ 37,500 JPY Running costs ≒ 2,500 JPY [1] ConoHa is a VPS service provided by GMO (Japanese IT company).
  6. My Home LAN VPS (ConoHa) PiCamera Module Four-byte size data

    in unsigned long + picamera.start_recording (mjpeg) Sends image data from daytime camera through TCP connections Sends Image data from night camera through TCP connections
  7. - I didn’t want to expose any ports from my

    home - Intermediate server definitely solved this! I chose ConoHa this time. - Bought a router brand new, which is super cool :) - Sending to VPS (ConoHa) using picamera on Python 3
  8. Built with high speed and stability. Supported A Wi-Fi Router

    Equipped with MU-MIMO Technologies High speed connections for multiple devices. Concentrated connections to destination devices by “AiRader” Technology. This Wi-Fi router is capable of delivering electromagnetic wave to the entire home because its covering area is very large.
  9. - By using Coroutines on PHP's Swoole, I made an

    inbound server for Raspberry Pi, and an outbound server for sending to ConoHa - That’s it! Simple is best.
  10. - mjpeg stands for Motion JPEG. - I have also

    investigated H.264 but its latency increases by 5 sec via ffmpeg. Thus, I chose mjpeg. - Keeps connected in MIME type multipart/x-mixed-replace. - (The browser continuously indicates the page is being loaded) - Latency appears to be roughly 0.5 sec - Renders smoothly.
  11. - Amazing async processing in PHP! - Relatively easy to

    install because of unnecessity of --enable-maintainer- zts when building. - I pray to Swoole so Atomic can accept at least serializable values. - I’m using Channel instead of Atomic.