This file contains hidden or 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 OpenCvSharp; | |
using System; | |
namespace OpenCvSharpSample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
This file contains hidden or 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 OpenCvSharp; | |
// using OpenCvSharp.CPlusPlus; | |
// リソースを自分の管理下において明示的に開放すればメモリリークしない | |
public static void CanAllocateMemoryMethod(int cameraId) | |
{ | |
using (var capture = new VideoCapture(cameraId)) | |
{ | |
var srcMat = new Mat(); |
This file contains hidden or 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 OpenCvSharp; | |
// using OpenCvSharp.CPlusPlus; | |
// リソースを解放しないとメモリリークする | |
public static void CannotAllocateMemoryMethod(int cameraId) | |
{ | |
using (var capture = new VideoCapture(cameraId)) | |
{ | |
var srcMat = new Mat(); |
This file contains hidden or 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
// 運が良いと、ガーベージコレクタがゴミリソースを回収してくれる | |
public static void CannotAllocateMemoryMethod3(int cameraId) | |
{ | |
using (var capture = new VideoCapture(cameraId)) | |
{ | |
var srcMat = new Mat(); | |
var dstMat = new Mat(); | |
while (Cv2.WaitKey(1) < 0) | |
{ |
This file contains hidden or 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 LINQtoCSV; | |
using NMeCab; | |
using System.Collections.Generic; | |
namespace RanukiCheckerConsole | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
This file contains hidden or 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
public static Mat ChromaKey(Mat srcMat, Mat backMat, int hueMin, int hueMax, int saturationMin, int saturationMax, int valueMin, int valueMax, int morphorogyIterations = 1) | |
{ | |
var mask = ColorExtractionMask(srcMat, ColorConversion.BgrToHsv, hueMin, hueMax, saturationMin, saturationMax, valueMin, valueMax); var element = new Mat(); | |
var back = new Mat(); | |
var face = new Mat(); | |
var result = new Mat(); | |
Cv2.MorphologyEx(mask, mask, MorphologyOperation.Close, element, null, morphorogyIterations); | |
Cv2.MorphologyEx(mask, mask, MorphologyOperation.Open, element, null, morphorogyIterations); |
This file contains hidden or 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
public static void ChromaKeyCaptureSum(int faceCameraId, int backCameraId, bool putText = true) | |
{ | |
using (var form = new Form()) | |
using (var trackbarHueMin = new TrackbarWithLabel("Hue (min)", 50, 180, 0)) | |
using (var trackbarHueMax = new TrackbarWithLabel("Hue (max)", 70, 180, 0)) | |
using (var trackbarSaturationMin = new TrackbarWithLabel("Saturation (min)", 80, 255, 0)) | |
using (var trackbarSaturationMax = new TrackbarWithLabel("Saturation (max)", 255, 255, 0)) | |
using (var trackbarValueMin = new TrackbarWithLabel("Value (min)", 0, 255, 0)) | |
using (var trackbarValueMax = new TrackbarWithLabel("Value (max)", 255, 255, 0)) | |
using (var faceCapture = new VideoCapture(faceCameraId)) |
This file contains hidden or 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 OpenCvSharp; | |
using OpenCvSharp.CPlusPlus; | |
using System; | |
namespace OpenCvSharpSample.Samples | |
{ | |
public class MethodTest | |
{ | |
public static void MouseClickCanvasWindow() | |
{ |
This file contains hidden or 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 OpenCvSharp; | |
using OpenCvSharp.CPlusPlus; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace OpenCvSharpSample.Samples | |
{ | |
public class MethodTest | |
{ |
This file contains hidden or 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 OpenCvSharp; | |
using OpenCvSharp.CPlusPlus; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace OpenCvSharpSample.Samples | |
{ | |
public class MethodTest | |
{ |