OAID / TengineKit

TengineKit - Free, Fast, Easy, Real-Time Face Detection & Face Landmarks & Face Attributes & Hand Detection & Hand Landmarks & Body Detection & Body Landmarks & Iris Landmarks & Yolov5 SDK On Mobile.
Other
2.38k stars 318 forks source link

[Linux] facesdk_readModelFromFile 参数和编译后运行报错问题 #19

Closed wasupandceacar closed 3 years ago

wasupandceacar commented 3 years ago

如果直接编译 Linux 版本,会出现和 https://github.com/OAID/TengineKit/issues/15 一样的问题。

libTengineKitSDK.so 中,tenginekit_api.h 引用的 facesdk_readModelFromFile 函数的参数和 demo.cpp 中的函数参数不一样,多了一个 bool 参数,我也不知道这个参数的具体意义。

自己在 tenginekit_api.h 加入了这个 bool 参数,比如将

void facesdk_readModelFromFile(ModelType type, const char* model_path, ImageFormat modelInputFormat);

改为

void facesdk_readModelFromFile(ModelType type, const char* model_path, ImageFormat modelInputFormat, bool why);

之后,能够编译成功。但运行识别会报错:

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

colab 复现链接 可以复现这个报错

我看了一下,是 demo.app 的第 45 行会报错:

facesdk_readModelFromFile(ModelType::Detect, "models/detect.bin", ImageFormat::RGB, true);

另外,如果把 45 行的最后那个 bool 参数改为 false 的话:

facesdk_readModelFromFile(ModelType::Detect, "models/detect.bin", ImageFormat::RGB, false);

45 行不会报错,但 46 行会报错:

sdkFaces faces = facesdk_detect(data);

这种情况下,colab 不会显示错误,会直接退出运行,但在我自己机子上会显示这个错误:

Segmentation fault (core dumped)
wasupandceacar commented 3 years ago

@Crusoekid 请问开发者这个问题有什么解决方法吗?

Crusoekid commented 3 years ago

你模型路径设置对了吗?"models/detect.bin"这个路径

Crusoekid commented 3 years ago

你用 facesdk_readModelFromFile(ModelType type, const char* model_path, ImageFormat modelInputFormat)这个接口就好

Crusoekid commented 3 years ago

我已经更新了最新版本的库,你可以替换尝试一下

Litou-lyh commented 3 years ago

我使用了最新版本,然后把模型路径改为绝对路径就行了,看来是demo里写的路径不对

wasupandceacar commented 3 years ago

已解决,谢谢