I have this exception:
Emgu.CV.Util.CvException: OpenCV: layer_rows - 2 * min_margin > 0
Here is my sample code:
static void SampleFunction()
{
string model = @"sample model image location";
string observed = @"sample observed image location";
Emgu.CV.Image<Emgu.CV.Structure.Gray, byte> modelImage = new Emgu.CV.Image<Emgu.CV.Structure.Gray, byte>(model);
Emgu.CV.Image<Emgu.CV.Structure.Gray, byte> observedImage = new Emgu.CV.Image<Emgu.CV.Structure.Gray, byte>(observed);
Custom.CustomSLAM slam = new Custom.CustomSLAM();
Emgu.CV.Mat drawImage = slam.FindMatches(modelImage, observedImage);
drawImage.Save("D:\\test.png");
}
with Custom.CustomSLAM is a class that use SURF feature detector class from EmguCV example The program is running normal for the first time try. The problem happen with second try
Here is the detail:
Emgu.CV.Util.CvException
HResult=0x80131500
Message=OpenCV: layer_rows - 2 * min_margin > 0
Source=Emgu.CV.World
StackTrace:
at Emgu.CV.CvInvoke.CvErrorHandler(Int32 status, IntPtr funcName, IntPtr errMsg, IntPtr fileName, Int32 line, IntPtr userData)
at Emgu.CV.Features2D.Feature2DInvoke.CvFeature2DDetectAndCompute(IntPtr feature2D, IntPtr image, IntPtr mask, IntPtr keypoints, IntPtr descriptors, Boolean useProvidedKeyPoints)
at Emgu.CV.Features2D.Feature2D.DetectAndCompute(IInputArray image, IInputArray mask, VectorOfKeyPoint keyPoints, IOutputArray descriptors, Boolean useProvidedKeyPoints)
at SURFFeature.DrawMatches.FindMatch(Mat modelImage, Mat observedImage, Int64& matchTime, VectorOfKeyPoint& modelKeyPoints, VectorOfKeyPoint& observedKeyPoints, VectorOfVectorOfDMatch matches, Mat& mask, Mat& homography) in C:\Users\TheUser\source\repos\SURFDetector\SURFDetector\SURFFeature.cs:line 82
at SURFFeature.DrawMatches.Draw(Mat modelImage, Mat observedImage, Int64& matchTime) in C:\Users\TheUser\source\repos\SURFDetector\SURFDetector\SURFFeature.cs:line 128
at Tracker_CameraTrackerModule.Custom.CustomSLAM.FindMatches(Image`2 modelImage, Image`2 observedImage) in C:\Users\TheUser\source\repos\Tracker_CameraTrackerModule\Tracker_CameraTrackerModule\Custom\CustomSLAM.cs:line 115
at Tracker_CameraTrackerModule.Program.SampleFunction() in C:\Users\TheUser\source\repos\Tracker_CameraTrackerModule\Tracker_CameraTrackerModule\Program.cs:line 92
at Tracker_CameraTrackerModule.Program.Main(String[] args) in C:\Users\TheUser\source\repos\Tracker_CameraTrackerModule\Tracker_CameraTrackerModule\Program.cs:line 74
How to solve it?
After looking for answers, i decided to replace
surfCPU.DetectAndCompute(uModelImage, null, modelKeyPoints, modelDescriptors, false);
// Also with the observed image
With
// The same for observed image
surfCPU.DetectRaw(modelImage, modelKeyPoints);
surfCPU.Compute(modelImage, modelKeyPoints, modelDescriptors);
And work.
User contributions licensed under CC BY-SA 3.0