C# Interp. for Active Shape Models library in C++
Stasm (http://www.milbo.users.sonic.net/stasm/index.html) is a C++ library for finding features on image, applying the concept of active shape models.
I am trying to use AsmSearchDll which is on stasm DLL (stasm_dll) like this on a C# project. In C++ the prototype is
void AsmSearchDll(
int *pnlandmarks, // out: number of landmarks, 0 if can't get landmarks
int landma开发者_JAVA技巧rks[], // 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 if grayscale
const char conf_file0[], // in: 1st config filename, NULL for default
const char conf_file1[]); // in: 2nd config filename, NULL for default, "" for none
I am using this in C# with this
[DllImport(@"..\data\stasm_dll.dll")]
public static extern void AsmSearchDll(
out int pnlandmarks, // out: number of landmarks, 0 if can't get landmarks
out int[] landmarks, // out: the landmarks, caller must allocate
[MarshalAs(UnmanagedType.LPStr)]string imagename, // in: used in internal error messages, if necessary
byte[] imagedata, // in: image data, 3 bytes per pixel if is_color
int width, // in: the width of the image
int height, // in: the height of the image
int is_color, // in: 1 if RGB image, 0 if grayscale
[MarshalAs(UnmanagedType.LPStr)]string conf_file0, // in: 1st config filename, NULL for default
[MarshalAs(UnmanagedType.LPStr)]string conf_file1 // in: 2nd config filename, NULL for default, "" for none
);
The function starts to read the config files, but then it quits the program. I can't figure out what is going on. Any suggestions?
Best regards
I tried to bind the same function to python unsuccessfully.
You have first to allocate the landmarks array and an int, before passing pointer to the function.
The function need a lot of configuration file in ../data/, be sure it is there.
The imagename string should actually be the FILEPATH of the image. No kidding. It loads it and process it whatever. Btw, imagedata must point to allocated memory to...
精彩评论