Compare commits

..

No commits in common. "4751d022293643a0482bc8d063ab9c7301b2db20" and "821d06c9cf6126e3c1080c6702a68b5af1694388" have entirely different histories.

4 changed files with 4 additions and 43 deletions

View file

@ -37,7 +37,6 @@ class FrameEmitter:
video = cv2.VideoCapture(str(self.config.video_src))
fps = video.get(cv2.CAP_PROP_FPS)
frame_duration = 1./fps
logger.info(f"Emit frames at {fps} fps")
prev_time = time.time()
while self.is_running.is_set():
@ -67,4 +66,3 @@ class FrameEmitter:
def run_frame_emitter(config: Namespace, is_running: Event):
router = FrameEmitter(config, is_running)
router.emit_video()
is_running.clear()

View file

@ -1,11 +1,7 @@
import atexit
import logging
from logging.handlers import SocketHandler
from multiprocessing import Event, Process, Queue
import multiprocessing
import signal
import sys
import time
from trap.config import parser
from trap.frame_emitter import run_frame_emitter
from trap.prediction_server import run_prediction_server
@ -16,28 +12,17 @@ from trap.tracker import run_tracker
logger = logging.getLogger("trap.plumbing")
class ExceptionHandlingProcess(Process):
def run(self):
assert 'is_running' in self._kwargs
# exit handler to make sure that on many kinds of crashes and kills the
# suprocess warns parent/siblings
# TODO: Does not work with OOM kill. Would need a watchdog process for that
def exit_handler(*args):
self._kwargs['is_running'].clear()
atexit.register(exit_handler)
signal.signal(signal.SIGTERM, exit_handler)
signal.signal(signal.SIGINT, exit_handler)
try:
super(Process, self).run()
except Exception as e:
logger.exception(e)
self._kwargs['is_running'].clear()
def start():
args = parser.parse_args()
loglevel = logging.NOTSET if args.verbose > 1 else logging.DEBUG if args.verbose > 0 else logging.INFO
@ -55,8 +40,6 @@ def start():
isRunning.set()
if args.remote_log_addr:
logging.captureWarnings(True)
root_logger.setLevel(logging.NOTSET) # to send all records to cutelog
@ -81,9 +64,6 @@ def start():
for proc in procs:
proc.start()
# wait for processes to clean up
for proc in procs:
proc.join()
logger.info('Stop')

View file

@ -207,13 +207,8 @@ class PredictionServer:
trajectron.set_environment(online_env, init_timestep)
timestep = init_timestep + 1
prev_run_time = 0
while self.is_running.is_set():
timestep += 1
this_run_time = time.time()
logger.debug(f'test {prev_run_time - this_run_time}')
time.sleep(max(0, prev_run_time - this_run_time + .5))
prev_run_time = time.time()
# for timestep in range(init_timestep + 1, eval_scene.timesteps):
# input_dict = eval_scene.get_clipped_input_dict(timestep, hyperparams['state'])

View file

@ -1,6 +1,5 @@
from argparse import Namespace
import datetime
import logging
from multiprocessing import Event
import cv2
@ -37,15 +36,6 @@ class Renderer:
if not self.config.output_dir.exists():
raise FileNotFoundError("Path does not exist")
date_str = datetime.datetime.now().isoformat(timespec="minutes")
filename = self.config.output_dir / f"render_predictions-{date_str}.mp4"
logger.info(f"Write to {filename}")
fourcc = cv2.VideoWriter_fourcc(*'vp09')
# TODO: get FPS from frame_emitter
self.out = cv2.VideoWriter(str(filename), fourcc, 23.97, (1280,720))
def run(self):
predictions = {}
i=0
@ -91,10 +81,8 @@ class Renderer:
img_path = (self.config.output_dir / f"{i:05d}.png").resolve()
# cv2.imwrite(str(img_path), img)
self.out.write(img)
cv2.imwrite(str(img_path), img)
logger.info('Stopping')
self.out.release()