diff --git a/003.jpg b/003.jpg new file mode 100644 index 0000000..8936ff9 Binary files /dev/null and b/003.jpg differ diff --git a/plugins/ai_face_det/ai_face_det_node.cpp b/plugins/ai_face_det/ai_face_det_node.cpp index 7a4c558..f0434da 100644 --- a/plugins/ai_face_det/ai_face_det_node.cpp +++ b/plugins/ai_face_det/ai_face_det_node.cpp @@ -12,6 +12,9 @@ #include #include +// For test image loading (implementation in ai_face_recog_node.cpp) +#include "../../third_party/rknpu2/examples/3rdparty/stb/stb_image.h" + #include "ai_scheduler.h" #include "face/face_result.h" #include "node.h" @@ -475,6 +478,56 @@ public: const int max_faces = cfg ? cfg->max_faces : 0; LogInfo("[ai_face_det] start id=" + id_ + " conf=" + std::to_string(conf) + " nms=" + std::to_string(nms) + " max_faces=" + std::to_string(max_faces)); + + // ========== TEST: Load 003.jpg and run detection ========== +#if defined(RK3588_ENABLE_RKNN) + { + const char* test_img_path = "./003.jpg"; + int img_w = 0, img_h = 0, img_c = 0; + unsigned char* img_data = stbi_load(test_img_path, &img_w, &img_h, &img_c, 3); + if (img_data && img_w > 0 && img_h > 0) { + std::cerr << "[TEST] Loaded " << test_img_path << " (" << img_w << "x" << img_h << ")\n"; + + // Create a fake frame + auto frame = std::make_shared(); + frame->width = img_w; + frame->height = img_h; + frame->format = PixelFormat::RGB; + frame->data = img_data; + frame->data_size = static_cast(img_w) * static_cast(img_h) * 3; + frame->stride = img_w * 3; + + // Run detection + Run(frame); + + // Print results + if (frame->face_det && !frame->face_det->faces.empty()) { + std::cerr << "[TEST] Detected " << frame->face_det->faces.size() << " face(s)\n"; + for (size_t fi = 0; fi < frame->face_det->faces.size(); ++fi) { + const auto& face = frame->face_det->faces[fi]; + std::cerr << "[TEST] Face " << fi << " bbox: [" + << face.bbox.x << "," << face.bbox.y << "," + << face.bbox.w << "," << face.bbox.h << "] score=" << face.score << "\n"; + if (face.has_landmarks) { + std::cerr << "[TEST] Board landmarks: "; + for (int li = 0; li < 5; ++li) { + std::cerr << "[" << face.landmarks[li].x << "," << face.landmarks[li].y << "] "; + } + std::cerr << "\n"; + } + } + } else { + std::cerr << "[TEST] No faces detected\n"; + } + + stbi_image_free(img_data); + } else { + std::cerr << "[TEST] Skip: " << test_img_path << " not found\n"; + } + } +#endif + // ========== END TEST ========== + return true; } diff --git a/plugins/ai_face_recog/ai_face_recog_node.cpp b/plugins/ai_face_recog/ai_face_recog_node.cpp index b3f125c..6454b25 100644 --- a/plugins/ai_face_recog/ai_face_recog_node.cpp +++ b/plugins/ai_face_recog/ai_face_recog_node.cpp @@ -16,6 +16,7 @@ // For test image loading #define STB_IMAGE_IMPLEMENTATION #define STBI_ONLY_PNG +#define STBI_ONLY_JPEG #define STBI_NO_FAILURE_STRINGS #include "../../third_party/rknpu2/examples/3rdparty/stb/stb_image.h" @@ -894,6 +895,17 @@ private: for (int i = 0; i < limit; ++i) { const FaceDetItem& face = frame->face_det->faces[static_cast(i)]; + // DEBUG: 打印检测到的 landmarks (只打印一次) + static bool landmarks_printed = false; + if (face.has_landmarks && !landmarks_printed) { + std::cerr << "[DEBUG] Board landmarks: "; + for (int li = 0; li < 5; ++li) { + std::cerr << "[" << face.landmarks[li].x << "," << face.landmarks[li].y << "] "; + } + std::cerr << "\n"; + landmarks_printed = true; + } + face_buf_.resize(static_cast(model_w_) * static_cast(model_h_) * 3); if (cfg->align && face.has_landmarks && model_w_ == 112 && model_h_ == 112) { const std::array dst = {