对于我的回答,我假设您要检测的其他部分将具有与给出的示例部分相同的精确白色轮廓。我只是用emgucv中的find contours方法得到了拼图的轮廓。
//Read in the image
Mat puzzlePiece = CvInvoke.Imread("Puzzle\Piece\path", ImreadModes.AnyColor);
//Create a grayscale version of the image
Mat puzzlePieceGray = new Mat();
CvInvoke.CvtColor(puzzlePiece, puzzlePieceGray, ColorConversion.Bgr2Gray);
//Black image to draw contours on
Image<Bgr, byte> output = new Image<Bgr, byte>(puzzlePiece.Width, puzzlePiece.Height,
new Bgr(Color.Black));
VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();
//Find and draw the found contours
CvInvoke.FindContours(puzzlePieceGray, contours, null, RetrType.External,
ChainApproxMethod.ChainApproxSimple);
CvInvoke.DrawContours(output, contours, -1, new MCvScalar(255, 0, 0));
//Display the found contours
CvInvoke.Imshow("Contours Drawn", output);
CvInvoke.WaitKey(0);
原图
带有轮廓的图像
由于只有您提供的输入图像,我无法将轮廓的大小与其他部分进行比较,但这里有一些示例代码,说明它是如何工作的。
if (contours[0].Size == contoursTwo[0].Size)
{
//do stuff
}