/*
 ********************************************************************************
 * NOTICE 
 * This software is the property of HiRain Technologies. Any information
 * contained in this doc should not be reproduced, or used, or disclosed
 * without the written authorization from HiRain Technologies.
 * 
 ********************************************************************************
 *   Author:   yangtian.yi
 *   Date:     2025-09-02  09:30:39
 *
 ********************************************************************************
 *   Description: 
 *
 ********************************************************************************
 *   Limitations:  None
 *
 ********************************************************************************
 */

#include "utils.h"

int Preprocess(cv::Mat& raw_image, void* input_buff) {
  auto ret = Normalize(reinterpret_cast<const uint8_t*>(raw_image.data), reinterpret_cast<uint8_t*>(input_buff));
  return 0;
}

int Postprocess(std::vector<std::array<int, 4>>& result, void* dets_data) {
  float threshold = 0.5;
  for (int i = 0; i < 200; i++) {
    float score = (float)reinterpret_cast<float*>(dets_data)[i * 5 + 4];
    if (score > threshold) {
      std::array<int, 4> one_ret;
      one_ret[0] = (float)reinterpret_cast<float*>(dets_data)[i * 5];
      one_ret[1] = (float)reinterpret_cast<float*>(dets_data)[i * 5 + 1];
      one_ret[2] = (float)reinterpret_cast<float*>(dets_data)[i * 5 + 2];
      one_ret[3] = (float)reinterpret_cast<float*>(dets_data)[i * 5 + 3];
      result.push_back(one_ret);
    }
  }
  return 0;
}