Major Problem....This code consistently generates an unbalanced stack error. I have even tried to change the Wrapper class argument to an IntPtr and that does not work....I am stumped....the "suggestion" is that my parameters do not match the number of arguments expected by the dll. Anyone used this wrapper class before? Any Problems?
dll is from http://www.fftw.org
wrapper class is from http://www.sdss.jhu.edu/~tamas/bytes/fftwcsharp.html
ANSI C base function in the dll is:
void *fftwf_malloc(size_t n);
Wrapper Implementation for PInvoke is:
IntPtr malloc(int length); //in a wrapper class called fftw
My code simply calls:
fftw.malloc(1000); //hardcoded test to see why this is failing...
fftw.malloc(FFTSampleSize*sizeof(float)*2); //where FFTSampleSize is a int
Sam HobbsPosted Feb 3, 2011, 9:00 PM
Michael LammingPosted Feb 3, 2011, 5:27 PM
Chris FoleyPosted Dec 16, 2010, 12:27 PM
Sam HobbsPosted Dec 16, 2010, 11:51 AM
Chris FoleyPosted Dec 16, 2010, 9:18 AM
Sam HobbsPosted Dec 15, 2010, 11:32 PM
Sam HobbsPosted Dec 15, 2010, 11:26 PM
The malloc function is part of C/C++. You can find the "signature" in the headers; it is: Using that, it is clear that calling convention is cdecl.
I doubt however that you you need to use malloc; the .Net Interop probably have safer ways to do what you need to do.
Jim TallentPosted Dec 15, 2010, 2:37 PM
I was also able to get a clean compile and have been running the FFTs. However my FFT results are questionable. I can send you what I have if you plan to get back on the project. Maybe between the two of us we can resolve issues. One of my questions is regarding the data input and output requirements since I am using the fftw_complexarray.
Maybe you can tell me this:
When I input my real data to the fftw_complexarray, as per my understanding, the data must be formatted as alternating real and imaginary parts. So, if I have an an array of 4 real numbers the input to the fftw_complexarray must be of size 8 and the data copied to the fftw_complexarray needs to look like: real_1,Imag_1, real_2,Imag_2, real_3,Imag_3, real_4,Imag_4. Where all Imaginary data is initially set to "0".
Following the FFT execution I perform addition calculations on the FFT output, and likewise my understanding is that the FFT output data is formatted in the array as: real_1,Imag_1, real_2,Imag_2, real_3,Imag_3, real_4,Imag_4, ...
I am trying to execute a Phase_Correlation on two 1-D real data arrays using the example provided at:
http://nashruddin.com/phase-correlation-function-in-opencv.html
Once successful I'll go for the 2-D array (two images).
Thanks
James
Chris FoleyPosted Dec 15, 2010, 8:24 AM
Jim TallentPosted Dec 14, 2010, 11:05 PM
I'm been working down the same path over the past two weeks trying to use the following:
I am hopping you can help me with a few issues I'm having in implementing this class/wrapper successfully as there is not much info I can find. If so, I will post my question here.
Thanks
Jim
Chris FoleyPosted Sep 15, 2010, 12:57 PM
Bechir BejaouiPosted Sep 15, 2010, 12:42 PM
What do you mean by the calling convention change Chris
Chris FoleyPosted Sep 15, 2010, 11:47 AM
krishna vPosted Sep 14, 2010, 2:11 AM
I remember size_t is typedef for unsinged int
IntPtr malloc(uint16 length);
IntPtr malloc(uint32 length);
Bechir BejaouiPosted Sep 13, 2010, 3:16 PM
Chris FoleyPosted Sep 13, 2010, 3:03 PM
Bechir BejaouiPosted Sep 13, 2010, 12:09 PM
Chris FoleyPosted Sep 13, 2010, 12:00 PM
Bechir BejaouiPosted Sep 13, 2010, 11:37 AM
Or this one
Chris FoleyPosted Sep 13, 2010, 10:58 AM
Bechir BejaouiPosted Sep 13, 2010, 10:46 AM
I remember I have read a good artile for simila issue, I thing this one
http://msdn.microsoft.com/en-us/magazine/cc163606.aspx
Meanwhile, I give you and alternative solution, if you have the unmanaged library then you could wrap up it and use it, I invite you to take a look on my articles in this context
http://www.c-sharpcorner.com/UploadFile/yougerthen/510262008060749AM/5.aspx?ArticleID=d2da1ab3-b92d-499d-94cd-bf54d91e14c3
Chris FoleyPosted Sep 13, 2010, 10:24 AM
Bechir BejaouiPosted Sep 13, 2010, 10:20 AM
Chris FoleyPosted Sep 13, 2010, 10:04 AM
Bechir BejaouiPosted Sep 13, 2010, 9:49 AM
Chris FoleyPosted Sep 13, 2010, 9:26 AM
Bechir BejaouiPosted Sep 10, 2010, 2:12 PM
Are you using 3.5 or 4.0, because the 4.0 resolves you problem by using optional parameters