我正在研究一個圖像處理工程,我需要找到並標記一些人臉屬性(即:嘴巴,鼻子,眼睛等)。我試圖使用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
我不明白問題在哪裏。
最好的問候,
路易斯
您有一個數組作爲頭文件中的第二個參數,並在指針上使用它。還有其他類型的不匹配。如果這是C++,肯定可以抱怨,因爲...或者可能是因爲函數被定義爲_C_,並且在包含頭部時被理解爲_C++ _。 – vonbrand 2013-02-15 02:08:35
@vonbrand謝謝你的時間和答案。我認爲問題不是類型不匹配,我會在問題中提供更多細節。 :D:D – LDDM 2013-02-19 14:21:16