forked from dsutanto/zenai-kpc-python
Fix blnak live stream
This commit is contained in:
1 parent
d93ee99c1f
commit
6afffb2184
2 files changed
+12
-3
No files matched your search
@@ -1384,11 +1384,14 @@ def run():
|
||||
if LIVE_STREAM_ENABLED and frame_idx % LIVE_STREAM_EVERY_N == 0:
|
||||
try:
|
||||
Path(LIVE_STREAM_FRAME_PATH).parent.mkdir(parents=True, exist_ok=True)
|
||||
_, jpeg = cv2.imencode(
|
||||
ok, jpeg = cv2.imencode(
|
||||
".jpg", frame, [cv2.IMWRITE_JPEG_QUALITY, LIVE_STREAM_QUALITY]
|
||||
)
|
||||
with open(LIVE_STREAM_FRAME_PATH, "wb") as f:
|
||||
f.write(jpeg.tobytes())
|
||||
if ok:
|
||||
tmp_path = f"{LIVE_STREAM_FRAME_PATH}.tmp"
|
||||
with open(tmp_path, "wb") as f:
|
||||
f.write(jpeg.tobytes())
|
||||
os.replace(tmp_path, LIVE_STREAM_FRAME_PATH)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
Reference in new issue
Block a user