riscritto per VLC
This commit is contained in:
29
README.md
29
README.md
@@ -1,11 +1,30 @@
|
|||||||
|
Prerequisito
|
||||||
|
Installare VLC (testato con versione 3.0.6)
|
||||||
|
installare python (3.9.x va bene, sviluppato sulla 3.9.2)
|
||||||
|
|
||||||
|
istruzioni su come installare:
|
||||||
|
creare una cartella e installare il virtualenv (es. C:\Users\User\Documents\python\webcam>"c:\Program Files\Python39\python.exe" -m venv env)
|
||||||
|
attivare il virtualenv e installare i prerequisiti:
|
||||||
|
C:\Users\User\Documents\python\webcam>env\Scripts\activate.bat
|
||||||
|
C:\Users\User\Documents\python\webcam>pip install -r requirements.txt
|
||||||
|
|
||||||
|
copiare lo script nella dir "webcam"
|
||||||
|
|
||||||
|
Per farla partire allo startup
|
||||||
|
Windows logo key + R, scrivi shell:startup
|
||||||
|
creare un icona con:
|
||||||
|
command line C:\Users\User\Documents\python\webcam\env\Scripts\python.exe -m flask run --host=0.0.0.0
|
||||||
|
start in
|
||||||
|
C:\Users\User\Documents\python\webcam\
|
||||||
|
|
||||||
|
|
||||||
Wwebhook per telecamera. Progetto fatto per Angelo.
|
Wwebhook per telecamera. Progetto fatto per Angelo.
|
||||||
in pratica tramite ESP8266 (easyesp) se uno preme un bottone, sul PC esce in primo piano una finestra che mostra una IP cam.
|
in pratica tramite ESP8266 (easyesp) se uno preme un bottone, sul PC esce in primo piano una finestra che mostra una IP cam.
|
||||||
|
|
||||||
Il sito con lo schema
|
Il sito con lo schema
|
||||||
https://community.blynk.cc/t/problem-using-physical-4-buttons-using-nodemcu-esp8266-to-switch-relays/36361/3
|
https://community.blynk.cc/t/problem-using-physical-4-buttons-using-nodemcu-esp8266-to-switch-relays/36361/3
|
||||||
|
|
||||||
La schermata non sempre viene in primo piano. Per questo usare https://efotinis.neocities.org/deskpins/
|
|
||||||
Sembra che opencv non gestisca correttamente questa cosa (fatto varie prove)
|
|
||||||
|
|
||||||
Rule su ESP:
|
Rule su ESP:
|
||||||
----------------------
|
----------------------
|
||||||
@@ -15,9 +34,3 @@ On Bottone#State=1 do
|
|||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
per la config di "bottone" vedi png.
|
per la config di "bottone" vedi png.
|
||||||
|
|
||||||
Per lanciarlo in prod:
|
|
||||||
python -m flask run --host=0.0.0.0
|
|
||||||
|
|
||||||
|
|
||||||
python 3.9.2
|
|
||||||
42
app.py
42
app.py
@@ -1,42 +1,14 @@
|
|||||||
import os
|
|
||||||
import cv2
|
|
||||||
from flask import Flask, request, Response
|
from flask import Flask, request, Response
|
||||||
import win32gui
|
import subprocess
|
||||||
import win32con
|
|
||||||
|
|
||||||
finestra = 0 # per capire se la finestra è gia aperta...
|
def playstream():
|
||||||
|
subprocess.run(["c:\\Program Files\\VideoLAN\\VLC\\vlc.exe","--video-on-top", "--zoom=0.5", "rtsp://admin:admin@192.168.123.199/0"], stdout=subprocess.DEVNULL)
|
||||||
# http://webcam-garage.romito.net/videostream.cgi
|
|
||||||
# http://admin:admin@192.168.123.1/cgi-bin/videostream.cgi?user=admin&pwd=admin
|
|
||||||
# per l'always on top https://efotinis.neocities.org/deskpins/
|
|
||||||
|
|
||||||
#print("Before URL")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def openwebcam():
|
|
||||||
global finestra
|
|
||||||
if finestra == 0:
|
|
||||||
finestra = 1
|
|
||||||
cap = cv2.VideoCapture('http://admin:smart24@webcam-garage.romito.net/videostream.cgi')
|
|
||||||
WindowName="Main View"
|
|
||||||
ret, frame = cap.read()
|
|
||||||
cv2.imshow(WindowName,frame)
|
|
||||||
text_color = (0,0,0)
|
|
||||||
while True:
|
|
||||||
ret, frame = cap.read()
|
|
||||||
cv2.putText(frame, "Premi q per uscire", (20,15), cv2.FONT_HERSHEY_PLAIN, 1.0, text_color, thickness=2)
|
|
||||||
cv2.imshow(WindowName,frame)
|
|
||||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
|
||||||
break
|
|
||||||
|
|
||||||
cap.release()
|
|
||||||
cv2.destroyAllWindows()
|
|
||||||
finestra = 0
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/webhook', methods=['GET'])
|
@app.route('/webhook', methods=['GET'])
|
||||||
def respond():
|
def respond():
|
||||||
openwebcam()
|
playstream()
|
||||||
|
return 'Visualizzazione avviata'
|
||||||
|
|
||||||
|
|||||||
44
appold.py
Normal file
44
appold.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import os
|
||||||
|
import cv2
|
||||||
|
from flask import Flask, request, Response
|
||||||
|
import win32gui
|
||||||
|
import win32con
|
||||||
|
|
||||||
|
finestra = 0 # per capire se la finestra è gia aperta...
|
||||||
|
|
||||||
|
# http://webcam-garage.romito.net/videostream.cgi
|
||||||
|
# http://admin:admin@192.168.123.1/cgi-bin/videostream.cgi?user=admin&pwd=admin
|
||||||
|
# per l'always on top https://efotinis.neocities.org/deskpins/
|
||||||
|
|
||||||
|
|
||||||
|
def openwebcam():
|
||||||
|
global cap
|
||||||
|
global finestra
|
||||||
|
if finestra == 0:
|
||||||
|
finestra = 1
|
||||||
|
#cap = cv2.VideoCapture('http://xxx:yyy@indirizzocam/videostream.cgi')
|
||||||
|
#cap = cv2.VideoCapture('http://admin:admin@192.168.123.199')
|
||||||
|
cap = cv2.VideoCapture('rtsp://admin:admin@192.168.123.199/0')
|
||||||
|
WindowName="Telecamera"
|
||||||
|
ret, frame = cap.read()
|
||||||
|
frame = cv2.resize(frame, (224, 224))
|
||||||
|
cv2.imshow(WindowName,frame)
|
||||||
|
text_color = (255,255,255)
|
||||||
|
while True:
|
||||||
|
ret, frame = cap.read()
|
||||||
|
frame = cv2.resize(frame, (int(1920/3), int(1080/3))) # ridimensiona l'immagine, commentare per default
|
||||||
|
cv2.putText(frame, "Premi q per uscire", (20,15), cv2.FONT_HERSHEY_PLAIN, 1.0, text_color, thickness=2)
|
||||||
|
cv2.imshow(WindowName,frame)
|
||||||
|
if cv2.waitKey(1) & 0xFF == ord('q'):
|
||||||
|
break
|
||||||
|
|
||||||
|
cap.release()
|
||||||
|
cv2.destroyAllWindows()
|
||||||
|
finestra = 0
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/webhook', methods=['GET'])
|
||||||
|
def respond():
|
||||||
|
openwebcam()
|
||||||
|
|
||||||
@@ -3,7 +3,4 @@ Flask==1.1.2
|
|||||||
itsdangerous==1.1.0
|
itsdangerous==1.1.0
|
||||||
Jinja2==2.11.3
|
Jinja2==2.11.3
|
||||||
MarkupSafe==1.1.1
|
MarkupSafe==1.1.1
|
||||||
numpy==1.20.1
|
|
||||||
opencv-python==4.5.1.48
|
|
||||||
pywin32==300
|
|
||||||
Werkzeug==1.0.1
|
Werkzeug==1.0.1
|
||||||
|
|||||||
Reference in New Issue
Block a user