Using FFTWLib (C #): using fftw.dft_r2c_2d () causes vshost.exe or the main program to crash if vshost is not running

As the title says: I'm trying to use Tamas Szalay C # port for FFTW in Visual C # 2010 Professional (Trial) and I get the above error when I try to use two-dimensional conversion. (The problem occurs when switching to dft_c2r_2d ()). Other functions (specifically fftw.malloc ()) work fine.

More details:

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

The console prints to "3.7." Attempting to start FourierPlan = ... causes the program to crash and a message box appears:

 vshost.exe has stopped working. 

Disabling the Visual Studio host process only replaces “vshost.exe” with “FFTFind”.

Perhaps this is relevant: I run this in x64 (Windows Server Standard), but the DLL and programs are x86. This previously caused a problem in Visual C # 2010 Express , which was resolved by switching to a professional trial version, and then manually changing the configuration target from "x86" to "Any processor." "

UPDATE: Executing the provided test code works fine.

+4
source share
1 answer

As it turned out, plan functions cannot accept dummy pointers — the arrays they point to must be initialized. Looking back, it should have been obvious ...

0
source

Source: https://habr.com/ru/post/1395351/


All Articles