正如標題所述:我試圖在Visual C#2010 Professional(試用版)中使用Tamas Szalay的C# port of FFTW ,當我嘗試使用二維變換時出現上述錯誤。 (當我切換到dft_c2r_2d()時,問題依然存在)。其他函數(特別是fftw.malloc())可以正常工作。使用FFTWLib(C#):使用fftw.dft_r2c_2d()崩潰vshost.exe或主程序如果vshost未運行
詳情:
unsafe void FFTFind(IntPtr Scan0, int stride, int width, int height, Rectangle roi)
{
IntPtr ComplexImage = fftw.malloc(width * height * 16);
double[] pComplexImage = new double[width * height * 2];
byte* pScan0 = (byte*)Scan0.ToPointer();
Console.WriteLine("3");
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
pComplexImage[x * y * 2] = pScan0[y * stride + x * 4];
//pComplexImage[x * y * 2] = pScan0[y * stride + x];
}
}
Console.WriteLine("3.05");
Marshal.Copy(pComplexImage, 0, ComplexImage, width * height * 2);
Console.WriteLine("Starting FFTFind");
FFTFindKernel(ComplexImage, stride, width, height, roi);
}
unsafe void FFTFindKernel(IntPtr imageIn, int stride, int width, int height, Rectangle roi)
{
Console.WriteLine("3.1");
IntPtr hScan0 = (IntPtr) GCHandle.Alloc(imageIn, GCHandleType.Pinned);
Console.WriteLine("3.3");
IntPtr FourierPlan;
Console.WriteLine("3.5");
int start = System.Environment.TickCount;
Console.WriteLine("3.7");
FourierPlan = fftw.dft_r2c_2d(width, height, hScan0, hScan0, 0);
Console.WriteLine("4");
fftw.execute(FourierPlan);
Console.WriteLine("Time: {0} ms", (System.Environment.TickCount - start));
}
控制檯最多可打印 「3.7」。試圖運行FourierPlan = ...
導致程序崩潰和消息框彈出:
vshost.exe has stopped working.
禁用的Visual Studio宿主進程只替換「vshost.exe」與「FFTFind」。
可能相關:我在x64環境(Windows Server Standard)中運行此操作,但dll和程序是x86。這previously caused a problem in Visual C# 2010 Express,這是通過切換到專業試用版,然後手動將配置目標從「x86」更改爲「任何CPU」解決。
更新:運行提供的測試代碼工作正常。
看來你已經發現了一個錯誤,無論是你的本地方法,還是你已經擊中了本地代碼中的錯誤。你沒有發佈,所以我們如何幫助? – 2012-02-08 04:29:36
我也沒有寫 - 代碼鏈接在帖子中,Tamas Szaley的C#端口。如果您認爲合適,我會發送一封關於它的電子郵件,但由於這是時間敏感的,我會很感激幫助。 – linkhyrule5 2012-02-08 04:43:02
(哦,Szaley發表了他的消息來源,對使用情況沒有限制,所以如果你願意去那麼遠有這樣的選擇,恐怕我對圖書館知道要複製什麼不是很熟悉,但如果你給我的指示,我可以盲目地按照指示。) – linkhyrule5 2012-02-08 04:44:37