【更新】

This commit is contained in:
wdp
2025-02-15 01:04:06 +08:00
parent df1f4b6a69
commit ebca2120c0
190 changed files with 61456 additions and 290 deletions

View File

@@ -3,6 +3,9 @@
#include "util/TimeCount.h"
#include "CenterFaceMnn.h"
#include "MobileFaceFeatureMnn.h"
#include "FaceQuality.h"
#include "util/DeviceInfo.h"
#include "util/AuthModule.h"
void test_face_detect(std::string img_path) {
cv::Mat img = cv::imread(img_path);
@@ -12,11 +15,15 @@ void test_face_detect(std::string img_path) {
CenterFaceMnn::GetInstance()->Detect(img, faces, 1);
}
for(auto& face : faces) {
for (auto& face : faces) {
cv::Rect rect(face.x1, face.y1, FACE_BOX_WIDTH(face), FACE_BOX_HEIGHT(face));
int score = FaceQuality::GetInstance()->DetectQuality(img, rect);
cv::rectangle(img, cv::Rect(face.x1, face.y1, FACE_BOX_WIDTH(face), FACE_BOX_HEIGHT(face)), cv::Scalar(0, 0, 255), 2);
cv::putText(img, std::to_string(score), cv::Point(face.x1, face.y1), cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0, 0, 255), 2);
std::cout << "score: " << score << std::endl;
}
cv::imshow("test", img);
cv::waitKey(0);
// cv::imshow("test", img);
// cv::waitKey(0);
}
void test_face_compare(std::string img1, std::string img2) {
@@ -63,11 +70,43 @@ void test_face_compare(std::string img1, std::string img2) {
cv::waitKey(0);
}
int32_t main(int32_t argc, char** argv) {
CenterFaceMnn::GetInstance();
MobileFaceFeatureMnn::GetInstance();
// test_face_detect("E:/dd.jpg");
// 打开摄像头
cv::VideoCapture cap(0);
if (!cap.isOpened()) {
std::cerr << "Failed to open camera." << std::endl;
return 1;
}
test_face_compare("F:/1.jpg", "E:\\6.jpg");
// 循环读取摄像头图像并显 示
cv::Mat frame;
while (true) {
// 读取一帧图像
cap >> frame;
if (frame.empty()) {
std::cerr << "Failed to read frame." << std::endl;
break;
}
// 显示图像
cv::imshow("Camera", frame);
cv::waitKey(1);
}
// CenterFaceMnn::GetInstance();
// FaceQuality::GetInstance();
// MobileFaceFeatureMnn::GetInstance();
// test_face_detect("E:/1.jpg");
// std::string key_data;
// int ret = AuthModule::GetInstance().DecodeKeyFile("E:\\ySSm8TAdi6Y0v72msa6E.key", key_data);
// std::cout << "decode file: " << std::endl << key_data << std::endl;
std::cout << "check key file: " <<
AuthModule::GetInstance().CheckKeyFile("E:\\ySSm8TAdi6Y0v72msa6E.key") << std::endl;
// test_face_compare("F:/1.jpg", "E:\\6.jpg");
// std::cout << "board: " << DeviceInfo::GetInstance().GetBoardInfo() << std::endl;
// std::vector<std::string> macs = DeviceInfo::GetInstance().GetMacAddress();
// for(auto& mac : macs) {
// std::cout << "mac: " << mac << std::endl;
// }
system("pause");
return 0;
}