Created
March 4, 2014 12:13
-
-
Save kamiyaowl/9345443 to your computer and use it in GitHub Desktop.
OpenCVSharpの逐次処理記述量を短く
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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