Download firmware/tests/test_pose_decode.cpp from eoinedge/pose-micro: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/eoinedge/pose-micro/resolve/main/firmware/tests/test_pose_decode.cpp
- Command line
-
hf download hf://eoinedge/pose-micro/firmware/tests/test_pose_decode.cpp
-
curl -L -o test_pose_decode.cpp https://huggingface.co/eoinedge/pose-micro/resolve/main/firmware/tests/test_pose_decode.cpp
1.48 kB
| /* 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. | |
| */ | |
| 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<unsigned char> data(pose::kOutputs * item); | |
| if (fread(data.data(), item, pose::kOutputs, f) != static_cast<size_t>(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<double>(k[i].x), static_cast<double>(k[i].y), | |
| static_cast<double>(k[i].heat)); | |
| } | |
| return 0; | |
| } | |