/* Copyright (c) 2026 Eoin Jordan * SPDX-License-Identifier: Apache-2.0 * * Runs the firmware's decoder (src/pose_decode.h) on a PC. Reads one network * output from a file written by test_pose_decode.py and prints the 17 * keypoints, for that script to compare with the Python decoder. * * File: int32 is_int8, int32 channels_last, float scale, int32 zero_point, * then 51 * 144 values, float32 or int8. */ #include #include #include #include "pose_decode.h" int main(int argc, char **argv) { if (argc != 2) { return 2; } FILE *f = fopen(argv[1], "rb"); if (f == nullptr) { return 2; } int32_t is_int8 = 0, channels_last = 0, zero_point = 0; float scale = 0.f; if (fread(&is_int8, 4, 1, f) != 1 || fread(&channels_last, 4, 1, f) != 1 || fread(&scale, 4, 1, f) != 1 || fread(&zero_point, 4, 1, f) != 1) { return 2; } const size_t item = is_int8 ? 1 : sizeof(float); std::vector data(pose::kOutputs * item); if (fread(data.data(), item, pose::kOutputs, f) != static_cast(pose::kOutputs)) { return 2; } fclose(f); const pose::Output out = {data.data(), is_int8 != 0, channels_last != 0, scale, zero_point}; pose::Keypoint k[pose::kKeypoints]; pose::decode(out, k); printf("%d\n", pose::found(k)); for (int i = 0; i < pose::kKeypoints; ++i) { printf("%.6f %.6f %.6f\n", static_cast(k[i].x), static_cast(k[i].y), static_cast(k[i].heat)); } return 0; }