|
|
|
@ -13,17 +13,14 @@ |
|
|
|
|
#define MODEL_HEIGHT 640 |
|
|
|
|
#define FULL_W 852 // should get these numbers from camerad
|
|
|
|
|
|
|
|
|
|
#if defined(QCOM) || defined(QCOM2) |
|
|
|
|
#define input_lambda(x) (x - 128.f) * 0.0078125f |
|
|
|
|
#else |
|
|
|
|
#define input_lambda(x) x // for non SNPE running platforms, assume keras model instead has lambda layer
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
void dmonitoring_init(DMonitoringModelState* s) { |
|
|
|
|
const char *model_path = Hardware::PC() ? "../../models/dmonitoring_model.dlc" : "../../models/dmonitoring_model_q.dlc"; |
|
|
|
|
int runtime = USE_DSP_RUNTIME; |
|
|
|
|
s->m = new DefaultRunModel(model_path, &s->output[0], OUTPUT_SIZE, runtime); |
|
|
|
|
s->is_rhd = Params().getBool("IsRHD"); |
|
|
|
|
|
|
|
|
|
const char *model_path = Hardware::PC() ? "../../models/dmonitoring_model.dlc" : "../../models/dmonitoring_model_q.dlc"; |
|
|
|
|
s->m = new DefaultRunModel(model_path, &s->output[0], OUTPUT_SIZE, USE_DSP_RUNTIME); |
|
|
|
|
for (int x = 0; x < std::size(s->tensor); ++x) { |
|
|
|
|
s->tensor[x] = (x - 128.f) * 0.0078125f; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <class T> |
|
|
|
@ -112,17 +109,17 @@ DMonitoringResult dmonitoring_eval_frame(DMonitoringModelState* s, void* stream_ |
|
|
|
|
for (int r = 0; r < MODEL_HEIGHT/2; r++) { |
|
|
|
|
for (int c = 0; c < MODEL_WIDTH/2; c++) { |
|
|
|
|
// Y_ul
|
|
|
|
|
net_input_buf[(r*MODEL_WIDTH/2) + c + (0*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = input_lambda(resized_buf[(2*r)*resized_width + (2*c)]); |
|
|
|
|
net_input_buf[(r*MODEL_WIDTH/2) + c + (0*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = s->tensor[resized_y[(2*r)*resized_width + 2*c]]; |
|
|
|
|
// Y_dl
|
|
|
|
|
net_input_buf[(r*MODEL_WIDTH/2) + c + (1*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = input_lambda(resized_buf[(2*r+1)*resized_width + (2*c)]); |
|
|
|
|
net_input_buf[(r*MODEL_WIDTH/2) + c + (1*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = s->tensor[resized_y[(2*r+1)*resized_width + 2*c]]; |
|
|
|
|
// Y_ur
|
|
|
|
|
net_input_buf[(r*MODEL_WIDTH/2) + c + (2*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = input_lambda(resized_buf[(2*r)*resized_width + (2*c+1)]); |
|
|
|
|
net_input_buf[(r*MODEL_WIDTH/2) + c + (2*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = s->tensor[resized_y[(2*r)*resized_width + 2*c+1]]; |
|
|
|
|
// Y_dr
|
|
|
|
|
net_input_buf[(r*MODEL_WIDTH/2) + c + (3*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = input_lambda(resized_buf[(2*r+1)*resized_width + (2*c+1)]); |
|
|
|
|
net_input_buf[(r*MODEL_WIDTH/2) + c + (3*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = s->tensor[resized_y[(2*r+1)*resized_width + 2*c+1]]; |
|
|
|
|
// U
|
|
|
|
|
net_input_buf[(r*MODEL_WIDTH/2) + c + (4*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = input_lambda(resized_buf[(resized_width*resized_height) + r*resized_width/2 + c]); |
|
|
|
|
net_input_buf[(r*MODEL_WIDTH/2) + c + (4*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = s->tensor[resized_u[r*resized_width/2 + c]]; |
|
|
|
|
// V
|
|
|
|
|
net_input_buf[(r*MODEL_WIDTH/2) + c + (5*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = input_lambda(resized_buf[(resized_width*resized_height) + ((resized_width/2)*(resized_height/2)) + c + (r*resized_width/2)]); |
|
|
|
|
net_input_buf[(r*MODEL_WIDTH/2) + c + (5*(MODEL_WIDTH/2)*(MODEL_HEIGHT/2))] = s->tensor[resized_v[r*resized_width/2 + c]]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|