Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #7 from TheSwerik/GPU-Accelerated
Browse files Browse the repository at this point in the history
add Gpu acceleration
  • Loading branch information
TheSwerik authored Sep 17, 2020
2 parents 007baba + 69b7662 commit 163613b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ If you want to change any settings, then edit the `RedEye\config.csv` in your Do
| `PickAverage` | Basically: It detects mutliple things as eyes and if you set this to true it will place the Meme-Texture over the average of every found eye location (I suggest `false`). `true \| false` |
| `DrawRectangles` | Set if you want to draw rectangles over the areas where the program found your eyes (if you set this to `true`, then you probably want to lower `DetectionFrequency`). `true \| false` |
| `Face` | Set wether you want to detect Faces (or Eyes). `true \| false` |
| `Cuda` | **DOESN'T WORK!** Set wether you want GPU acceleration. `true \| false` |
| `Cuda` | Set wether you want GPU acceleration. `true \| false` |
| `ScreenshotLocation` | Set the Full-Path to a folder where you want your screenshots to be saved (Folder should exist). `Text \| default` |

# Examples
Expand Down
4 changes: 2 additions & 2 deletions RedEye.Backend/RedEye.Backend.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Emgu.CV.runtime.windows.cuda" Version="4.2.0.3662"/>
<PackageReference Include="System.Drawing.Common" Version="5.0.0-preview.3.20214.6"/>
<PackageReference Include="Emgu.CV.runtime.windows.cuda" Version="4.4.0.4061"/>
<PackageReference Include="System.Drawing.Common" Version="5.0.0-preview.8.20407.11"/>
</ItemGroup>

</Project>
44 changes: 20 additions & 24 deletions RedEye.Backend/src/Util/EmguCvUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Emgu.CV.Structure;
using Emgu.CV.Util;
using Emgu.Util;
using Emgu.Util.TypeEnum;

namespace RedEye.Util
{
Expand Down Expand Up @@ -52,8 +51,8 @@ public static Bitmap RawDataToBitmap(IntPtr scan0, int step, Size size, Type src
// See https://bugzilla.novell.com/show_bug.cgi?id=363431

if (
Platform.OperationSystem == OS.Windows &&
Platform.ClrType == ClrType.DotNet &&
Platform.OperationSystem == Platform.OS.Windows &&
Platform.ClrType == Platform.Clr.DotNet &&
srcColorType == typeof(Bgr) && srcDepthType == typeof(byte)
&& (step & 3) == 0)
//Bgr byte
Expand Down Expand Up @@ -184,7 +183,6 @@ public static Bitmap ToBitmap(this Mat mat)
CvInvoke.GetDepthType(mat.Depth), true);
}


/// <summary>
/// Convert the umat into Bitmap, the pixel values are copied over to the Bitmap
/// </summary>
Expand Down Expand Up @@ -212,8 +210,8 @@ public static Bitmap ToBitmap(this GpuMat gpuMat)
/// Create an Image &lt; TColor, TDepth &gt; from Bitmap
/// </summary>
public static Image<TColor, TDepth> ToImage<TColor, TDepth>(this Bitmap bitmap) where
TColor : struct, IColor
where TDepth : new()
TColor : struct, IColor
where TDepth : new()
{
var size = bitmap.Size;
var image = new Image<TColor, TDepth>(size);
Expand Down Expand Up @@ -408,17 +406,16 @@ public static Image<TColor, TDepth> ToImage<TColor, TDepth>(this Bitmap bitmap)
return image;
}


/// <summary>
/// Utility function for converting Bitmap to Image
/// </summary>
/// <param name="bmp">the bitmap to copy data from</param>
/// <param name="image">The image to copy data to</param>
private static void CopyFromBitmap<TColor, TDepth>(this Image<TColor, TDepth> image, Bitmap bmp) where
TColor : struct
, IColor
where TDepth :
new()
TColor : struct
, IColor
where TDepth :
new()
{
var data = bmp.LockBits(
new Rectangle(Point.Empty, bmp.Size),
Expand Down Expand Up @@ -450,8 +447,8 @@ private static void CopyFromBitmap<TColor, TDepth>(this Image<TColor, TDepth> im
/// Image&lt;Bgra, Byte&gt;, the image data is shared between the Bitmap and the Image object.
/// </returns>
public static Bitmap AsBitmap<TColor, TDepth>(this Image<TColor, TDepth> image) where
TColor : struct, IColor
where TDepth : new()
TColor : struct, IColor
where TDepth : new()
{
IntPtr scan0;
int step;
Expand All @@ -470,8 +467,8 @@ public static Bitmap AsBitmap<TColor, TDepth>(this Image<TColor, TDepth> image)
/// </remarks>
/// <returns> This image in Bitmap format, the pixel data are copied over to the Bitmap</returns>
public static Bitmap ToBitmap<TColor, TDepth>(this Image<TColor, TDepth> image) where
TColor : struct, IColor
where TDepth : new()
TColor : struct, IColor
where TDepth : new()
{
var typeOfColor = typeof(TColor);
var typeofDepth = typeof(TDepth);
Expand Down Expand Up @@ -524,26 +521,25 @@ public static Bitmap ToBitmap<TColor, TDepth>(this Image<TColor, TDepth> image)
/// <param name="height"> The height of the bitmap</param>
/// <returns> This image in Bitmap format of the specific size</returns>
public static Bitmap ToBitmap<TColor, TDepth>(this Image<TColor, TDepth> image, int width, int height) where
TColor :
struct,
IColor
where
TDepth :
new()
TColor :
struct,
IColor
where
TDepth :
new()
{
using (var scaledImage = image.Resize(width, height, Inter.Linear))
{
return scaledImage.ToBitmap();
}
}


/// <summary>
/// Convert the CudaImage to its equivalent Bitmap representation
/// </summary>
public static Bitmap ToBitmap<TColor, TDepth>(this CudaImage<TColor, TDepth> cudaImage) where
TColor : struct, IColor
where TDepth : new()
TColor : struct, IColor
where TDepth : new()
{
if (typeof(TColor) == typeof(Bgr) && typeof(TDepth) == typeof(byte))
{
Expand Down
8 changes: 4 additions & 4 deletions RedEye.UI/RedEye.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Emgu.CV.runtime.windows.cuda" Version="4.2.0.3662" />
<PackageReference Include="System.Drawing.Common" Version="5.0.0-preview.3.20214.6" />
<PackageReference Include="AForge.Video.DirectShow" Version="2.2.5" />
<PackageReference Include="WindowsAPICodePack-Shell" Version="1.1.1" />
<PackageReference Include="Emgu.CV.runtime.windows.cuda" Version="4.4.0.4061"/>
<PackageReference Include="System.Drawing.Common" Version="5.0.0-preview.8.20407.11"/>
<PackageReference Include="AForge.Video.DirectShow" Version="2.2.5"/>
<PackageReference Include="WindowsAPICodePack-Shell" Version="1.1.1"/>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
environment:
my_version_number: 1.4.1 # DONT FORGET TO CHANGE IS IN THE ISS FILE
my_version_number: 1.5.0 # DONT FORGET TO CHANGE IS IN THE ISS FILE
application_name: RedEye # DONT FORGET TO CHANGE IS IN THE ISS FILE
project_name: RedEye.UI

Expand Down

0 comments on commit 163613b

Please sign in to comment.