Files
webhook/app.py
Gianluca Romito e2d00b9eb9 primo commit
2021-02-24 08:15:59 +01:00

42 lines
1.1 KiB
Python

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/
#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.route('/webhook', methods=['GET'])
def respond():
openwebcam()