2010-11-29 6 views
1

Stasm(http://www.milbo.users.sonic.net/stasm/index.html)は、アクティブシェイプモデルの概念を適用して画像上のフィーチャを見つけるためのC++ライブラリです。C#Interp。アクティブシェイプモデルライブラリfor C++

C#プロジェクトでthisのようなstasm DLL(stasm_dll)にあるAsmSearchDllを使用しようとしています。 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 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 

は、私は関数が設定ファイルを読み込むために開始し、この

[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 
    ); 

とC#でこれを使用していますが、それはプログラムを終了しています。私は何が起こっているのか理解できません。助言がありますか?

お礼

+0

この問題を解決できましたか?はいの場合、どのように解決しましたか?同じ問題に直面していて、それは私をナットにしている。 – Syma

+0

私は覚えていない、申し訳ありません。しかし、最初にランドマークとランドマークを割り当てようとする... – jose

答えて

1

私は同じ関数をPythonにバインドしようとして失敗しました。

関数にポインターを渡す前に、まずランドマーク配列とintを割り当ててください。

この機能には../data/に多くの設定ファイルが必要ですが、そこにあることを確認してください。

imagename文字列は、実際にはイメージのFILEPATHである必要があります。冗談なし。それを読み込んで処理します。 Btw、imagedataは割り当てられたメモリを指す必要があります。