本文整理汇总了C#中Window.ShowImage方法的典型用法代码示例。如果您正苦于以下问题:C# Window.ShowImage方法的具体用法?C# Window.ShowImage怎么用?C# Window.ShowImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Window
的用法示例。
在下文中一共展示了Window.ShowImage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FileStorageTest
private static void FileStorageTest()
{
const string fileName = "foo.yml";
try
{
using (var fs = new FileStorage(fileName, FileStorage.Mode.Write | FileStorage.Mode.FormatYaml))
{
fs.Write("int", 123);
fs.Write("double", Math.PI);
using (var tempMat = new Mat("data/lenna.png"))
{
fs.Write("mat", tempMat);
}
}
using (var fs = new FileStorage(fileName, FileStorage.Mode.Read))
{
Console.WriteLine("int: {0}", fs["int"].ReadInt());
Console.WriteLine("double: {0}", (double) fs["double"]);
using (var window = new Window("mat"))
{
window.ShowImage(fs["mat"].ReadMat());
Cv2.WaitKey();
}
}
}
finally
{
File.Delete(fileName);
}
}
示例2: Run
public void Run()
{
var capture = new VideoCapture();
capture.Set(CaptureProperty.FrameWidth, 640);
capture.Set(CaptureProperty.FrameHeight, 480);
capture.Open(-1);
if (!capture.IsOpened())
throw new Exception("capture initialization failed");
var fs = FrameSource.CreateCameraSource(-1);
var sr = SuperResolution.CreateBTVL1();
sr.SetInput(fs);
using (var normalWindow = new Window("normal"))
using (var srWindow = new Window("super resolution"))
{
var normalFrame = new Mat();
var srFrame = new Mat();
while (true)
{
capture.Read(normalFrame);
sr.NextFrame(srFrame);
if (normalFrame.Empty() || srFrame.Empty())
break;
normalWindow.ShowImage(normalFrame);
srWindow.ShowImage(srFrame);
Cv2.WaitKey(100);
}
}
}
示例3: VideoCaptureSample
private static void VideoCaptureSample()
{
var cap = new VideoCapture(0);
if (!cap.IsOpened())
{
Console.WriteLine("Can't use camera.");
return;
}
var frame = new Mat();
cap.Grab();
NativeMethods.videoio_VideoCapture_operatorRightShift_Mat(cap.CvPtr, frame.CvPtr);
Window.ShowImages(frame);
using (var window = new Window("window"))
{
while (true)
{
cap.Read(frame);
window.ShowImage(frame);
int key = Cv2.WaitKey(50);
if (key == 'b')
break;
}
}
}
示例4: VideoCaptureSample
private static void VideoCaptureSample()
{
var cap = new VideoCapture(0);
if (!cap.IsOpened())
{
Console.WriteLine("Can't use camera.");
return;
}
var frame = new Mat();
using (var window = new Window("window"))
{
while (true)
{
cap.Read(frame);
window.ShowImage(frame);
int key = Cv2.WaitKey(50);
if (key == 'b')
break;
}
}
}
示例5: Run
public void Run()
{
const string OutVideoFile = "out.avi";
// Opens MP4 file (ffmpeg is probably needed)
VideoCapture capture = new VideoCapture(FilePath.Bach);
// Read movie frames and write them to VideoWriter
Size dsize = new Size(640, 480);
using (VideoWriter writer = new VideoWriter(OutVideoFile, -1, capture.Fps, dsize))
{
Console.WriteLine("Converting each movie frames...");
Mat frame = new Mat();
while(true)
{
// Read image
capture.Read(frame);
if(frame.Empty())
break;
Console.CursorLeft = 0;
Console.Write("{0} / {1}", capture.PosFrames, capture.FrameCount);
// grayscale -> canny -> resize
Mat gray = new Mat();
Mat canny = new Mat();
Mat dst = new Mat();
Cv2.CvtColor(frame, gray, ColorConversion.BgrToGray);
Cv2.Canny(gray, canny, 100, 180);
Cv2.Resize(canny, dst, dsize, 0, 0, Interpolation.Linear);
// Write mat to VideoWriter
writer.Write(dst);
}
Console.WriteLine();
}
// Watch result movie
using (VideoCapture capture2 = new VideoCapture(OutVideoFile))
using (Window window = new Window("result"))
{
int sleepTime = (int)(1000 / capture.Fps);
Mat frame = new Mat();
while (true)
{
capture2.Read(frame);
if(frame.Empty())
break;
window.ShowImage(frame);
Cv2.WaitKey(sleepTime);
}
}
}
示例6: Run
public void Run()
{
// Opens MP4 file (ffmpeg is probably needed)
VideoCapture capture = new VideoCapture(FilePath.Movie.Bach);
int sleepTime = (int)Math.Round(1000 / capture.Fps);
using (Window window = new Window("capture"))
{
// Frame image buffer
Mat image = new Mat();
// When the movie playback reaches end, Mat.data becomes NULL.
while (true)
{
capture.Read(image); // same as cvQueryFrame
if(image.Empty())
break;
window.ShowImage(image);
Cv2.WaitKey(sleepTime);
}
}
}