本文整理汇总了C#中OpenCvSharp.IplImage.Get2D方法的典型用法代码示例。如果您正苦于以下问题:C# IplImage.Get2D方法的具体用法?C# IplImage.Get2D怎么用?C# IplImage.Get2D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCvSharp.IplImage
的用法示例。
在下文中一共展示了IplImage.Get2D方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Watershed
public Watershed()
{
// cvWatershed
// マウスで円形のマーカー(シード領域)の中心を指定し,複数のマーカーを設定する.
// このマーカを画像のgradientに沿って広げて行き,gradientの高い部分に出来る境界を元に領域を分割する.
// 領域は,最初に指定したマーカーの数に分割される.
// (2)画像の読み込み,マーカー画像の初期化,結果表示用画像領域の確保を行なう
using (IplImage srcImg = new IplImage(Const.ImageGoryokaku, LoadMode.AnyDepth | LoadMode.AnyColor))
using (IplImage dstImg = srcImg.Clone())
using (IplImage dspImg = srcImg.Clone())
using (IplImage markers = new IplImage(srcImg.Size, BitDepth.S32, 1))
{
markers.Zero();
// (3)入力画像を表示しシードコンポーネント指定のためのマウスイベントを登録する
using (CvWindow wImage = new CvWindow("image", WindowMode.AutoSize))
{
wImage.Image = srcImg;
// クリックにより中心を指定し,円形のシード領域を設定する
int seedNum = 0;
wImage.OnMouseCallback += delegate(MouseEvent ev, int x, int y, MouseEvent flags)
{
if (ev == MouseEvent.LButtonDown)
{
seedNum++;
CvPoint pt = new CvPoint(x, y);
markers.Circle(pt, 20, CvScalar.ScalarAll(seedNum), Cv.FILLED, LineType.Link8, 0);
dspImg.Circle(pt, 20, CvColor.White, 3, LineType.Link8, 0);
wImage.Image = dspImg;
}
};
CvWindow.WaitKey();
}
// (4)watershed分割を実行する
Cv.Watershed(srcImg, markers);
// (5)実行結果の画像中のwatershed境界(ピクセル値=-1)を結果表示用画像上に表示する
for (int i = 0; i < markers.Height; i++)
{
for (int j = 0; j < markers.Width; j++)
{
int idx = (int)(markers.Get2D(i, j).Val0);
if (idx == -1)
{
dstImg.Set2D(i, j, CvColor.Red);
}
}
}
using (CvWindow wDst = new CvWindow("watershed transform", WindowMode.AutoSize))
{
wDst.Image = dstImg;
CvWindow.WaitKey();
}
}
}
示例2: Watershed
public Watershed()
{
using (var srcImg = new IplImage(FilePath.Image.Goryokaku, LoadMode.AnyDepth | LoadMode.AnyColor))
using (var dstImg = srcImg.Clone())
using (var dspImg = srcImg.Clone())
using (var markers = new IplImage(srcImg.Size, BitDepth.S32, 1))
{
markers.Zero();
using (var window = new CvWindow("image", WindowMode.AutoSize))
{
window.Image = srcImg;
// Mouse event
int seedNum = 0;
window.OnMouseCallback += delegate(MouseEvent ev, int x, int y, MouseEvent flags)
{
if (ev == MouseEvent.LButtonDown)
{
seedNum++;
CvPoint pt = new CvPoint(x, y);
markers.Circle(pt, 20, CvScalar.ScalarAll(seedNum), Cv.FILLED, LineType.Link8, 0);
dspImg.Circle(pt, 20, CvColor.White, 3, LineType.Link8, 0);
window.Image = dspImg;
}
};
CvWindow.WaitKey();
}
Cv.Watershed(srcImg, markers);
// draws watershed
for (int i = 0; i < markers.Height; i++)
{
for (int j = 0; j < markers.Width; j++)
{
int idx = (int)(markers.Get2D(i, j).Val0);
if (idx == -1)
{
dstImg.Set2D(i, j, CvColor.Red);
}
}
}
using (CvWindow wDst = new CvWindow("watershed transform", WindowMode.AutoSize))
{
wDst.Image = dstImg;
CvWindow.WaitKey();
}
}
}
示例3: StartFishing
private bool StartFishing()
{
iNumTries++;
if (!bRumsy)
{
SendKeys.SendWait("0");
rumsyTimer.AutoReset = true;
rumsyTimer.Interval = 3 * 60 * 1000; // 3 minutes rumsy label
rumsyTimer.Elapsed += new ElapsedEventHandler(OnRumsyEndTimerEvent);
rumsyTimer.Enabled = true;
bRumsy = true;
}
if (!bLurk)
{
SendKeys.SendWait(this.txtLurk.Text);
lurkTimer.AutoReset = true;
lurkTimer.Interval = 10*60*1000; // 10 minutes best lurk
lurkTimer.Elapsed += new ElapsedEventHandler(OnLurkEndTimerEvent);
lurkTimer.Enabled = true;
bLurk = true;
Thread.Sleep(2500);
}
Thread.Sleep(1000);
Bitmap b4Fishing = ScreenShot.CaptureImage(new Point(this.Left, this.Top), new Point(0,0), new Rectangle(this.Top, this.Left, this.Width, this.Height));
SendKeys.SendWait(this.txtKey.Text);
Thread.Sleep(400);
aTimer.AutoReset = true;
aTimer.Interval = 20000;
aTimer.Elapsed += new ElapsedEventHandler(OnFishingTimerFinishEvent);
aTimer.Enabled = true;
Thread.Sleep(2000);
Bitmap onFishing = ScreenShot.CaptureImage(new Point(this.Left, this.Top), new Point(0, 0), new Rectangle(this.Top, this.Left, this.Width, this.Height));
IplImage i1 = FeatureDetector(b4Fishing);
IplImage i2 = FeatureDetector(onFishing);
IplImage diff = new IplImage(new OpenCvSharp.CvSize(i1.Size.Width, i1.Size.Height), BitDepth.U8, 1);
IplImage normalized = new IplImage(new OpenCvSharp.CvSize(diff.Size.Width, diff.Size.Height), BitDepth.U8, 1);
OpenCvSharp.Cv.AbsDiff((CvArr)i2, (CvArr)i1, (CvArr)diff);
//OpenCvSharp.Cv.CvtColor(diff, gray, ColorConversion.RgbToGray);
OpenCvSharp.Cv.Normalize(diff, normalized, 0.0, 255.0, NormType.MinMax);
bool bEnd = false;
bool bFound = false;
on_cursor = true;
for (int i = 0; i < normalized.Height; ++i)
{
if (!on_cursor)
break;
for (int j = 0; j < normalized.Width; ++j)
{
if (!on_cursor)
break;
CvScalar color = normalized.Get2D(i, j);
if (color.Val0 > 50)
{
Cursor.Position = new Point(this.Left + j, this.Top + i);
//Thread.Sleep(100);
if (TestCursor())
{
bEnd = true;
bFound = true;
break;
}
}
}
if (bEnd)
break;
}
on_cursor = false;
Bitmap bDiff = BitmapConverter.ToBitmap(i2);
//b4Fishing.Save("C:\\cursors\\b4fish.jpg", ImageFormat.Jpeg);
//onFishing.Save("C:\\cursors\\onfish.jpg", ImageFormat.Jpeg);
//bDiff.Save("C:\\cursors\\diff.jpg", ImageFormat.Jpeg);
//.........这里部分代码省略.........
示例4: CheckFlagHelper2
private bool CheckFlagHelper2(IplImage img, int x, int y)
{
CvScalar tmp = img.Get2D(x, y);
return 240 < tmp.Val0 &&
240 < tmp.Val1 &&
240 < tmp.Val2;
}
示例5: Check7
private bool Check7(IplImage img)
{
int x = 9;
for (int y = 1; y < 10; y++)
{
if (Check7Helper(img.Get2D(x, y)))
{
int len = 0;
int xbuf = x;
// xの左端を探す
try
{
while (!Check7Helper(img.Get2D(--x, y))) { len++; }
len++;
x = xbuf;
while (!Check7Helper(img.Get2D(++x, y))) { len++; }
len++;
return len == 7;
}
catch (Exception e)
{
return false;
}
}
}
return false;
}
示例6: Check6
private bool Check6(IplImage img)
{
CvScalar tmp0 = img.Get2D(11, 6);
CvScalar tmp1 = img.Get2D(11, 7);
return (90 < tmp0.Val0 && tmp0.Val0 < 144 &&
90 < tmp0.Val1 && tmp0.Val1 < 144 &&
tmp0.Val2 < 10) ||
(90 < tmp1.Val0 && tmp1.Val0 < 144 &&
90 < tmp1.Val1 && tmp1.Val1 < 144 &&
tmp1.Val2 < 10);
}
示例7: Check5
private bool Check5(IplImage img)
{
for (int y = 4; y < 8; y++)
{
for (int x = 3; x < 9; x++)
{
CvScalar tmp0 = img.Get2D(x, y);
if (tmp0.Val0 < 10 &&
tmp0.Val1 < 10 &&
120 < tmp0.Val2 && tmp0.Val2 < 130)
{
return true;
}
}
}
return false;
}
示例8: Check4
private bool Check4(IplImage img)
{
CvScalar tmp0 = img.Get2D(10, 10);
CvScalar tmp1 = img.Get2D(11, 11);
return (tmp0.Val0 > 100 && tmp0.Val1 < 10 && tmp0.Val2 < 10)
|| (tmp1.Val0 > 100 && tmp1.Val1 < 10 && tmp1.Val2 < 10);
}
示例9: Check3
private bool Check3(IplImage img)
{
CvScalar tmp = img.Get2D(8, 8);
CvScalar tmp2 = img.Get2D(9, 9);
return (tmp.Val0 < 20 &&
tmp.Val1 < 20 &&
tmp.Val2 > 150) ||
(tmp2.Val0 < 20 &&
tmp2.Val1 < 20 &&
tmp2.Val2 > 150);
}
示例10: Check2
private bool Check2(IplImage img)
{
CvScalar tmp = img.Get2D(7, 12);
return (tmp.Val0 < 50 && tmp.Val1 > 50 && tmp.Val2 < 60);
}
示例11: Check1
private bool Check1(IplImage img)
{
return img.Get2D(8, 9) == new CvScalar(190, 80, 64, 255);
}