修复人脸识别问题,测试模型问题,添加了调试,测试landlandmarks
This commit is contained in:
parent
57e4af1d92
commit
6c17c260e8
@ -12,6 +12,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// 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>();
|
||||
frame->width = img_w;
|
||||
frame->height = img_h;
|
||||
frame->format = PixelFormat::RGB;
|
||||
frame->data = img_data;
|
||||
frame->data_size = static_cast<size_t>(img_w) * static_cast<size_t>(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;
|
||||
}
|
||||
|
||||
|
||||
@ -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<size_t>(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<size_t>(model_w_) * static_cast<size_t>(model_h_) * 3);
|
||||
if (cfg->align && face.has_landmarks && model_w_ == 112 && model_h_ == 112) {
|
||||
const std::array<Point2f, 5> dst = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user