mirror of
https://github.com/deepinsight/insightface.git
synced 2026-05-14 12:17:55 +00:00
Update inspireface to 1.2.0
This commit is contained in:
@@ -1,43 +1,25 @@
|
||||
//
|
||||
// Created by tunm on 2023/10/12.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
#pragma
|
||||
#ifndef HYPERFACEREPO_TEST_TOOLS_H
|
||||
#define HYPERFACEREPO_TEST_TOOLS_H
|
||||
#ifndef INSPIREFACE_TEST_TOOLS_H
|
||||
#define INSPIREFACE_TEST_TOOLS_H
|
||||
|
||||
#include "opencv2/opencv.hpp"
|
||||
#include "inspireface/c_api/inspireface.h"
|
||||
#include <fstream>
|
||||
#include <cstdint> // For uint8_t
|
||||
#include <cstdint> // For uint8_t
|
||||
#include <inspirecv/inspirecv.h>
|
||||
|
||||
// Bad function
|
||||
inline HResult ReadImageToImageStream(const char *path, HFImageStream &handle, HFImageFormat format = HF_STREAM_BGR,
|
||||
HFRotation rot = HF_CAMERA_ROTATION_0) {
|
||||
cv::Mat image = cv::imread(path);
|
||||
if (image.empty()) {
|
||||
return -1;
|
||||
}
|
||||
HFImageData imageData = {0};
|
||||
imageData.data = image.data;
|
||||
imageData.height = image.rows;
|
||||
imageData.width = image.cols;
|
||||
imageData.format = format;
|
||||
imageData.rotation = rot;
|
||||
|
||||
auto ret = HFCreateImageStream(&imageData, &handle);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline HResult CVImageToImageStream(const cv::Mat& image, HFImageStream &handle, HFImageFormat format = HF_STREAM_BGR,
|
||||
inline HResult CVImageToImageStream(const inspirecv::Image &image, HFImageStream &handle, HFImageFormat format = HF_STREAM_BGR,
|
||||
HFRotation rot = HF_CAMERA_ROTATION_0) {
|
||||
if (image.empty()) {
|
||||
if (image.Empty()) {
|
||||
return -1;
|
||||
}
|
||||
HFImageData imageData = {0};
|
||||
imageData.data = image.data;
|
||||
imageData.height = image.rows;
|
||||
imageData.width = image.cols;
|
||||
imageData.data = (uint8_t *)image.Data();
|
||||
imageData.height = image.Height();
|
||||
imageData.width = image.Width();
|
||||
imageData.format = format;
|
||||
imageData.rotation = rot;
|
||||
|
||||
@@ -46,9 +28,8 @@ inline HResult CVImageToImageStream(const cv::Mat& image, HFImageStream &handle,
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
inline uint8_t *ReadNV21Data(const char *filePath, int width, int height) {
|
||||
const int nv21Size = width * height * 3 / 2; // Calculate the NV21 data size
|
||||
const int nv21Size = width * height * 3 / 2; // Calculate the NV21 data size
|
||||
|
||||
// Memory is allocated dynamically to store NV21 data
|
||||
uint8_t *nv21Data = new uint8_t[nv21Size];
|
||||
@@ -76,4 +57,4 @@ inline uint8_t *ReadNV21Data(const char *filePath, int width, int height) {
|
||||
return nv21Data;
|
||||
}
|
||||
|
||||
#endif //HYPERFACEREPO_TEST_TOOLS_H
|
||||
#endif // INSPIREFACE_TEST_TOOLS_H
|
||||
|
||||
Reference in New Issue
Block a user