mirror of
https://github.com/deepinsight/insightface.git
synced 2026-08-23 13:47:51 +00:00
Update inspireface to 1.2.0
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Created by tunm on 2024/4/6.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
#include <iostream>
|
||||
#include "track_module/face_track.h"
|
||||
#include "inspireface/feature_hub/face_recognition.h"
|
||||
@@ -8,7 +9,7 @@
|
||||
#include "track_module/face_track.h"
|
||||
#include "pipeline_module/face_pipeline.h"
|
||||
#include "inspireface/feature_hub/face_recognition.h"
|
||||
#include "middleware/inference_helper/customized/rknn_adapter.h"
|
||||
#include "middleware/inference_wrapper/customized/rknn_adapter.h"
|
||||
|
||||
using namespace inspire;
|
||||
|
||||
@@ -16,9 +17,9 @@ int main() {
|
||||
InspireArchive archive;
|
||||
auto ret = archive.ReLoad("test_res/pack/Gundam_RV1109");
|
||||
LOGD("ReLoad %d", ret);
|
||||
// InspireModel model;
|
||||
// ret = archive.LoadModel("mask_detect", model);
|
||||
// LOGD("LoadModel %d", ret);
|
||||
// InspireModel model;
|
||||
// ret = archive.LoadModel("mask_detect", model);
|
||||
// LOGD("LoadModel %d", ret);
|
||||
|
||||
FaceTrack track;
|
||||
ret = track.Configuration(archive);
|
||||
@@ -28,11 +29,10 @@ int main() {
|
||||
|
||||
FaceRecognition recognition(archive, true);
|
||||
|
||||
// std::shared_ptr<RKNNAdapter> rknet = std::make_shared<RKNNAdapter>();
|
||||
// ret = rknet->Initialize((unsigned char* )model.buffer, model.bufferSize);
|
||||
//
|
||||
// LOGD("LoadModel %d", ret);
|
||||
|
||||
// std::shared_ptr<RKNNAdapter> rknet = std::make_shared<RKNNAdapter>();
|
||||
// ret = rknet->Initialize((unsigned char* )model.buffer, model.bufferSize);
|
||||
//
|
||||
// LOGD("LoadModel %d", ret);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Created by tunm on 2024/4/6.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
#include <iostream>
|
||||
#include "track_module/face_track.h"
|
||||
#include "inspireface/recognition_module/face_feature_extraction.h"
|
||||
@@ -13,7 +14,7 @@ int main() {
|
||||
archive.ReLoad("test_res/pack/Gundam_RV1109");
|
||||
|
||||
FaceTrack track;
|
||||
// FaceRecognition recognition(archive, true);
|
||||
// FaceRecognition recognition(archive, true);
|
||||
|
||||
auto ret = track.Configuration(archive);
|
||||
INSPIRE_LOGD("ret=%d", ret);
|
||||
@@ -29,13 +30,13 @@ int main() {
|
||||
|
||||
track.UpdateStream(stream, true);
|
||||
|
||||
// if (!track.trackingFace.empty()) {
|
||||
// auto const &face = track.trackingFace[0];
|
||||
// cv::rectangle(image, face.GetRectSquare(), cv::Scalar(200, 0, 20), 2);
|
||||
// }
|
||||
//
|
||||
// cv::imshow("w", image);
|
||||
// cv::waitKey(0);
|
||||
// if (!track.trackingFace.empty()) {
|
||||
// auto const &face = track.trackingFace[0];
|
||||
// cv::rectangle(image, face.GetRectSquare(), cv::Scalar(200, 0, 20), 2);
|
||||
// }
|
||||
//
|
||||
// cv::imshow("w", image);
|
||||
// cv::waitKey(0);
|
||||
|
||||
InspireModel model;
|
||||
ret = archive.LoadModel("mask_detect", model);
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
//
|
||||
// Created by Tunm-Air13 on 2023/9/11.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "opencv2/opencv.hpp"
|
||||
#include "log.h"
|
||||
#include "inspireface/feature_hub/simd.h"
|
||||
//#include <Eigen/Dense>
|
||||
// #include <Eigen/Dense>
|
||||
|
||||
using namespace inspire;
|
||||
|
||||
int main() {
|
||||
|
||||
int N = 512;
|
||||
int vectorSize = 512; // Vector length
|
||||
int vectorSize = 512; // Vector length
|
||||
{
|
||||
// Create an Nx512 matrix of type CV_32F and fill it with random numbers
|
||||
cv::Mat mat(N, vectorSize, CV_32F);
|
||||
@@ -26,14 +26,13 @@ int main() {
|
||||
std::cout << mat.size << std::endl;
|
||||
std::cout << one.size << std::endl;
|
||||
|
||||
auto timeStart = (double) cv::getTickCount();
|
||||
auto timeStart = (double)cv::getTickCount();
|
||||
|
||||
cv::Mat cosineSimilarities;
|
||||
cv::gemm(mat, one, 1, cv::Mat(), 0, cosineSimilarities);
|
||||
|
||||
double cost = ((double) cv::getTickCount() - timeStart) / cv::getTickFrequency() * 1000;
|
||||
double cost = ((double)cv::getTickCount() - timeStart) / cv::getTickFrequency() * 1000;
|
||||
INSPIRE_LOGD("Matrix COST: %f", cost);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
@@ -51,33 +50,33 @@ int main() {
|
||||
vectorOne[i] = static_cast<float>(std::rand()) / RAND_MAX;
|
||||
}
|
||||
|
||||
auto timeStart = (double) cv::getTickCount();
|
||||
auto timeStart = (double)cv::getTickCount();
|
||||
// dot
|
||||
for (const auto &v: matrix) {
|
||||
for (const auto &v : matrix) {
|
||||
simd_dot(v.data(), vectorOne.data(), vectorSize);
|
||||
}
|
||||
|
||||
double cost = ((double) cv::getTickCount() - timeStart) / cv::getTickFrequency() * 1000;
|
||||
double cost = ((double)cv::getTickCount() - timeStart) / cv::getTickFrequency() * 1000;
|
||||
INSPIRE_LOGD("Vector COST: %f", cost);
|
||||
}
|
||||
|
||||
// {
|
||||
// Eigen::initParallel();
|
||||
// Eigen::MatrixXf mat(N, vectorSize);
|
||||
// mat = Eigen::MatrixXf::Random(N, vectorSize);
|
||||
//
|
||||
// std::cout << mat.rows() << " x " << mat.cols() << std::endl;
|
||||
//
|
||||
//
|
||||
// Eigen::VectorXf one(vectorSize);
|
||||
// one = Eigen::VectorXf::Random(vectorSize);
|
||||
//
|
||||
// auto timeStart = (double) cv::getTickCount();
|
||||
// Eigen::VectorXf result = mat * one;
|
||||
//
|
||||
// double cost = ((double) cv::getTickCount() - timeStart) / cv::getTickFrequency() * 1000;
|
||||
// LOGD("Eigen COST: %f", cost);
|
||||
// }
|
||||
// {
|
||||
// Eigen::initParallel();
|
||||
// Eigen::MatrixXf mat(N, vectorSize);
|
||||
// mat = Eigen::MatrixXf::Random(N, vectorSize);
|
||||
//
|
||||
// std::cout << mat.rows() << " x " << mat.cols() << std::endl;
|
||||
//
|
||||
//
|
||||
// Eigen::VectorXf one(vectorSize);
|
||||
// one = Eigen::VectorXf::Random(vectorSize);
|
||||
//
|
||||
// auto timeStart = (double) cv::getTickCount();
|
||||
// Eigen::VectorXf result = mat * one;
|
||||
//
|
||||
// double cost = ((double) cv::getTickCount() - timeStart) / cv::getTickFrequency() * 1000;
|
||||
// LOGD("Eigen COST: %f", cost);
|
||||
// }
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Created by tunm on 2023/10/3.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
#include <iostream>
|
||||
#include "inspireface/c_api/inspireface.h"
|
||||
#include "opencv2/opencv.hpp"
|
||||
@@ -8,7 +9,7 @@
|
||||
|
||||
using namespace inspire;
|
||||
|
||||
std::string basename(const std::string& path) {
|
||||
std::string basename(const std::string &path) {
|
||||
size_t lastSlash = path.find_last_of("/\\"); // Take into account the cross-platform separator
|
||||
if (lastSlash == std::string::npos) {
|
||||
return path; // Without the slash, the entire path is the base name
|
||||
@@ -30,7 +31,7 @@ int compare() {
|
||||
parameter.enable_mask_detect = 1;
|
||||
parameter.enable_recognition = 1;
|
||||
parameter.enable_face_quality = 1;
|
||||
HF_DetectMode detMode = HF_DETECT_MODE_IMAGE; // Selecting the image mode is always detection
|
||||
HF_DetectMode detMode = HF_DETECT_MODE_IMAGE; // Selecting the image mode is always detection
|
||||
HContextHandle session;
|
||||
ret = HF_CreateFaceContextFromResourceFile(path, parameter, detMode, 3, &session);
|
||||
if (ret != HSUCCEED) {
|
||||
@@ -38,13 +39,13 @@ int compare() {
|
||||
}
|
||||
|
||||
std::vector<std::string> names = {
|
||||
"/Users/tunm/datasets/lfw_funneled/Abel_Pacheco/Abel_Pacheco_0001.jpg",
|
||||
"/Users/tunm/datasets/lfw_funneled/Abel_Pacheco/Abel_Pacheco_0004.jpg",
|
||||
"/Users/tunm/datasets/lfw_funneled/Abel_Pacheco/Abel_Pacheco_0001.jpg",
|
||||
"/Users/tunm/datasets/lfw_funneled/Abel_Pacheco/Abel_Pacheco_0004.jpg",
|
||||
};
|
||||
HInt32 featureNum;
|
||||
HF_GetFeatureLength(&featureNum);
|
||||
INSPIRE_LOGD("Feature length: %d", featureNum);
|
||||
HFloat featuresCache[names.size()][featureNum]; // Store the cached vector
|
||||
HFloat featuresCache[names.size()][featureNum]; // Store the cached vector
|
||||
|
||||
for (int i = 0; i < names.size(); ++i) {
|
||||
auto &name = names[i];
|
||||
@@ -63,7 +64,7 @@ int compare() {
|
||||
HImageHandle imageSteamHandle;
|
||||
ret = HF_CreateImageStream(&imageData, &imageSteamHandle);
|
||||
if (ret == HSUCCEED) {
|
||||
INSPIRE_LOGD("image handle: %ld", (long )imageSteamHandle);
|
||||
INSPIRE_LOGD("image handle: %ld", (long)imageSteamHandle);
|
||||
}
|
||||
|
||||
HF_MultipleFaceData multipleFaceData = {0};
|
||||
@@ -71,9 +72,11 @@ int compare() {
|
||||
INSPIRE_LOGD("Number of faces detected: %d", multipleFaceData.detectedNum);
|
||||
|
||||
for (int i = 0; i < multipleFaceData.detectedNum; ++i) {
|
||||
cv::Rect rect = cv::Rect(multipleFaceData.rects[i].x, multipleFaceData.rects[i].y, multipleFaceData.rects[i].width, multipleFaceData.rects[i].height);
|
||||
cv::Rect rect =
|
||||
cv::Rect(multipleFaceData.rects[i].x, multipleFaceData.rects[i].y, multipleFaceData.rects[i].width, multipleFaceData.rects[i].height);
|
||||
cv::rectangle(image, rect, cv::Scalar(0, 255, 200), 2);
|
||||
INSPIRE_LOGD("%d, track_id: %d, pitch: %f, yaw: %f, roll: %f", i, multipleFaceData.trackIds[i], multipleFaceData.angles.pitch[i], multipleFaceData.angles.yaw[i], multipleFaceData.angles.roll[i]);
|
||||
INSPIRE_LOGD("%d, track_id: %d, pitch: %f, yaw: %f, roll: %f", i, multipleFaceData.trackIds[i], multipleFaceData.angles.pitch[i],
|
||||
multipleFaceData.angles.yaw[i], multipleFaceData.angles.roll[i]);
|
||||
INSPIRE_LOGD("token size: %d", multipleFaceData.tokens->size);
|
||||
}
|
||||
#ifndef DISABLE_GUI
|
||||
@@ -89,16 +92,16 @@ int compare() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// for (int j = 0; j < 512; ++j) {
|
||||
// std::cout << featuresCache[0][j] << ", ";
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
// for (int j = 0; j < 512; ++j) {
|
||||
// std::cout << featuresCache[0][j] << ", ";
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
|
||||
// HSize size;
|
||||
// HF_GetFaceBasicTokenSize(&size);
|
||||
// LOGD("in size: %ld", size);
|
||||
//
|
||||
// LOGD("o size %d", multipleFaceData.tokens[0].size);
|
||||
// HSize size;
|
||||
// HF_GetFaceBasicTokenSize(&size);
|
||||
// LOGD("in size: %ld", size);
|
||||
//
|
||||
// LOGD("o size %d", multipleFaceData.tokens[0].size);
|
||||
|
||||
HBuffer buffer[multipleFaceData.tokens[0].size];
|
||||
HF_CopyFaceBasicToken(multipleFaceData.tokens[0], buffer, multipleFaceData.tokens[0].size);
|
||||
@@ -108,7 +111,7 @@ int compare() {
|
||||
token.data = buffer;
|
||||
|
||||
HFloat quality;
|
||||
// ret = HF_FaceQualityDetect(session, multipleFaceData.tokens[0], &quality);
|
||||
// ret = HF_FaceQualityDetect(session, multipleFaceData.tokens[0], &quality);
|
||||
ret = HF_FaceQualityDetect(session, token, &quality);
|
||||
INSPIRE_LOGD("RET : %d", ret);
|
||||
INSPIRE_LOGD("Q: %f", quality);
|
||||
@@ -120,7 +123,6 @@ int compare() {
|
||||
} else {
|
||||
INSPIRE_LOGE("image release error: %ld", ret);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HFloat compResult;
|
||||
@@ -147,7 +149,6 @@ int compare() {
|
||||
|
||||
int search() {
|
||||
HResult ret;
|
||||
// 初始化context
|
||||
HString path = "test_res/pack/Pikachu";
|
||||
HF_ContextCustomParameter parameter = {0};
|
||||
parameter.enable_liveness = 1;
|
||||
@@ -185,7 +186,7 @@ int search() {
|
||||
HImageHandle imageSteamHandle;
|
||||
ret = HF_CreateImageStream(&imageData, &imageSteamHandle);
|
||||
if (ret != HSUCCEED) {
|
||||
INSPIRE_LOGE("image handle error: %ld", (long )imageSteamHandle);
|
||||
INSPIRE_LOGE("image handle error: %ld", (long)imageSteamHandle);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -214,16 +215,15 @@ int search() {
|
||||
|
||||
ret = HF_FeatureHubInsertFeature(identity);
|
||||
if (ret != HSUCCEED) {
|
||||
INSPIRE_LOGE("插入失败: %ld", ret);
|
||||
INSPIRE_LOGE("Insert failed: %ld", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// // 在插入一次测试一下重复操作问题
|
||||
// ret = HF_FeaturesGroupInsertFeature(session, identity);
|
||||
// if (ret != HSUCCEED) {
|
||||
// LOGE("不能重复id插入: %ld", ret);
|
||||
// }
|
||||
// // Test duplicate insertion operation
|
||||
// ret = HF_FeaturesGroupInsertFeature(session, identity);
|
||||
// if (ret != HSUCCEED) {
|
||||
// INSPIRE_LOGE("Cannot insert duplicate ID: %ld", ret);
|
||||
// }
|
||||
|
||||
delete[] tagName;
|
||||
|
||||
@@ -247,7 +247,7 @@ int search() {
|
||||
HImageHandle imageSteamHandle;
|
||||
ret = HF_CreateImageStream(&imageData, &imageSteamHandle);
|
||||
if (ret != HSUCCEED) {
|
||||
INSPIRE_LOGE("image handle error: %ld", (long )imageSteamHandle);
|
||||
INSPIRE_LOGE("image handle error: %ld", (long)imageSteamHandle);
|
||||
return -1;
|
||||
}
|
||||
HF_MultipleFaceData multipleFaceData = {0};
|
||||
@@ -265,10 +265,10 @@ int search() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// ret = HF_FaceContextFeatureRemove(session, 3);
|
||||
// if (ret != HSUCCEED) {
|
||||
// LOGE("delete failed: %ld", ret);
|
||||
// }
|
||||
// ret = HF_FaceContextFeatureRemove(session, 3);
|
||||
// if (ret != HSUCCEED) {
|
||||
// LOGE("delete failed: %ld", ret);
|
||||
// }
|
||||
|
||||
std::string newName = "Six";
|
||||
char *newTagName = new char[newName.size() + 1];
|
||||
@@ -283,10 +283,9 @@ int search() {
|
||||
}
|
||||
delete[] newTagName;
|
||||
|
||||
|
||||
HF_FaceFeatureIdentity searchIdentity = {0};
|
||||
// HF_FaceFeature featureSearched = {0};
|
||||
// searchIdentity.feature = &featureSearched;
|
||||
// HF_FaceFeature featureSearched = {0};
|
||||
// searchIdentity.feature = &featureSearched;
|
||||
HFloat confidence;
|
||||
ret = HF_FeatureHubFaceSearch(feature, &confidence, &searchIdentity);
|
||||
if (ret != HSUCCEED) {
|
||||
@@ -298,7 +297,6 @@ int search() {
|
||||
INSPIRE_LOGD("The matched tag: %s", searchIdentity.tag);
|
||||
INSPIRE_LOGD("The matched customId: %d", searchIdentity.customId);
|
||||
|
||||
|
||||
// Face Pipeline
|
||||
ret = HF_MultipleFacePipelineProcess(session, imageSteamHandle, &multipleFaceData, parameter);
|
||||
if (ret != HSUCCEED) {
|
||||
@@ -331,7 +329,6 @@ int search() {
|
||||
|
||||
HF_FeatureHubViewDBTable();
|
||||
|
||||
|
||||
HF_FaceFeatureIdentity identity;
|
||||
ret = HF_FeatureHubGetFaceIdentity(100, &identity);
|
||||
if (ret != HSUCCEED) {
|
||||
@@ -350,47 +347,44 @@ int search() {
|
||||
}
|
||||
|
||||
int opiton() {
|
||||
// HInt32 mask = HF_ENABLE_FACE_RECOGNITION | HF_ENABLE_LIVENESS;
|
||||
// HInt32 mask = HF_ENABLE_FACE_RECOGNITION | HF_ENABLE_LIVENESS;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
HResult ret;
|
||||
|
||||
// {
|
||||
// // 测试ImageStream
|
||||
// cv::Mat image = cv::imread("test_res/images/kun.jpg");
|
||||
// HF_ImageData imageData = {0};
|
||||
// imageData.data = image.data;
|
||||
// imageData.height = image.rows;
|
||||
// imageData.width = image.cols;
|
||||
// imageData.rotation = CAMERA_ROTATION_0;
|
||||
// imageData.format = STREAM_BGR;
|
||||
//
|
||||
// HImageHandle imageSteamHandle;
|
||||
// ret = HF_CreateImageStream(&imageData, &imageSteamHandle);
|
||||
// if (ret == HSUCCEED) {
|
||||
// LOGD("image handle: %ld", (long )imageSteamHandle);
|
||||
// }
|
||||
// HF_DeBugImageStreamImShow(imageSteamHandle);
|
||||
//
|
||||
// ret = HF_ReleaseImageStream(imageSteamHandle);
|
||||
// if (ret == HSUCCEED) {
|
||||
// imageSteamHandle = nullptr;
|
||||
// LOGD("image released");
|
||||
// } else {
|
||||
// LOGE("image release error: %ld", ret);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// {
|
||||
// // TestImageStream
|
||||
// cv::Mat image = cv::imread("test_res/images/kun.jpg");
|
||||
// HF_ImageData imageData = {0};
|
||||
// imageData.data = image.data;
|
||||
// imageData.height = image.rows;
|
||||
// imageData.width = image.cols;
|
||||
// imageData.rotation = CAMERA_ROTATION_0;
|
||||
// imageData.format = STREAM_BGR;
|
||||
//
|
||||
// HImageHandle imageSteamHandle;
|
||||
// ret = HF_CreateImageStream(&imageData, &imageSteamHandle);
|
||||
// if (ret == HSUCCEED) {
|
||||
// LOGD("image handle: %ld", (long )imageSteamHandle);
|
||||
// }
|
||||
// HF_DeBugImageStreamImShow(imageSteamHandle);
|
||||
//
|
||||
// ret = HF_ReleaseImageStream(imageSteamHandle);
|
||||
// if (ret == HSUCCEED) {
|
||||
// imageSteamHandle = nullptr;
|
||||
// LOGD("image released");
|
||||
// } else {
|
||||
// LOGE("image release error: %ld", ret);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// compare();
|
||||
// compare();
|
||||
|
||||
search();
|
||||
|
||||
|
||||
opiton();
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Created by tunm on 2023/9/15.
|
||||
//
|
||||
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "face_context.h"
|
||||
@@ -46,10 +46,10 @@ int main() {
|
||||
|
||||
ctx.FaceDetectAndTrack(stream);
|
||||
|
||||
// LOGD("Track Cost: %f", ctx.GetTrackTotalUseTime());
|
||||
// LOGD("Track Cost: %f", ctx.GetTrackTotalUseTime());
|
||||
|
||||
auto &faces = ctx.GetTrackingFaceList();
|
||||
for (auto &face: faces) {
|
||||
for (auto &face : faces) {
|
||||
auto rect = face.GetRect();
|
||||
int track_id = face.GetTrackingId();
|
||||
int track_count = face.GetTrackingCount();
|
||||
@@ -60,19 +60,18 @@ int main() {
|
||||
|
||||
cv::Point text_position(rect.x, rect.y - 10);
|
||||
|
||||
const auto& pose_and_quality = face.high_result;
|
||||
const auto &pose_and_quality = face.high_result;
|
||||
float mean_quality = 0.0f;
|
||||
for (int i = 0; i < pose_and_quality.lmk_quality.size(); ++i) {
|
||||
mean_quality += pose_and_quality.lmk_quality[i];
|
||||
}
|
||||
mean_quality /= pose_and_quality.lmk_quality.size();
|
||||
mean_quality = 1 - mean_quality;
|
||||
std::string pose_text = "pitch: " + std::to_string(pose_and_quality.pitch) + ",Yaw: " + std::to_string(pose_and_quality.yaw) + ",roll:" +std::to_string(pose_and_quality.roll) + ", q: " +
|
||||
std::to_string(mean_quality);
|
||||
std::string pose_text = "pitch: " + std::to_string(pose_and_quality.pitch) + ",Yaw: " + std::to_string(pose_and_quality.yaw) +
|
||||
",roll:" + std::to_string(pose_and_quality.roll) + ", q: " + std::to_string(mean_quality);
|
||||
|
||||
cv::Point pose_position(rect.x, rect.y + rect.height + 20);
|
||||
|
||||
|
||||
int font_face = cv::FONT_HERSHEY_SIMPLEX;
|
||||
double font_scale = 0.5;
|
||||
int font_thickness = 1;
|
||||
@@ -82,7 +81,6 @@ int main() {
|
||||
cv::putText(frame, pose_text, pose_position, font_face, font_scale, font_color, font_thickness);
|
||||
}
|
||||
|
||||
|
||||
cv::imshow("Webcam", frame);
|
||||
|
||||
if (cv::waitKey(1) == 27) {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
//
|
||||
// Created by Tunm-Air13 on 2024/4/10.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "inspireface/c_api/inspireface.h"
|
||||
#include "inspireface/middleware/camera_stream/camera_stream.h"
|
||||
|
||||
void non_file_test() {
|
||||
|
||||
HResult ret;
|
||||
HPath path = "test_res/pack/abc"; // Use error path
|
||||
HPath path = "test_res/pack/abc"; // Use error path
|
||||
HF_ContextCustomParameter parameter = {0};
|
||||
HF_DetectMode detMode = HF_DETECT_MODE_IMAGE;
|
||||
HContextHandle session;
|
||||
@@ -28,7 +28,6 @@ void camera_test() {
|
||||
stream.SetDataFormat(inspire::NV12);
|
||||
stream.SetDataBuffer(image.data, image.rows, image.cols);
|
||||
auto decode = stream.GetScaledImage(1.0f, true);
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Created by tunm on 2024/4/6.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
#include <iostream>
|
||||
#include "track_module/face_track.h"
|
||||
#include "inspireface/recognition_module/face_feature_extraction.h"
|
||||
@@ -12,7 +13,7 @@ int main() {
|
||||
InspireArchive archive("test_res/pack/Pikachu");
|
||||
|
||||
FaceTrack track;
|
||||
// FaceRecognition recognition(archive, true);
|
||||
// FaceRecognition recognition(archive, true);
|
||||
|
||||
auto ret = track.Configuration(archive);
|
||||
INSPIRE_LOGD("ret=%d", ret);
|
||||
@@ -27,12 +28,11 @@ int main() {
|
||||
track.UpdateStream(stream, true);
|
||||
}
|
||||
|
||||
|
||||
// InspireModel model;
|
||||
// ret = archive.LoadModel("mask_detect", model);
|
||||
// std::cout << ret << std::endl;
|
||||
//
|
||||
// archive.PublicPrintSubFiles();
|
||||
// InspireModel model;
|
||||
// ret = archive.LoadModel("mask_detect", model);
|
||||
// std::cout << ret << std::endl;
|
||||
//
|
||||
// archive.PublicPrintSubFiles();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Created by tunm on 2023/9/8.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
#include <iostream>
|
||||
#include "track_module/face_detect/face_pose.h"
|
||||
|
||||
@@ -14,12 +15,14 @@ int main(int argc, char** argv) {
|
||||
|
||||
Configurable param;
|
||||
param.set<std::string>("input_layer", "data");
|
||||
param.set<std::vector<std::string>>("outputs_layers", {"ip3_pose", });
|
||||
param.set<std::vector<std::string>>("outputs_layers", {
|
||||
"ip3_pose",
|
||||
});
|
||||
param.set<std::vector<int>>("input_size", {112, 112});
|
||||
param.set<std::vector<float>>("mean", {0.0f, 0.0f, 0.0f});
|
||||
param.set<std::vector<float>>("norm", {1.0f, 1.0f, 1.0f});
|
||||
param.set<int>("input_channel", 1); // Input Gray
|
||||
param.set<int>("input_image_channel", 1); // BGR 2 Gray
|
||||
param.set<int>("input_image_channel", 1); // BGR 2 Gray
|
||||
|
||||
auto m_pose_net_ = std::make_shared<FacePose>();
|
||||
InspireModel model;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Created by tunm on 2023/9/10.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "face_context.h"
|
||||
@@ -11,7 +12,7 @@
|
||||
|
||||
using namespace inspire;
|
||||
|
||||
std::string GetFileNameWithoutExtension(const std::string& filePath) {
|
||||
std::string GetFileNameWithoutExtension(const std::string &filePath) {
|
||||
size_t slashPos = filePath.find_last_of("/\\");
|
||||
if (slashPos != std::string::npos) {
|
||||
std::string fileName = filePath.substr(slashPos + 1);
|
||||
@@ -52,7 +53,6 @@ int comparison1v1(FaceContext &ctx) {
|
||||
return -1;
|
||||
}
|
||||
ctx.FaceRecognitionModule()->FaceExtract(stream, faces[0], feature_1);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
@@ -68,7 +68,6 @@ int comparison1v1(FaceContext &ctx) {
|
||||
return -1;
|
||||
}
|
||||
ctx.FaceRecognitionModule()->FaceExtract(stream, faces[0], feature_2);
|
||||
|
||||
}
|
||||
|
||||
float rec;
|
||||
@@ -78,14 +77,11 @@ int comparison1v1(FaceContext &ctx) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int search(FaceContext &ctx) {
|
||||
// std::shared_ptr<FeatureBlock> block;
|
||||
// block.reset(FeatureBlock::Create(hyper::MC_OPENCV));
|
||||
|
||||
// std::shared_ptr<FeatureBlock> block;
|
||||
// block.reset(FeatureBlock::Create(hyper::MC_OPENCV));
|
||||
|
||||
std::vector<String> files_list = {
|
||||
};
|
||||
std::vector<String> files_list = {};
|
||||
for (int i = 0; i < files_list.size(); ++i) {
|
||||
auto image = cv::imread(files_list[i]);
|
||||
CameraStream stream;
|
||||
@@ -103,11 +99,11 @@ int search(FaceContext &ctx) {
|
||||
FEATURE_HUB->RegisterFaceFeature(feature, i, GetFileNameWithoutExtension(files_list[i]), 1000 + i);
|
||||
}
|
||||
|
||||
// ctx.FaceRecognitionModule()->PrintMatrix();
|
||||
// ctx.FaceRecognitionModule()->PrintMatrix();
|
||||
|
||||
// auto ret = block->DeleteFeature(3);
|
||||
// LOGD("DEL: %d", ret);
|
||||
// block->PrintMatrix();
|
||||
// auto ret = block->DeleteFeature(3);
|
||||
// LOGD("DEL: %d", ret);
|
||||
// block->PrintMatrix();
|
||||
|
||||
FEATURE_HUB->DeleteFaceFeature(2);
|
||||
|
||||
@@ -129,8 +125,8 @@ int search(FaceContext &ctx) {
|
||||
}
|
||||
ctx.FaceRecognitionModule()->FaceExtract(stream, faces[0], feature);
|
||||
|
||||
// block->UpdateFeature(4, feature);
|
||||
// block->AddFeature(feature);
|
||||
// block->UpdateFeature(4, feature);
|
||||
// block->AddFeature(feature);
|
||||
}
|
||||
|
||||
// Prepare an image to search
|
||||
@@ -150,18 +146,17 @@ int search(FaceContext &ctx) {
|
||||
ctx.FaceRecognitionModule()->FaceExtract(stream, faces[0], feature);
|
||||
|
||||
SearchResult result;
|
||||
auto timeStart = (double) cv::getTickCount();
|
||||
auto timeStart = (double)cv::getTickCount();
|
||||
FEATURE_HUB->SearchFaceFeature(feature, result);
|
||||
double cost = ((double) cv::getTickCount() - timeStart) / cv::getTickFrequency() * 1000;
|
||||
double cost = ((double)cv::getTickCount() - timeStart) / cv::getTickFrequency() * 1000;
|
||||
INSPIRE_LOGD("Search time: %f", cost);
|
||||
INSPIRE_LOGD("Top1: %d, %f, %s %d", result.index, result.score, result.tag.c_str(), result.customId);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(int argc, char **argv) {
|
||||
FaceContext ctx;
|
||||
CustomPipelineParameter param;
|
||||
param.enable_recognition = true;
|
||||
@@ -170,11 +165,10 @@ int main(int argc, char** argv) {
|
||||
INSPIRE_LOGE("Initialization error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
comparison1v1(ctx);
|
||||
|
||||
// search(ctx);
|
||||
// search(ctx);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Created by tunm on 2023/9/7.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "face_context.h"
|
||||
@@ -31,12 +32,12 @@ int main(int argc, char** argv) {
|
||||
|
||||
std::vector<HyperFaceData> faces;
|
||||
for (int i = 0; i < ctx.GetNumberOfFacesCurrentlyDetected(); ++i) {
|
||||
// const ByteArray &byteArray = ctx.GetDetectCache()[i];
|
||||
// const ByteArray &byteArray = ctx.GetDetectCache()[i];
|
||||
HyperFaceData face = {0};
|
||||
// ret = DeserializeHyperFaceData(byteArray, face);
|
||||
// ret = DeserializeHyperFaceData(byteArray, face);
|
||||
|
||||
const FaceBasicData &faceBasic = ctx.GetFaceBasicDataCache()[i];
|
||||
ret = DeserializeHyperFaceData((char* )faceBasic.data, faceBasic.dataSize, face);
|
||||
const FaceBasicData& faceBasic = ctx.GetFaceBasicDataCache()[i];
|
||||
ret = DeserializeHyperFaceData((char*)faceBasic.data, faceBasic.dataSize, face);
|
||||
INSPIRE_LOGD("OK!");
|
||||
|
||||
if (ret != HSUCCEED) {
|
||||
@@ -48,17 +49,16 @@ int main(int argc, char** argv) {
|
||||
std::cout << rect << std::endl;
|
||||
cv::rectangle(rot90, rect, cv::Scalar(0, 0, 233), 2);
|
||||
|
||||
for (auto &p: face.keyPoints) {
|
||||
for (auto& p : face.keyPoints) {
|
||||
cv::Point2f point(p.x, p.y);
|
||||
cv::circle(rot90, point, 0, cv::Scalar(0, 0, 255), 5);
|
||||
}
|
||||
}
|
||||
|
||||
// cv::imshow("wq", rot90);
|
||||
// cv::waitKey(0);
|
||||
// cv::imshow("wq", rot90);
|
||||
// cv::waitKey(0);
|
||||
cv::imwrite("wq.png", rot90);
|
||||
|
||||
|
||||
ret = ctx.FacesProcess(stream, faces, param);
|
||||
if (ret != HSUCCEED) {
|
||||
return -1;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Created by Tunm-Air13 on 2023/10/11.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "inspireface/feature_hub/persistence/sqlite_faces_manage.h"
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
//
|
||||
// Created by tunm on 2023/8/29.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
#include <iostream>
|
||||
#include "inspireface/track_module/face_track.h"
|
||||
#include "opencv2/opencv.hpp"
|
||||
|
||||
using namespace inspire;
|
||||
|
||||
int video_test(FaceTrack &ctx, int cam_id) {
|
||||
int video_test(FaceTrack& ctx, int cam_id) {
|
||||
#ifndef ISF_USE_MOBILE_OPENCV_IN_LOCAL
|
||||
cv::VideoCapture cap(cam_id);
|
||||
|
||||
@@ -37,8 +38,8 @@ int video_test(FaceTrack &ctx, int cam_id) {
|
||||
|
||||
INSPIRE_LOGD("Track Cost: %f", ctx.GetTrackTotalUseTime());
|
||||
|
||||
auto const &faces = ctx.trackingFace;
|
||||
for (auto const &face: faces) {
|
||||
auto const& faces = ctx.trackingFace;
|
||||
for (auto const& face : faces) {
|
||||
auto rect = face.GetRect();
|
||||
int track_id = face.GetTrackingId();
|
||||
int track_count = face.GetTrackingCount();
|
||||
@@ -51,7 +52,7 @@ int video_test(FaceTrack &ctx, int cam_id) {
|
||||
|
||||
const auto& pose_and_quality = face.high_result;
|
||||
std::vector<float> euler = {pose_and_quality.yaw, pose_and_quality.roll, pose_and_quality.pitch};
|
||||
std::string pose_text = "P: " + std::to_string(euler[0]) + ",Yaw: " + std::to_string(euler[1]) + ",roll:" +std::to_string(euler[2]);
|
||||
std::string pose_text = "P: " + std::to_string(euler[0]) + ",Yaw: " + std::to_string(euler[1]) + ",roll:" + std::to_string(euler[2]);
|
||||
|
||||
cv::Point pose_position(rect.x, rect.y + rect.height + 20);
|
||||
|
||||
@@ -64,7 +65,6 @@ int video_test(FaceTrack &ctx, int cam_id) {
|
||||
cv::putText(frame, pose_text, pose_position, font_face, font_scale, font_color, font_thickness);
|
||||
}
|
||||
|
||||
|
||||
cv::imshow("Webcam", frame);
|
||||
|
||||
if (cv::waitKey(1) == 27) {
|
||||
@@ -107,8 +107,8 @@ void video_file_test(FaceTrack& ctx, const std::string& video_filename) {
|
||||
ctx.UpdateStream(stream, false);
|
||||
INSPIRE_LOGD("Track Cost: %f", ctx.GetTrackTotalUseTime());
|
||||
|
||||
auto const &faces = ctx.trackingFace;
|
||||
for (auto const &face: faces) {
|
||||
auto const& faces = ctx.trackingFace;
|
||||
for (auto const& face : faces) {
|
||||
auto rect = face.GetRect();
|
||||
int track_id = face.GetTrackingId();
|
||||
int track_count = face.GetTrackingCount();
|
||||
@@ -116,7 +116,7 @@ void video_file_test(FaceTrack& ctx, const std::string& video_filename) {
|
||||
cv::rectangle(frame, rect, cv::Scalar(0, 0, 255), 2, 1);
|
||||
|
||||
auto lmk = face.GetLanmdark();
|
||||
for (auto & p : lmk) {
|
||||
for (auto& p : lmk) {
|
||||
cv::circle(frame, p, 0, cv::Scalar(0, 0, 242), 2);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,8 @@ void video_file_test(FaceTrack& ctx, const std::string& video_filename) {
|
||||
cv::Point text_position(rect.x, rect.y - 10);
|
||||
|
||||
const auto& euler = face.high_result;
|
||||
std::string pose_text = "pitch: " + std::to_string(euler.pitch) + ",Yaw: " + std::to_string(euler.yaw) + ",roll:" +std::to_string(euler.roll);
|
||||
std::string pose_text =
|
||||
"pitch: " + std::to_string(euler.pitch) + ",Yaw: " + std::to_string(euler.yaw) + ",roll:" + std::to_string(euler.roll);
|
||||
|
||||
cv::Point pose_position(rect.x, rect.y + rect.height + 20);
|
||||
|
||||
@@ -163,8 +164,8 @@ int main(int argc, char** argv) {
|
||||
|
||||
const std::string folder = "test_res/pack/Pikachu";
|
||||
INSPIRE_LOGD("%s", folder.c_str());
|
||||
// ModelLoader loader;
|
||||
// loader.Reset(folder);
|
||||
// ModelLoader loader;
|
||||
// loader.Reset(folder);
|
||||
|
||||
InspireArchive archive;
|
||||
archive.ReLoad(folder);
|
||||
@@ -183,7 +184,7 @@ int main(int argc, char** argv) {
|
||||
} else if (source == "image") {
|
||||
cv::Mat image = cv::imread(input);
|
||||
if (!image.empty()) {
|
||||
// image_test(ctx, image);
|
||||
// image_test(ctx, image);
|
||||
} else {
|
||||
std::cerr << "Unable to open the image file." << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user