本文整理匯總了C#中OpenCvSharp.Mat.EmptyClone方法的典型用法代碼示例。如果您正苦於以下問題:C# Mat.EmptyClone方法的具體用法?C# Mat.EmptyClone怎麽用?C# Mat.EmptyClone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OpenCvSharp.Mat
的用法示例。
在下文中一共展示了Mat.EmptyClone方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Run
public void Run()
{
Mat src = new Mat("Data/Image/shapes.png", ImreadModes.Color);
Mat gray = src.CvtColor(ColorConversionCodes.BGR2GRAY);
Mat binary = gray.Threshold(0, 255, ThresholdTypes.Otsu | ThresholdTypes.Binary);
Mat labelView = src.EmptyClone();
Mat rectView = binary.CvtColor(ColorConversionCodes.GRAY2BGR);
ConnectedComponents cc = Cv2.ConnectedComponentsEx(binary);
if (cc.LabelCount <= 1)
return;
// draw labels
cc.RenderBlobs(labelView);
// draw bonding boxes except background
foreach (var blob in cc.Blobs.Skip(1))
{
rectView.Rectangle(blob.Rect, Scalar.Red);
}
// filter maximum blob
var maxBlob = cc.GetLargestBlob();
var filtered = new Mat();
cc.FilterByBlob(src, filtered, maxBlob);
using (new Window("src", src))
using (new Window("binary", binary))
using (new Window("labels", labelView))
using (new Window("bonding boxes", rectView))
using (new Window("maximum blob", filtered))
{
Cv2.WaitKey();
}
}