STASM-ASM在linux中不工作
我正在做一个图像处理项目,在这个项目中我需要定位和标记一些面部属性(例如:嘴、鼻子、眼睛等)。我正在尝试使用STASM-ASM算法(),我已经在以前在Windows中完成的项目中使用了该技术,在那里我获得了非常好的结果 当尝试在Linux中使用此实用程序时,问题出现了,我按照作者提供的说明构建了object.o文件。然后,我按照中的说明创建了一个静态库。然后,我将此静态库链接到我的项目,并包含以下头文件:STASM-ASM在linux中不工作,linux,gcc,ubuntu,opencv,Linux,Gcc,Ubuntu,Opencv,我正在做一个图像处理项目,在这个项目中我需要定位和标记一些面部属性(例如:嘴、鼻子、眼睛等)。我正在尝试使用STASM-ASM算法(),我已经在以前在Windows中完成的项目中使用了该技术,在那里我获得了非常好的结果 当尝试在Linux中使用此实用程序时,问题出现了,我按照作者提供的说明构建了object.o文件。然后,我按照中的说明创建了一个静态库。然后,我将此静态库链接到我的项目,并包含以下头文件: // stasm.h #ifndef STASM_H_ #define STASM_H_
// stasm.h
#ifndef STASM_H_
#define STASM_H_
void AsmSearchDll(int *pnlandmarks, int landmarks[], const char image_name[], const char image_data[], const int width, const int height, const int is_color, const char con f_file0[], const char conf_file1[]);
#endif
尝试构建此项目时,我遇到以下错误:
undefined reference to `AsmSearchDll(int*, int*, char const*, char const*, int, int, int, char const*, char const*)'
这对我来说似乎很奇怪,因为我确信头文件是正确包含的。我还尝试了作者在包中包含的.hpp文件,获得了相同的精确结果。此问题与中处理的问题类似。但是,该职位仍然没有最终解决方案。我希望有人能帮我解决这个问题,STASM-ASM实用程序真的很棒,很遗憾它不能在linux中使用
我认为问题不在于类型不匹配,我在分析了对ASMSearchDll函数的调用及其声明后得出结论。函数的调用如下所示:
AsmSearchDll(&nlandmarks, landmarks, image_name, img->imageData, img->width, img->height,1 /* is_color */, NULL /* conf_file0 */, NULL /* conf_file1 */);
函数定义如下:
// stasm_dll.hpp
#ifndef stasm_dll_hpp
#define stasm_dll_hpp
extern "C"
void AsmSearchDll(
int *pnlandmarks, // out: number of landmarks, 0 if can't get landmarks
int landmarks[], // out: the landmarks, caller must allocate
const char image_name[], // in: used in internal error messages, if necessary
const char image_data[], // in: image data, 3 bytes per pixel if is_color
const int width, // in: the width of the image
const int height, // in: the height of the image
const int is_color, // in: 1 if RGB image, 0 for grayscale
const char conf_file0[], // in: 1st config filename, NULL for default
const char conf_file1[]); // in: 2nd config filename, NULL for default, "" if none
#endif // stasm_dll_hpp
../src/PruebaStasm.cpp:44:155: error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive]
../src/stasm_dll.hpp:6:6: error: initializing argument 1 of ‘void AsmSearchDll(int*, int*, const char*, const char*, int, int, int, const char*, const char*)’ [-fpermissive]
此外,如果更改传递给函数的某个参数的格式,会出现如下错误:
// stasm_dll.hpp
#ifndef stasm_dll_hpp
#define stasm_dll_hpp
extern "C"
void AsmSearchDll(
int *pnlandmarks, // out: number of landmarks, 0 if can't get landmarks
int landmarks[], // out: the landmarks, caller must allocate
const char image_name[], // in: used in internal error messages, if necessary
const char image_data[], // in: image data, 3 bytes per pixel if is_color
const int width, // in: the width of the image
const int height, // in: the height of the image
const int is_color, // in: 1 if RGB image, 0 for grayscale
const char conf_file0[], // in: 1st config filename, NULL for default
const char conf_file1[]); // in: 2nd config filename, NULL for default, "" if none
#endif // stasm_dll_hpp
../src/PruebaStasm.cpp:44:155: error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive]
../src/stasm_dll.hpp:6:6: error: initializing argument 1 of ‘void AsmSearchDll(int*, int*, const char*, const char*, int, int, int, const char*, const char*)’ [-fpermissive]
我使用提供的makefile再次编译了.o文件,在本教程之后,我使用这些.o文件创建了共享和动态库:
我不明白问题出在哪里
致以最良好的祝愿
Luis由于stasm_dll.hpp中的定义是用extern“C”包装的,因此我认为在以后的程序中包括stasm.h时,也必须这样做,例如:
extern "C" {
#include "stasm.h"
}
这应该得到调用约定,C/C++问题正确,如下所示: 您需要调用:
SHAPE // results returned as a SHAPE
AsmSearch(
SHAPE &StartShape, // out: start shape returned in here
DET_PARAMS &DetParams, // out: face detector parameters
double &MeanTime, // out: mean time per image (face det failed excluded)
const RgbImage &RgbImg, // in: find face features in this image
const char sImage[], // in: file path for RgbImg, for err msgs
const bool fRowley=false, // in: true to use VJ detector, else Rowley
const char sConfFile0[]="../data/mu-68-1d.conf", // in: 1st config filename
const char sConfFile1[]="../data/mu-76-2d.conf", // in: 2nd config filename
const char sDataDir[]="../data",// in: data directory
const char sShapeFile[]=NULL, // in: if not NULL then use face detector in here
bool fIssueWarnings=true); // in: true to issue warnings if needed
我不确定您是否可以在Linux下调用AsmSearchDll。如评论所述,AsmSearchDll函数被认为仅在windows中使用,因此在Linux中无法轻松使用 最后,我在linux中使用了AsmSearch函数,但做了一些小改动。为了使用这个函数,我构建了一个静态库,其中包含从stasm asm包中包含的源文件获得的.o文件 更准确地说,我在makefile文件中添加了以下内容:
LIB_OBJ=\
stasmlibrary.o\
$(STASM_OBJ)
lib: $(LIB_OBJ)
ar rs libstasm.a $(LIB_OBJ)
其中,stasmlibrary.cpp和stasmlibrary.hpp包含我在包中提供的AsmSearch中定义的函数。STASM_OBJ变量包括以下对象文件:
stasm.o\
atface.o\
ezfont.o\
find.o\
follow.o\
forward.o\
imfile.o\
imwrite.o\
imgiven.o\
imshape.o\
imutil.o\
initnet.o\
jpegutil.o\
landmarks.o\
mat.o\
matvec.o\
mchol.o\
mrand.o\
prof.o\
readconf.o\
rgbimutil.o\
rowley.o\
rowleyhand.o\
search.o\
shapefile.o\
shapemodel.o\
sparsemat.o\
startshape.o\
safe_alloc.o\
tclHash.o\
util.o\
violajones.o\
vjhand.o\
wrbmp.o\
asmsearch.o\
initasm.o\
readasm.o\
err.o\
release.o\
tab.o
感谢所有回答这些问题的人,感谢他们的时间和善意的建议。头文件中有一个数组作为第二个参数,并在指针上使用它。还有其他类型的不匹配。如果这是C++,它肯定会抱怨,因为…或者可能是因为函数被定义为C,当包含头时,被理解为C++。我认为问题不在于类型不匹配,我将在问题中提供更多细节:D:谢谢你的回答,我试了你的建议,但问题仍然存在。我将尝试从源代码中包含STASM-ASM实用程序,因为在我看来,STASM ASM的编译和构建都考虑了Windows的使用。这个想法在我脑海中浮现,因为我试图以多种方式包括图书馆,但没有成功。在这个问题上,作者得出了类似的结论。