异步编码截图

This commit is contained in:
zhbaor 2024-11-25 22:00:56 +08:00
parent dcd08ab559
commit dbde9508cb
4 changed files with 11 additions and 17 deletions

View file

@ -449,14 +449,12 @@ def test_custom_screenshot():
shell=True,
creationflags=subprocess.CREATE_NO_WINDOW if __system__ == "windows" else 0,
)
end = time.time()
elapsed = int((end - start) * 1000)
data = np.frombuffer(data, np.uint8)
data = cv2.imdecode(data, cv2.IMREAD_COLOR)
elapsed = int((time.time() - start) * 1000)
_, data = cv2.imencode(".jpg", data, [int(cv2.IMWRITE_JPEG_QUALITY), 75])
data = base64.b64encode(data)
data = data.decode("ascii")
data = base64.b64encode(data).decode("ascii")
return {"elapsed": elapsed, "screenshot": data}