'Run python screen capture script in Windows 10 background
I am trying to run the script that captures my screen on the Windows 10 and sends that stream to the flask app. It works fine when I start the script from the Windows CMD, but once I set the script to be started in the background when I login (via Task Manager) it give only the black screen. Same thing happens when I use pythonw to start the script in the background from the CMD.
This is the code that I use:
from flask import Response
from flask import Flask
from flask import render_template
import threading
import numpy
import time
import cv2
import mss
from camera import Camera
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
def gen(camera):
while True:
frame = camera.get_frame()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
@app.route('/video_feed')
def video_feed():
return Response(gen(Camera()),
mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ == '__main__':
app.run(host='10.10.10.1',port=5000, debug=True)
Any advice on how to run this one in the background to capture my screen?
Thank you in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
