5
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AtomCam2のRTSP通信で映像を取得しStreamlitで公開すーる(Python3.6、Windows10)

Last updated at Posted at 2021-12-27

はじめに

AtomCam2がRTSP対応したので、Streamlitで公開しちゃおう

開発環境

  • Windows 10 PC
  • Python 3.6
  • streamlit
  • opencv-python
  • pillow
  • AtomCam2 (ファームウェア:4.58.0.73)

実装

1.AtomCam2のRTSP通信設定をします

2.streamlitをインストールします

pip install streamlit
streamlit hello

image.png

image.png

Ctrl+Cで中断します

3.下記コードを作成し実行します。

streaming.py
import cv2
import streamlit as st
import time
from PIL import Image

st.markdown("# Gachimoto AtomCam2 Live")

cap = cv2.VideoCapture('rtsp://xxxx:yyyy@zzz.zzz.zzz.zzz/live')
_, frame = cap.read()
height, width = frame.shape[:2]
print(height, width) # SD : 1080, 1920

image_loc = st.empty()
while(True):
    _, frame = cap.read()
    frame = cv2.resize(frame, ((int)(width/4), (int)(height/4)))
    frame = Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
    image_loc.image(frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
streaming.py
streamlit run streaming.py

image.png

ngrokで外部公開

ngrokによってローカルサーバーを外部に公開することができます

ngrok.exe authtoken XXXXXXXXXXXXXXXXXXXX_XXXXXXXXXXXXXXXXXXXX
ngrok.exe http 8501

ドメインお持ちの方

ngrok.exe http -subdomain=name 8501
image.png

遠隔で見えるわーい

参考

5
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?