flipoff: allow hiding the GUI with --headless
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I741f75f8c2615dacea5f6ca703d6da716a6a6964
This commit is contained in:
parent
46ad04ac3b
commit
a8262ab7a6
1 changed files with 15 additions and 4 deletions
19
flipoff.py
19
flipoff.py
|
|
@ -1,3 +1,4 @@
|
|||
import argparse
|
||||
import asyncio
|
||||
import os
|
||||
import time
|
||||
|
|
@ -64,6 +65,14 @@ async def async_poweroff() -> None:
|
|||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description="Hand gesture poweroff utility")
|
||||
parser.add_argument(
|
||||
"--headless",
|
||||
action="store_true",
|
||||
help="Hide GUI window and run in headless mode",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
if not MODEL_PATH:
|
||||
raise RuntimeError("FLIPOFF_MODEL_PATH environment variable not set")
|
||||
|
||||
|
|
@ -112,12 +121,14 @@ def main() -> None:
|
|||
last_trigger = now
|
||||
loop.run_until_complete(async_poweroff())
|
||||
|
||||
cv2.imshow("Gesture Poweroff", frame)
|
||||
if cv2.waitKey(1) & 0xFF == 27:
|
||||
break
|
||||
if not args.headless:
|
||||
cv2.imshow("Gesture Poweroff", frame)
|
||||
if cv2.waitKey(1) & 0xFF == 27:
|
||||
break
|
||||
|
||||
cap.release()
|
||||
cv2.destroyAllWindows()
|
||||
if not args.headless:
|
||||
cv2.destroyAllWindows()
|
||||
detector.close()
|
||||
loop.close()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue