Skip to content

Commit

Permalink
run mac
Browse files Browse the repository at this point in the history
  • Loading branch information
k-azuma-radius5 committed Dec 11, 2023
1 parent ce69c1a commit f757393
Showing 1 changed file with 35 additions and 33 deletions.
68 changes: 35 additions & 33 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import json
import multiprocessing
from multiprocessing import Queue, Value, Array
from multiprocessing import Array, Queue, Value

from capture_bbox_manager import CaptureBBoxManager
from client import Client
from workflow_manager import GenerateSettings, WorkflowManager
from ui import ui
from capture_bbox_manager import CaptureBBoxManager
from workflow_manager import GenerateSettings, WorkflowManager


def set_bbox(queue, is_captureing, bbox):
Expand All @@ -18,33 +19,34 @@ def set_bbox(queue, is_captureing, bbox):
queue.put("done")


with open("config.json", "r") as f:
config = json.load(f)
workflow_manager = WorkflowManager(f"workflows/{config['init_workflow']}")
generate_settings = GenerateSettings(**config)
client = Client()
bbox_manager = CaptureBBoxManager() # must be main process, since uses tkinter

# status shared between processes
queue = Queue()
is_capturing = Value('i', 0)
bbox = Array('i', [0, 0, 0, 0])

ui_process = multiprocessing.Process(
target=ui,
args=(
config,
workflow_manager,
generate_settings,
client,
queue,
is_capturing,
bbox
),
)
ui_process.start()

while True:
message = queue.get()
if message == "set_bbox":
set_bbox(queue, is_capturing, bbox)
if __name__ == "__main__":
with open("config.json", "r") as f:
config = json.load(f)
workflow_manager = WorkflowManager(f"workflows/{config['init_workflow']}")
generate_settings = GenerateSettings(**config)
client = Client()
bbox_manager = CaptureBBoxManager() # must be main process, since uses tkinter

# status shared between processes
queue = Queue()
is_capturing = Value('i', 0)
bbox = Array('i', [0, 0, 0, 0])

ui_process = multiprocessing.Process(
target=ui,
args=(
config,
workflow_manager,
generate_settings,
client,
queue,
is_capturing,
bbox
),
)
ui_process.start()

while True:
message = queue.get()
if message == "set_bbox":
set_bbox(queue, is_capturing, bbox)

0 comments on commit f757393

Please sign in to comment.