Reputation: 16908
The following code doesn't compile in EmguCV 3.4.1.
Image<Gray, float> image = new Image<Gray, float>(path);
IntPtr complexImage = CvInvoke.cvCreateImage(image.Size,
Emgu.CV.CvEnum.IplDepth.IplDepth32F, 2);
CvInvoke.cvSetZero(complexImage); // Initialize all elements to Zero
CvInvoke.cvSetImageCOI(complexImage, 1);
CvInvoke.cvCopy(image, complexImage, IntPtr.Zero);
CvInvoke.cvSetImageCOI(complexImage, 0);
Matrix<float> dft = new Matrix<float>(image.Rows, image.Cols, 2);
CvInvoke.cvDFT(complexImage, dft, Emgu.CV.CvEnum.DxtType.Forward, 0);
//The Real part of the Fourier Transform
Matrix<float> outReal = new Matrix<float>(image.Size);
//The imaginary part of the Fourier Transform
Matrix<float> outIm = new Matrix<float>(image.Size);
CvInvoke.cvSplit(dft, outReal, outIm, IntPtr.Zero, IntPtr.Zero);
//Show The Data
CvInvoke.cvShowImage("Real", outReal);
CvInvoke.cvShowImage("Imaginary ", outIm);
Some functions
cvSetZero()
cvDFT()
cvShowImage()
are not available in this version of EmguCV.
How can I get around this issue?
Upvotes: 1
Views: 1665
Reputation: 928
Since version 3.0 EmguCV goes more for Mat instead of Image. Also somemethods were moved from CvInvoke to Mat or Image or were renamed (example: CvInvoke.cvShowImage --> CvInvoke.Imshow).
I also had this problem with dft and tried to port the code from the openCV example to c#. This is what I work with (using EmguCV 3.4.1):
var image = new Mat(path, ImreadModes.Grayscale);
int a = CvInvoke.GetOptimalDFTSize(image.Rows);
int b = CvInvoke.GetOptimalDFTSize(image.Cols);
var extended = new Mat();
CvInvoke.CopyMakeBorder(image, extended, 0, a - image.Rows, 0, b - image.Cols, BorderType.Constant, new MCvScalar(0));
extended.ConvertTo(extended, DepthType.Cv32F);
var vec = new VectorOfMat(extended, new Mat(extended.Size, DepthType.Cv32F, 1));
var complex = new Mat();
CvInvoke.Merge(vec, complex);
CvInvoke.Dft(complex, complex, DxtType.Forward, 0);
CvInvoke.Split(complex, vec);
vec[0].ConvertTo(vec[0], DepthType.Cv8U);
vec[1].ConvertTo(vec[1], DepthType.Cv8U);
CvInvoke.Imshow("Real", vec[0]);
CvInvoke.Imshow("Img", vec[1]);
Upvotes: 3
Reputation: 51904
Some methods have been renamed or moved. Use CvInvoke.Dft
with Image.toUMat
and UMat
for the image manipulation. ImageViewer
can be used for displaying images.
Image<Gray, float> image = new Image<Gray, float>(path);
UMat dftImage = new UMat(image.Size, Emgu.CV.CvEnum.DepthType.Cv32F, 2);
CvInvoke.Dft(image, dftImage, Emgu.CV.CvEnum.DxtType.Forward, image.Rows);
Upvotes: 2