2013-02-15 38 views
0

我正在研究一個圖像處理工程,我需要找到並標記一些人臉屬性(即:嘴巴,鼻子,眼睛等)。我試圖使用STASM-ASM算法(http://www.milbo.users.sonic.net/stasm/),我已經在之前在Windows中完成的項目中使用了這種技術,並獲得了非常好的結果。STASM-ASM不能在linux中工作

嘗試在Linux中使用此實用程序時出現問題,我按照作者提供的說明構建了對象.o文件。然後,我按照How to create a static library with g++?中的說明創建了一個靜態庫。然後,我掛這個靜態庫到我的proyect幷包括下面的頭文件:

// 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 

當試圖建立這個proyect我得到TE以下錯誤:

undefined reference to `AsmSearchDll(int*, int*, char const*, char const*, int, int, int, char const*, char const*)' 

這似乎很奇怪,我作爲我確定頭文件是正確的。我也試着用包裝上的作者包含的.hpp文件,並獲得了相同的確切結果。這個問題與Trying to get stasm to work on Ubuntu中處理的問題類似。但是,這個職位仍然沒有最終的解決方案。我希望有人能夠幫助我解決這個問題,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] 

我再編譯的.o文件使用提供的生成文件,有下列本教程中我創建的共享這些.o文件和動態庫:http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html

我不明白問題在哪裏。

最好的問候,

路易斯

+0

您有一個數組作爲頭文件中的第二個參數,並在指針上使用它。還有其他類型的不匹配。如果這是C++,肯定可以抱怨,因爲...或者可能是因爲函數被定義爲_C_,並且在包含頭部時被理解爲_C++ _。 – vonbrand 2013-02-15 02:08:35

+0

@vonbrand謝謝你的時間和答案。我認爲問題不是類型不匹配,我會在問題中提供更多細節。 :D:D – LDDM 2013-02-19 14:21:16

回答

0

由於它是在此間表示:

http://www.milbo.users.sonic.net/stasm/minimal.html

你需要調用:

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 

我不知道你是否能調用AsmSearchDll Linux下。

0

由於stasm_dll.hpp定義是包裹着的extern「C」,我認爲你必須在後面做同樣的,當你包括你的stasm.h程序,如:

extern "C" { 
#include "stasm.h" 
} 

本應該得到的調用約定,C/C++的問題右側

+0

感謝您的回答,我嘗試了您的建議,但問題仍然存在。我將嘗試從源代碼中包含STASM-ASM實用程序,因爲在我看來,stasm-asm已經在Windows中使用時編譯和構建。這個想法出現在我的腦海裏,試圖以許多方式包括圖書館,但沒有成功。 在http://stackoverflow.com/questions/13735735/trying-to-get-stasm-to-work-on-ubuntu中的問題作者得出了類似的結論。 – LDDM 2013-02-20 00:48:51

0

如上所述,函數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 

感謝所有爲這些問題回答他們的時間和善意建議的人。