modeld: make valid variable thread safe (#23228)

pull/23231/head
Dean Lee 2021-12-15 21:01:11 +08:00 committed by GitHub
parent f20d53b15c
commit 7c4855a609
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -87,6 +87,7 @@ void run_model(ModelState &model, VisionIpcClient &vipc_client) {
transform_lock.lock();
mat3 model_transform = cur_transform;
bool valid = live_calib_seen;
transform_lock.unlock();
// TODO: path planner timeout?
@ -117,8 +118,8 @@ void run_model(ModelState &model, VisionIpcClient &vipc_client) {
float frame_drop_ratio = frames_dropped / (1 + frames_dropped);
model_publish(pm, extra.frame_id, frame_id, frame_drop_ratio, *model_output, extra.timestamp_eof, model_execution_time,
kj::ArrayPtr<const float>(model.output.data(), model.output.size()), live_calib_seen);
posenet_publish(pm, extra.frame_id, vipc_dropped_frames, *model_output, extra.timestamp_eof, live_calib_seen);
kj::ArrayPtr<const float>(model.output.data(), model.output.size()), valid);
posenet_publish(pm, extra.frame_id, vipc_dropped_frames, *model_output, extra.timestamp_eof, valid);
//printf("model process: %.2fms, from last %.2fms, vipc_frame_id %u, frame_id, %u, frame_drop %.3f\n", mt2 - mt1, mt1 - last, extra.frame_id, frame_id, frame_drop_ratio);
last = mt1;