pull/24762/head
ZwX1616 3 years ago
parent 439862c7db
commit dde1e1927b
  1. 9
      selfdrive/modeld/models/dmonitoring.cc

@ -19,18 +19,11 @@ static inline T *get_buffer(std::vector<T> &buf, const size_t size) {
return buf.data(); return buf.data();
} }
static inline void init_yuv_buf(std::vector<uint8_t> &buf, const int width, int height) {
uint8_t *y = get_buffer(buf, width * height * 3 / 2);
uint8_t *u = y + width * height;
uint8_t *v = u + (width / 2) * (height / 2);
}
void dmonitoring_init(DMonitoringModelState* s) { void dmonitoring_init(DMonitoringModelState* s) {
s->is_rhd = Params().getBool("IsRHD"); s->is_rhd = Params().getBool("IsRHD");
for (int x = 0; x < std::size(s->tensor); ++x) { for (int x = 0; x < std::size(s->tensor); ++x) {
s->tensor[x] = (x - 128.f) * 0.0078125f; s->tensor[x] = (x - 128.f) * 0.0078125f;
} }
init_yuv_buf(s->resized_buf, MODEL_WIDTH, MODEL_HEIGHT);
#ifdef USE_ONNX_MODEL #ifdef USE_ONNX_MODEL
s->m = new ONNXModel("../../models/dmonitoring_model.onnx", &s->output[0], OUTPUT_SIZE, USE_DSP_RUNTIME); s->m = new ONNXModel("../../models/dmonitoring_model.onnx", &s->output[0], OUTPUT_SIZE, USE_DSP_RUNTIME);
@ -49,7 +42,7 @@ static inline auto get_yuv_buf(std::vector<uint8_t> &buf, const int width, int h
} }
DMonitoringResult dmonitoring_eval_frame(DMonitoringModelState* s, void* stream_buf, int width, int height, float *calib) { DMonitoringResult dmonitoring_eval_frame(DMonitoringModelState* s, void* stream_buf, int width, int height, float *calib) {
uint8_t *raw_y = (uint8_t *) raw; uint8_t *raw_y = (uint8_t *) stream_buf;
uint8_t *raw_u = raw_y + (width * height); uint8_t *raw_u = raw_y + (width * height);
uint8_t *raw_v = raw_u + ((width / 2) * (height / 2)); uint8_t *raw_v = raw_u + ((width / 2) * (height / 2));

Loading…
Cancel
Save