#include "STFaceCache.h"
|
#include <MaterialBuffer.h>
|
#include <logger.h>
|
#include <map>
|
|
#include <sys/types.h>
|
#include <dirent.h>
|
|
#include "sample_face_search.h"
|
|
struct STFaceContext
|
{
|
int dbid;
|
std::string dbfn;
|
stface_handles handles;
|
};
|
|
typedef std::map<int, STFaceContext> stface_ctx_map_t; // <dbid, ctx>
|
|
STFaceCache::STFaceCache(const std::string& _stfacedbPath)
|
: stfacedbPath(_stfacedbPath), stfaceModels(STFACESDK_BASE "/models"), _cacheContext(new stface_ctx_map_t)
|
{
|
LOG_INFO << "st face db: " << stfacedbPath << LOG_ENDL;
|
LOG_INFO << "st face sdk models: " << stfaceModels << LOG_ENDL;
|
}
|
|
STFaceCache::~STFaceCache()
|
{
|
delete (stface_ctx_map_t*)_cacheContext;
|
_cacheContext = nullptr;
|
}
|
|
bool STFaceCache::load_dbs()
|
{
|
stface_ctx_map_t& cacheContext(*(stface_ctx_map_t*)_cacheContext);
|
|
DIR* dp = opendir(stfacedbPath.c_str());
|
if (dp != NULL)
|
{
|
struct dirent* ep;
|
while(ep = readdir(dp))
|
{
|
//puts(ep->d_name);
|
|
STFaceContext ctx;
|
ctx.dbfn = ep->d_name;
|
ctx.dbid = strtol(ctx.dbfn.c_str(), nullptr, 10);
|
}
|
closedir(dp);
|
}
|
else
|
{
|
LOG_ERROR << "Couldn't open the directory." << LOG_ENDL;
|
return false;
|
}
|
}
|
|
FDP_FaceDetectResult STFaceCache::detect(const STFaceImage& img)
|
{
|
stface_ctx_map_t& cacheContext(*(stface_ctx_map_t*)_cacheContext);
|
return FDP_FaceDetectResult(0, 0);
|
}
|
|
FDP_FaceDetectResult STFaceCache::save(const STFaceImage& img)
|
{
|
stface_ctx_map_t& cacheContext(*(stface_ctx_map_t*)_cacheContext);
|
return FDP_FaceDetectResult(0, 0);
|
}
|