mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-01 03:22:07 +08:00
dmonitoringmodeld: fix black padding not black after libyuv.I420Scale (#22971)
* true black * set black once * move def * add commnet * Update selfdrive/modeld/models/dmonitoring.cc * Update selfdrive/modeld/models/dmonitoring.cc * Update selfdrive/modeld/models/dmonitoring.cc * Update selfdrive/modeld/models/dmonitoring.cc Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> old-commit-hash: 80940b98440a71e15d96dcb16105a3d0b39393f3
This commit is contained in:
@@ -13,11 +13,30 @@
|
||||
#define MODEL_HEIGHT 640
|
||||
#define FULL_W 852 // should get these numbers from camerad
|
||||
|
||||
template <class T>
|
||||
static inline T *get_buffer(std::vector<T> &buf, const size_t size) {
|
||||
if (buf.size() < size) buf.resize(size);
|
||||
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);
|
||||
|
||||
// needed on comma two to make the padded border black
|
||||
// equivalent to RGB(0,0,0) in YUV space
|
||||
memset(y, 16, width * height);
|
||||
memset(u, 128, (width / 2) * (height / 2));
|
||||
memset(v, 128, (width / 2) * (height / 2));
|
||||
}
|
||||
|
||||
void dmonitoring_init(DMonitoringModelState* s) {
|
||||
s->is_rhd = Params().getBool("IsRHD");
|
||||
for (int x = 0; x < std::size(s->tensor); ++x) {
|
||||
s->tensor[x] = (x - 128.f) * 0.0078125f;
|
||||
}
|
||||
init_yuv_buf(s->resized_buf, MODEL_WIDTH, MODEL_HEIGHT);
|
||||
|
||||
#ifdef USE_ONNX_MODEL
|
||||
s->m = new ONNXModel("../../models/dmonitoring_model.onnx", &s->output[0], OUTPUT_SIZE, USE_DSP_RUNTIME);
|
||||
@@ -26,12 +45,6 @@ void dmonitoring_init(DMonitoringModelState* s) {
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static inline T *get_buffer(std::vector<T> &buf, const size_t size) {
|
||||
if (buf.size() < size) buf.resize(size);
|
||||
return buf.data();
|
||||
}
|
||||
|
||||
static inline auto get_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;
|
||||
|
||||
Reference in New Issue
Block a user