This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import panoramasdk | |
import numpy as np | |
class Application(panoramasdk.node): | |
def __init__(self, logger): | |
super().__init__() | |
self.logger = logger | |
self.threshold = 0. | |
self.MODEL_NODE = 'model_node' | |
self.MODEL_INPUT_NAME = 'images' | |
self.MODEL_INPUT_SIZE = (640, 640) | |
try: | |
# Get parameter values | |
self.logger.info('Getting parameters') | |
self.threshold = self.inputs.threshold.get() | |
except: | |
self.logger.exception('Error during initialization.') | |
finally: | |
self.logger.info('Initialiation complete.') | |
self.logger.info('Threshold: {}'.format(self.threshold)) | |
def process_streams(self): | |
streams = self.inputs.video_in.get() | |
for stream in streams: | |
self.process_media(stream) | |
self.outputs.video_out.put(streams) | |
def process_media(self, stream): | |
image_data, ratio = self.preprocess(stream.image, self.MODEL_INPUT_SIZE) | |
inference_results = self.call( | |
{ self.MODEL_INPUT_NAME: image_data }, | |
self.MODEL_NODE | |
) | |
self.postprocess(inference_results, stream, ratio) | |
def preprocess(self, img, size): | |
return ((np.ones((size[0], size[1], 3), dtype=np.uint8) * 114), 1.0) | |
def postprocess(self, inference_results, stream, ratio): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment