<reponame>Amagicians/openscout
# OpenScout
#   - Distributed Automated Situational Awareness
#
#   Author: <NAME> <<EMAIL>>
#
#   Copyright (C) 2020 Carnegie Mellon University
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
#

import base64
import time
import os
import uuid
import cv2
import numpy as np
import logging
from gabriel_server import cognitive_engine
from gabriel_protocol import gabriel_pb2
from openscout_protocol import openscout_pb2
import asyncio
import io
import glob
import uuid
import requests
import json

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

class HelloWorldEngine(cognitive_engine.Engine):
    ENGINE_NAME = "openscout-hello"

    def __init__(self, args):
        self.name = args.name
        logger.info("Hello World Name: {}".format(args.name))

    def handle(self, input_frame):
        if input_frame.payload_type != gabriel_pb2.PayloadType.IMAGE:
            status = gabriel_pb2.ResultWrapper.Status.WRONG_INPUT_FORMAT
            return cognitive_engine.create_result_wrapper(status)

        status = gabriel_pb2.ResultWrapper.Status.SUCCESS
        result_wrapper = cognitive_engine.create_result_wrapper(status)
        result_wrapper.result_producer_name.value = self.ENGINE_NAME

        result = gabriel_pb2.ResultWrapper.Result()
        result.payload_type = gabriel_pb2.PayloadType.TEXT
        result.payload = 'Hello {}'.format(self.name).encode(encoding="utf-8")
        result_wrapper.results.append(result)
        return result_wrapper



# OpenScout
#   - Distributed Automated Situational Awareness
#
#   Author: <NAME> <<EMAIL>>
#
#   Copyright (C) 2020 Carnegie Mellon University
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
#

import base64
import time
import os
import uuid
import cv2
import numpy as np
import logging
from gabriel_server import cognitive_engine
from gabriel_protocol import gabriel_pb2
from openscout_protocol import openscout_pb2
import asyncio
import io
import glob
import uuid
import requests
import json

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

class HelloWorldEngine(cognitive_engine.Engine):
    ENGINE_NAME = "openscout-hello"

    def __init__(self, args):
        self.name = args.name
        logger.info("Hello World Name: {}".format(args.name))

    def handle(self, input_frame):
        if input_frame.payload_type != gabriel_pb2.PayloadType.IMAGE:
            status = gabriel_pb2.ResultWrapper.Status.WRONG_INPUT_FORMAT
            return cognitive_engine.create_result_wrapper(status)

        status = gabriel_pb2.ResultWrapper.Status.SUCCESS
        result_wrapper = cognitive_engine.create_result_wrapper(status)
        result_wrapper.result_producer_name.value = self.ENGINE_NAME

        result = gabriel_pb2.ResultWrapper.Result()
        result.payload_type = gabriel_pb2.PayloadType.TEXT
        result.payload = 'Hello {}'.format(self.name).encode(encoding="utf-8")
        result_wrapper.results.append(result)
        return result_wrapper
# OpenScout #   - Distributed Automated Situational Awareness # #   Author: <NAME> <<EMAIL>> # #   Copyright (C) 2020 Carnegie Mellon University #   Licensed under the Apache License, Version 2.0 (the "License"); #   you may not use this file except in compliance with the License. #   You may obtain a copy of the License at # #       http://www.apache.org/licenses/LICENSE-2.0 # #   Unless required by applicable law or agreed to in writing, software #   distributed under the License is distributed on an "AS IS" BASIS, #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #   See the License for the specific language governing permissions and #   limitations under the License. # #