本文整理汇总了C#中Emgu.CV.Mat.GetData方法的典型用法代码示例。如果您正苦于以下问题:C# Mat.GetData方法的具体用法?C# Mat.GetData怎么用?C# Mat.GetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Emgu.CV.Mat
的用法示例。
在下文中一共展示了Mat.GetData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Canny
public static byte[] Canny(IntPtr buffer, int width, int height, bool smooth = false)
{
unsafe
{
Mat source = new Mat(height, width, DepthType.Cv8U, 1, buffer, width);
Mat blurred = new Mat(height, width, DepthType.Cv8U, 1);
if (smooth) {
CvInvoke.Blur(source, blurred, new Size(3, 3), new Point(-1, -1));
}
Mat cannyEdges = new Mat(height, width, DepthType.Cv8U, 1);
double cannyThreshold = 180.0;
double cannyThresholdLinking = 60.0;
CvInvoke.Canny(smooth ? blurred : source, cannyEdges, cannyThreshold, cannyThresholdLinking);
return cannyEdges.GetData();
}
}
示例2: transformColor
//.........这里部分代码省略.........
t2.X += tweak2.X;
t2.Y += tweak2.Y;
//optimal_h = 1000;
//optimal_w = 1000;
dst = new Mat(optimal_h, optimal_w,DepthType.Cv8U,3);
dst_mask = new Mat(optimal_h, optimal_w,DepthType.Cv8U,3);
if (mode)
{
dst.SetTo(new MCvScalar(255, 255, 255)); // white background=255, black background=0
}
else
{
dst.SetTo(new MCvScalar(0, 0, 0)); // white background=255, black background=0
}
dst_mask.SetTo(new MCvScalar(0, 0, 0));
/*if (BKG_WHITE)
cvSet(dst, cvScalar(255));//make it white
else
cvSet(dst, cvScalar(0));//make it black*/
for (int i = 0; i < img1.Height; ++i)
{
for (int j = 0; j < img1.Width; ++j)
{
// if black background
if (mode)
{
if (mask1.GetData(i, j)[0] != 255)
{
int i_new = i + t1.Y;
int j_new = j + t1.X;
try
{
dst.SetValue(i_new, j_new, img1.GetData(i, j));
int[] vals = { 255, 255, 255 };
dst_mask.SetValue(i_new, j_new, vals);
}
catch(IndexOutOfRangeException e)
{
//MessageBox.Show("You cannot tweak in that direction further");
success = false;
goto ret;
}
}
}
// if white background
else
{
if (mask1.GetData(i, j) [0] != 0)
{
int i_new = i + t1.Y;
int j_new = j + t1.X;
try
{
dst.SetValue(i_new, j_new, img1.GetData(i, j));
int[] vals = { 0, 0, 0 };
dst_mask.SetValue(i_new, j_new, vals);