Reputation: 2215
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Features2D;
using Emgu.CV.Structure;
using Emgu.CV.UI;
using Emgu.CV.Util;
using Emgu.CV.GPU;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
Image<Bgr, Byte> modelImage = new Image<Bgr, byte>("box1_Same.png");//child
Image<Bgr, Byte> observedImage = new Image<Bgr, byte>("box2.png");//parent
Image<Bgr, Byte> observedImagae = modelImage.Cmp(observedImage, CMP_TYPE.CV_CMP_GE);
// Image<Bgr, Byte> Difference; //Difference between the two frames
//Difference = modelImage.AbsDiff(observedImage);
}
catch (Exception ex)
{
throw;
}
}
}
}
In above code i used CMP() method for two image comparison "it works if pass two same image for comparison." if pass two different images it gives below exception "OpenCV: src.depth() == dst.depth() && src.size == dst.size" i tried by changing enum CMP_TYPE.CV_CMP_GE but giving same issue
Upvotes: 3
Views: 1492
Reputation: 28950
That error message tells you that you put two images of different size into a function that requires both input images to have the same dimensions.
If you think about what this function does it should make sense. The function compares two images pixel-wise. How do you compare a value vs nothing? That's not defined hence the function does not allow this situation.
The function asserts that this expression is true:
src.depth() == dst.depth() && src.size == dst.size
befor anything else happens. In your case this is false and an exception is thrown in your face.
Upvotes: 1