From afd3972c6f01256055da0a00b2887a81df0739d4 Mon Sep 17 00:00:00 2001 From: Carter Date: Mon, 17 Aug 2026 11:18:11 -0400 Subject: [PATCH] New sharpen filter and a new option to select the filter --- src/program.cs | 4 ++++ src/videoFilters.cs | 45 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/program.cs b/src/program.cs index 91cea9b..16daa75 100644 --- a/src/program.cs +++ b/src/program.cs @@ -23,6 +23,10 @@ namespace VideoProcessor Filters edges = new Filters(); edges.Edges(); break; + case "sharpen": + Filters sharpen = new Filters(); + sharpen.Sharpen(); + break; default: diff --git a/src/videoFilters.cs b/src/videoFilters.cs index 01afa08..d82f519 100644 --- a/src/videoFilters.cs +++ b/src/videoFilters.cs @@ -8,11 +8,12 @@ namespace VideoProcessor class Filters { /// - /// + /// Creates a grey scale image and every pixel with a vule inside a range is changed to blue and + /// every other pixel is changed to green /// public void ColorSwap() { - VideoCapture capture = new VideoCapture(); + VideoCapture capture = new VideoCapture(0); Mat frame = new(); bool pause = false; @@ -56,11 +57,11 @@ namespace VideoProcessor } /// - /// + /// Uses canny edge ditection to find and display all the edges in a frame /// public void Edges() { - VideoCapture capture = new VideoCapture(); + VideoCapture capture = new VideoCapture(0); Mat feed = new Mat(); Mat guassianBlur = new Mat(); Mat cannyFeed = new Mat(); @@ -87,5 +88,41 @@ namespace VideoProcessor } } } + + /// + /// + /// + public void Sharpen() + { + VideoCapture capture = new(); + Mat feed = new(); + Mat sharpendFeed = new(); + + bool play = false; + + float[,] kernalArray = new float[3, 3] + { + { 0, -1, 0}, + { -1, 5, -1}, + { 0, -1, 0} + }; + + ConvolutionKernelF kernal = new ConvolutionKernelF(kernalArray); + + while(!play) + { + capture.Read(feed); + + CvInvoke.Filter2D(feed, sharpendFeed, kernal, new Point(0, 0)); + + CvInvoke.Imshow("Sharpend Video", sharpendFeed); + + int keyPressed = CvInvoke.WaitKey(1); + if (keyPressed == 27) + { + play = true; + } + } + } } } \ No newline at end of file