ShiqiYu / libfacedetection

An open source library for face detection in images. The face detection speed can reach 1000FPS.
Other
12.28k stars 3.05k forks source link

多线程调用 #22

Closed sean028 closed 7 years ago

sean028 commented 7 years ago

您好,11 月 10 日更新的这个版本您说的是可以在多线程调用,但是我用 VS2015(以及 opencv 3.1)测试发现,还是没法多线程同时调用啊,必须要加锁。 另外,您提供的 dll 似乎是 VS2010 编译的,而新版的接口里面用到了 vector,编译器版本不匹配时在 vector 析构的时候就会出现问题,除非调用之前为 vector 预留足够的空间。

ShiqiYu commented 7 years ago

这个版本有问题!请用上一个版本,抱歉!我们马上更新。

2016年11月16日星期三,sean028 notifications@github.com 写道:

您好,11 月 10 日更新的这个版本您说的是可以在多线程调用,但是我用 VS2015(以及 opencv 3.1)测试发现,还是没法多线程同时调用啊,必须要加锁。 另外,您提供的 dll 似乎是 VS2010 编译的,而新版的接口里面用到了 vector,编译器版本不匹配时在 vector 析构的时候就会出现问题,除非调用之前为 vector 预留足够的空间。

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ShiqiYu/libfacedetection/issues/22, or mute the thread https://github.com/notifications/unsubscribe-auth/AG0eHRBZitz4JFGhWioFlAH8fU9_qUKpks5q-qlBgaJpZM4KzdbP .

Dr. Shiqi YU (于仕琪) School of Computer Science and Software Engineering, Shenzhen University, 518060, China +86-755-2673 3127

shz0519 commented 7 years ago

于老师您好,我前几天下了最新版本,也出现了上述的问题,但是在网上找不到上一个版本了,您能发我一份吗?shz_0519@126.com

ShiqiYu commented 7 years ago

你研究一下GitHub用法,上面有所有历史记录。

2016年11月16日星期三,shz0519 notifications@github.com 写道:

于老师您好,我前几天下了最新版本,也出现了上述的问题,但是在网上找不到上一个版本了,您能发我一份吗?shz_0519@126.com javascript:_e(%7B%7D,'cvml','shz_0519@126.com');

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ShiqiYu/libfacedetection/issues/22#issuecomment-260877960, or mute the thread https://github.com/notifications/unsubscribe-auth/AG0eHQSoYxeyLX5lDZHjbn9jyyuLPwkOks5q-raQgaJpZM4KzdbP .

Dr. Shiqi YU (于仕琪) School of Computer Science and Software Engineering, Shenzhen University, 518060, China +86-755-2673 3127

EncodeTS commented 7 years ago

@shz0519 https://github.com/ShiqiYu/libfacedetection/commits/master 在这里可以看到所有提交记录,点最右边的<>符号然后下载该版本就行了。

shz0519 commented 7 years ago

谢谢啊

在 2016-11-16 16:04:07,"Su Tang" notifications@github.com 写道:

@shz0519https://github.com/ShiqiYu/libfacedetection/commits/master在这里可以看到所有提交记录,下载对应版本就行了

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

chai2010 commented 7 years ago

头文件含有 C++元素 std::vector. 对于动态库来说, 不同的VC版本之间vector的二进制接口是不兼容的, MinGW同样是不兼容. (C++没有二进制接口标准, C++头文件含有代码(编译时和使用者的VC并不同)导致问题更严重, 各个编译器实现都不一样).

最安全的方式是头文件只包含必要的C语言声明语句.

可以将 std::vector 重新包装为C接口:

typedef struct FaceInfoList_T FaceInfoList_T;

FaceInfoList_T* FaceInfoList_New();
void FaceInfoList_Delete(FaceInfoList_T* p);

int FaceInfoList_Size(FaceInfoList_T* p);
FaceInfo* FaceInfoList_At(FaceInfoList_T* p, int i);

或者直接传入一个 FaceInfo 数组, 给出最大长度:

int facedetect_frontal(FaceInfo faces[], int faces_length, ...);

返回结果不超出数组容量就行了.

ShiqiYu commented 7 years ago

谢谢你的建议,我已经用第二个方案改写了,再测试一下就放上来。

2016年11月16日星期三,chai2010 notifications@github.com 写道:

头文件含有 C++元素 std::vector. 对于动态库来说, 不同的VC版本之间vector的二进制接口是不兼容的, MinGW同样是不兼容. (C++没有二进制接口标准, C++头文件含有代码(编译时和使用者的VC并不同)导致问题更严重, 各个编译器实现都不一样).

最安全的方式是头文件只包含必要的C语言声明语句.

可以将 std::vector 重新包装为C接口:

typedef struct FaceInfoList_T FaceInfoList_T;

FaceInfoList_T* FaceInfoList_New();void FaceInfoList_Delete(FaceInfoList_T* p); int FaceInfoList_Size(FaceInfoList_T* p); FaceInfo* FaceInfoList_At(FaceInfoList_T* p, int i);

或者直接传入一个 FaceInfo 数组, 给出最大长度:

int facedetect_frontal(FaceInfo faces[], int faces_length, ...);

返回结果不超出数组容量就行了.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ShiqiYu/libfacedetection/issues/22#issuecomment-260900352, or mute the thread https://github.com/notifications/unsubscribe-auth/AG0eHVby4H9JAEYYuNfzW-MadJZ0YyD9ks5q-tChgaJpZM4KzdbP .

Dr. Shiqi YU (于仕琪) School of Computer Science and Software Engineering, Shenzhen University, 518060, China +86-755-2673 3127

ShiqiYu commented 7 years ago

Hi, guys, thank you for reporting bugs. I have fixed the bug and uploaded the lib to GitHub. Please download the newest version and test it. Enjoy!