本文整理汇总了C#中OpenCvSharp.IplImage.SaveImage方法的典型用法代码示例。如果您正苦于以下问题:C# IplImage.SaveImage方法的具体用法?C# IplImage.SaveImage怎么用?C# IplImage.SaveImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCvSharp.IplImage
的用法示例。
在下文中一共展示了IplImage.SaveImage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveImage
public SaveImage()
{
using (IplImage img = new IplImage(Const.Image16bit, LoadMode.Color))
{
// JPEG quality test
img.SaveImage("q000.jpg", new JpegEncodingParam(0));
img.SaveImage("q025.jpg", new JpegEncodingParam(25));
img.SaveImage("q050.jpg", new JpegEncodingParam(50));
img.SaveImage("q075.jpg", new JpegEncodingParam(75));
img.SaveImage("q100.jpg", new JpegEncodingParam(100));
using (IplImage q000 = new IplImage("q000.jpg", LoadMode.Color))
using (IplImage q025 = new IplImage("q025.jpg", LoadMode.Color))
using (IplImage q050 = new IplImage("q050.jpg", LoadMode.Color))
using (IplImage q075 = new IplImage("q075.jpg", LoadMode.Color))
using (IplImage q100 = new IplImage("q100.jpg", LoadMode.Color))
using (CvWindow w000 = new CvWindow("quality 0", q000))
using (CvWindow w025 = new CvWindow("quality 25", q025))
using (CvWindow w050 = new CvWindow("quality 50", q050))
using (CvWindow w075 = new CvWindow("quality 75", q075))
using (CvWindow w100 = new CvWindow("quality 100", q100))
{
Cv.WaitKey();
}
}
}
示例2: Main
static void Main(string[] args)
{
// CreateCameraCaptureの引数はカメラのIndex(通常は0から始まる)
using (var capture = Cv.CreateCameraCapture(0))
{
IplImage frame = new IplImage();
// W320 x H240のウィンドウを作る
double w = 320, h = 240;
Cv.SetCaptureProperty(capture, CaptureProperty.FrameWidth, w);
Cv.SetCaptureProperty(capture, CaptureProperty.FrameHeight, h);
// 何かキーを押すまでは、Webカメラの画像を表示し続ける
while (Cv.WaitKey(1) == -1)
{
// カメラからフレームを取得
frame = Cv.QueryFrame(capture);
// Window「Capture」を作って、Webカメラの画像を表示
Cv.ShowImage("Capture", frame);
}
// bmp以外に、jpegやpngでの保存が可能
frame.SaveImage("result.bmp");
// 使い終わったWindow「Capture」を破棄
Cv.DestroyWindow("Capture");
}
}
示例3: Edge
public Edge()
{
using (IplImage src = new IplImage(Const.ImageLenna, LoadMode.Color))
using (IplImage gray = new IplImage(src.Size, BitDepth.U8, 1))
using (IplImage temp = new IplImage(src.Size, BitDepth.S16, 1))
using (IplImage dstSobel = new IplImage(src.Size, BitDepth.U8, 1))
using (IplImage dstLaplace = new IplImage(src.Size, BitDepth.U8, 1))
using (IplImage dstCanny = new IplImage(src.Size, BitDepth.U8, 1))
{
//src.CvtColor(gray, ColorConversion.RgbToGray);
src.CvtColor(gray, ColorConversion.BgrToGray);
// Sobel
Cv.Sobel(gray, temp, 1, 0, ApertureSize.Size3);
Cv.ConvertScaleAbs(temp, dstSobel);
// Laplace
Cv.Laplace(gray, temp);
Cv.ConvertScaleAbs(temp, dstLaplace);
// Canny
Cv.Canny(gray, dstCanny, 50, 200, ApertureSize.Size3);
using (new CvWindow("src", src))
using (new CvWindow("sobel", dstSobel))
using (new CvWindow("laplace", dstLaplace))
using (new CvWindow("canny", dstCanny))
{
CvWindow.WaitKey();
}
dstSobel.SaveImage("sobel.png");
dstLaplace.SaveImage("laplace.png");
dstCanny.SaveImage("canny.png");
}
}
示例4: Inpaint
public Inpaint()
{
// cvInpaint
// 画像の不要な文字列部分に対するマスク画像を指定して文字列を除去する
Console.WriteLine(
"Hot keys: \n" +
"\tESC - quit the program\n" +
"\tr - restore the original image\n" +
"\ti or ENTER - run inpainting algorithm\n" +
"\t\t(before running it, paint something on the image)\n" +
"\ts - save the original image, mask image, original+mask image and inpainted image to desktop."
);
// 原画像の読み込み
using (IplImage img0 = new IplImage(Const.ImageFruits, LoadMode.AnyDepth | LoadMode.AnyColor))
{
// お絵かき用の画像を確保(マスク)
using (IplImage img = img0.Clone())
using (IplImage inpaintMask = new IplImage(img0.Size, BitDepth.U8, 1))
// Inpaintの出力先画像を確保
using (IplImage inpainted = img0.Clone())
{
inpainted.Zero();
inpaintMask.Zero();
using (CvWindow wImage = new CvWindow("image", WindowMode.AutoSize, img))
{
// マウスイベントの処理
CvPoint prevPt = new CvPoint(-1, -1);
wImage.OnMouseCallback += delegate(MouseEvent ev, int x, int y, MouseEvent flags)
{
if (ev == MouseEvent.LButtonUp || (flags & MouseEvent.FlagLButton) == 0)
{
prevPt = new CvPoint(-1, -1);
}
else if (ev == MouseEvent.LButtonDown)
{
prevPt = new CvPoint(x, y);
}
else if (ev == MouseEvent.MouseMove && (flags & MouseEvent.FlagLButton) != 0)
{
CvPoint pt = new CvPoint(x, y);
if (prevPt.X < 0)
{
prevPt = pt;
}
inpaintMask.Line(prevPt, pt, CvColor.White, 5, LineType.AntiAlias, 0);
img.Line(prevPt, pt, CvColor.White, 5, LineType.AntiAlias, 0);
prevPt = pt;
wImage.ShowImage(img);
}
};
for (; ; )
{
switch ((char)CvWindow.WaitKey(0))
{
case (char)27: // ESCキーで終了
CvWindow.DestroyAllWindows();
return;
case 'r': // 原画像を復元
inpaintMask.Zero();
img0.Copy(img);
wImage.ShowImage(img);
break;
case 'i': // Inpaintの実行
case '\r':
CvWindow wInpaint = new CvWindow("inpainted image", WindowMode.AutoSize);
img.Inpaint(inpaintMask, inpainted, 3, InpaintMethod.Telea);
wInpaint.ShowImage(inpainted);
break;
case 's': // 画像の保存
string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
img0.SaveImage(Path.Combine(desktop, "original.png"));
inpaintMask.SaveImage(Path.Combine(desktop, "mask.png"));
img.SaveImage(Path.Combine(desktop, "original+mask.png"));
inpainted.SaveImage(Path.Combine(desktop, "inpainted.png"));
break;
}
}
}
}
}
}
示例5: SaveImage
unsafe ImageDetail[] SaveImage(Target[] targets)
{
IList<ImageDetail> imgs = new List<ImageDetail>();
foreach (Target t in targets)
{
Frame frame = t.BaseFrame;
DateTime dt = DateTime.FromBinary(frame.timeStamp);
for (int j = 0; j < t.FaceCount; ++j)
{
IntPtr* f = ((IntPtr*)(t.FaceData)) + j;
IplImage aFace = new IplImage(*f);
aFace.IsEnabledDispose = false;
string facePath = GetFacePath(frame, dt, j);
aFace.SaveImage(facePath);
imgs.Add(ImageDetail.FromPath(facePath));
}
}
ImageDetail[] details = new ImageDetail[imgs.Count];
imgs.CopyTo(details, 0);
return details;
}
示例6: SaveFrame
private static void SaveFrame(Frame frame)
{
IplImage ipl = new IplImage(frame.image);
ipl.IsEnabledDispose = false;
string path = frame.GetFileName();
DateTime dt = DateTime.FromBinary(frame.timeStamp);
string root = Path.Combine(Properties.Settings.Default.OutputPath,
frame.cameraID.ToString("d2"));
string folder = ImageClassifier.BuildDestDirectory(root, dt, Properties.Settings.Default.BigImageDirectoryName);
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
path = Path.Combine(folder, path);
ipl.SaveImage(path);
}
示例7: SaveImage
private static string SaveImage(IplImage image, DateTime captureTime)
{
var path = GetImagePath(captureTime);
var dir = Path.GetDirectoryName(path);
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
image.SaveImage(path);
return path;
}
示例8: button1_Click_2
private void button1_Click_2(object sender, EventArgs e)
{
string[] files = Directory.GetFiles(@"D:\pictures in hall");
foreach (string file in files)
{
string ext = Path.GetExtension(file);
if (ext != ".jpg") continue;
Bitmap img1 = (Bitmap)Bitmap.FromFile(file);
IplImage ipl = BitmapConverter.ToIplImage(img1);
IplImage ipl1 = new IplImage(ipl.CvPtr);
Bitmap bmp = ipl1.ToBitmap();
this.pictureFace.Image = bmp;
ipl1.SaveImage(@"d:\iplimg.jpg");
return;
// byte[] data = File.ReadAllBytes(file);
// Frame f = new Frame();
// f.data = IntPtr.Zero;// Marshal.AllocCoTaskMem(data.Length);
// //Marshal.Copy(data, 0, f.data, data.Length);
// f.dataLength = 0;// data.Length;
// f.image = IntPtr.Zero;
// f.timeStamp = 0;
// f.searchRect = IntPtr.Zero;
// f.fileName = Marshal.StringToCoTaskMemAnsi(file);
//
// bool group = NativeMethods.PreProcessFrame(ref f);
}
}