Skip to content

Instantly share code, notes, and snippets.

@kamiyaowl
Created March 4, 2014 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamiyaowl/9345443 to your computer and use it in GitHub Desktop.
Save kamiyaowl/9345443 to your computer and use it in GitHub Desktop.
OpenCVSharpの逐次処理記述量を短く
using Microsoft.Kinect;
using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace kamiya.util
{
public static class ImageUtil
{
/// <summary>
/// 同サイズ同深度同チャンネル数のIplImageを作成します
/// </summary>
/// <returns></returns>
public static IplImage CloneFrame(this IplImage src)
{
return new IplImage(src.Size, src.Depth, src.NChannels);
}
/// <summary>
/// 指定した手法で処理をした画像を返します
/// </summary>
/// <param name="src">元画像</param>
/// <param name="fx">画像処理を行う関数、srcとsrc.CloneFrame()によって初期化済みのdstが渡される</param>
/// <returns>編集後のdst</returns>
public static IplImage Process(this IplImage src, Action<IplImage, IplImage> fx)
{
var dst = src.CloneFrame();
fx(src, dst);
return dst;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment