exec method

Future<EvaluatePose> exec(
  1. Person person,
  2. ReceivePort responsePort,
  3. List<List<double>> threshold
)

運動評価を実行

Implementation

Future<EvaluatePose> exec(
  Person person,
  ReceivePort responsePort,
  List<List<double>> threshold,
) async {
  try {
    if (person.score < 0.25 || _interpreter.isDeleted) {
      return EvaluatePose(
        inputData: [],
        outputData: [],
      );
    }

    /// 運動評価のInputDataを作成
    final inputData = _convertToEvaluateInput.exec(person, threshold);

    /// Isolate用のModelを作成
    final isolateModel = InferenceModel(
      inputData,
      _interpreter.address,
      _interpreter.outPutTensorShape,
    );

    /// IsolateにModelを送信
    _isolateInferenceService.sendPort
        ?.send(isolateModel..responsePort = responsePort.sendPort);
    final evaluatePose = await responsePort.first;

    if (evaluatePose == null) {
      throw ServiceException(
        ServiceErrorType.inferenceIsolateError,
        ServiceErrorType.inferenceIsolateError.message,
      );
    }

    return evaluatePose;
  } on ServiceException {
    rethrow;
  } catch (_) {
    throw ServiceException(
      ServiceErrorType.inferenceError,
      ServiceErrorType.inferenceError.message,
    );
  }
}