Skip to content

Commit

Permalink
v2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
9hy committed May 15, 2019
1 parent db6a415 commit 8148645
Show file tree
Hide file tree
Showing 17 changed files with 468 additions and 186 deletions.
40 changes: 22 additions & 18 deletions Blur/Blur.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="Emgu.CV.UI, Version=4.0.1.3373, Culture=neutral, PublicKeyToken=7281126722ab4438, processorArchitecture=MSIL">
<HintPath>..\packages\EMGU.CV.4.0.1.3373\lib\net35\Emgu.CV.UI.dll</HintPath>
</Reference>
<Reference Include="Emgu.CV.World, Version=4.0.1.3373, Culture=neutral, PublicKeyToken=7281126722ab4438, processorArchitecture=MSIL">
<HintPath>..\packages\EMGU.CV.4.0.1.3373\lib\net35\Emgu.CV.World.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -48,6 +54,13 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="XBF, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\XBF\bin\Debug\XBF.dll</HintPath>
</Reference>
<Reference Include="ZedGraph, Version=5.1.7.430, Culture=neutral, PublicKeyToken=02a83cbd123fcd60, processorArchitecture=MSIL">
<HintPath>..\packages\ZedGraph.5.1.7\lib\net35-Client\ZedGraph.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Form2.cs">
Expand All @@ -70,12 +83,7 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Assets\deploy.prototxt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Assets\lbfmodel.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand All @@ -85,23 +93,19 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="Assets\res10_300x300_ssd_iter_140000.caffemodel">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Assets\haarcascade_frontalface_default.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\XBF\XBF.csproj">
<Project>{530d1738-ec76-4575-83ae-af6d84537718}</Project>
<Name>XBF</Name>
</ProjectReference>
<Content Include="License-LGPL.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\EMGU.CV.4.0.1.3373\build\EMGU.CV.targets" Condition="Exists('..\packages\EMGU.CV.4.0.1.3373\build\EMGU.CV.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\EMGU.CV.4.0.1.3373\build\EMGU.CV.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EMGU.CV.4.0.1.3373\build\EMGU.CV.targets'))" />
</Target>
</Project>
66 changes: 50 additions & 16 deletions Blur/Form2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@


using XBF;

using Emgu.CV.Face;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.Util;

namespace Blur
{
Expand Down Expand Up @@ -79,7 +82,7 @@ private void button1_Click(object sender, EventArgs e)
// frame = (Bitmap)blurer.ClipToCircle(frame2.Bitmap, frame, new Point(face.X + face.Width / 2, face.Y + face.Height / 2), face.Width / 2, face);

//}
Analyzer analyzer = new Analyzer(true, Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\res10_300x300_ssd_iter_140000.caffemodel", Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\deploy.prototxt", Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\lbfmodel.yaml");
Analyzer analyzer = new Analyzer(true);
//frame = analyzer.BlurFaceOval(imageFrame.Mat).ToImage<Bgr, Byte>().Bitmap;
pictureBox1.Image = frame;
}
Expand All @@ -99,10 +102,26 @@ private void button2_Click(object sender, EventArgs e)

Bitmap frame = (Bitmap)Image.FromFile(path);

Analyzer analyzer = new Analyzer(false, Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\res10_300x300_ssd_iter_140000.caffemodel", Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\deploy.prototxt", Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\lbfmodel.yaml");
Analyzer analyzer = new Analyzer(false);

List<Rectangle> Faces = ((IAnalyzer)analyzer).getFaceRegions(Analyzer.ImageToByte(frame), analyzer.ssdProtoFile, analyzer.ssdFile);
PointF[][][] Landmarks_ = ((IAnalyzer)analyzer).getLandmarks(Analyzer.ImageToByte(frame), Faces, analyzer.facemarkFileName);

//List<VectorOfVectorOfPointF> landmarks = new List<VectorOfVectorOfPointF>(Landmarks_.Length);
//foreach (PointF[][] lm in Landmarks_)
//{
// landmarks.Add(new VectorOfVectorOfPointF(lm));
//}
Image<Bgr, Byte> img = new Image<Bgr, Byte>(frame);
//for (int i = 0; i < landmarks[0].Size; i++)
//{
// using (VectorOfPointF vpf = landmarks[0][i])
// FaceInvoke.DrawFacemarks(img, vpf, new MCvScalar(255, 128, 0));
//}


pictureBox1.Image = analyzer.BlurFaceWithLandmark(frame, 20);


pictureBox1.Image = img.Bitmap;

}
}
Expand All @@ -115,18 +134,33 @@ private void button3_Click(object sender, EventArgs e)
Bitmap imageFrame = Image.FromFile(path) as Bitmap;


Analyzer analyzer = new Analyzer(false, Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\res10_300x300_ssd_iter_140000.caffemodel", Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\deploy.prototxt", Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\lbfmodel.yaml");

Analyzer analyzer = new Analyzer(false);

List<Rectangle> Faces = analyzer.getFaceRegions(imageFrame, Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\deploy.prototxt", Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\res10_300x300_ssd_iter_140000.caffemodel");
PointF[][][] Landmarks = analyzer.getLandmarks(imageFrame, Faces, Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\lbfmodel.yaml");
List<Rectangle> Faces = ((IAnalyzer)analyzer).getFaceRegions(Analyzer.ImageToByte(imageFrame), analyzer.ssdProtoFile, analyzer.ssdFile);
PointF[][][] Landmarks = ((IAnalyzer)analyzer).getLandmarks(Analyzer.ImageToByte(imageFrame), Faces, analyzer.facemarkFileName);

Bitmap Mask = ((IAnalyzer)analyzer).getOpMask(Analyzer.ImageToByte(imageFrame), Faces, Landmarks);
Bitmap Final = ((IAnalyzer)analyzer).BlurFaceWithLandmark(Analyzer.ImageToByte(imageFrame), 12, Faces, Landmarks, Mask);

Bitmap Mask = analyzer.getOpMask(imageFrame, Faces, Landmarks);
Bitmap Final = analyzer.BlurFaceWithLandmark(imageFrame, 12, Faces, Landmarks, Mask);
//List<VectorOfVectorOfPointF> landmarks = new List<VectorOfVectorOfPointF>(Landmarks.Length);
//foreach (PointF[][] lm in Landmarks)
//{
// landmarks.Add(new VectorOfVectorOfPointF(lm));
//}
Image<Bgr, Byte> img = new Image<Bgr, Byte>(Final);
//for(int j = 0; j < Faces.Count; j++)
//{
// for (int i = 0; i < landmarks[j].Size; i++)
// {
// using (VectorOfPointF vpf = landmarks[j][i])
// FaceInvoke.DrawFacemarks(img, vpf, new MCvScalar(255, 128, 0));
// }
//}




pictureBox1.Image = Final;
pictureBox1.Image = img.Bitmap;

}
}
Expand All @@ -138,12 +172,12 @@ private void button4_Click(object sender, EventArgs e)
string path = openFileDialog1.FileName;
Bitmap imageFrame = Image.FromFile(path) as Bitmap;

Analyzer analyzer = new Analyzer(false, Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\res10_300x300_ssd_iter_140000.caffemodel", Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\deploy.prototxt", Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\lbfmodel.yaml");
Analyzer analyzer = new Analyzer(false);

List<Rectangle> Faces = analyzer.getFaceRegions(imageFrame, Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\deploy.prototxt", Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\res10_300x300_ssd_iter_140000.caffemodel");
PointF[][][] Landmarks = analyzer.getLandmarks(imageFrame, Faces, Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Assets\lbfmodel.yaml");
List<Rectangle> Faces = ((IAnalyzer)analyzer).getFaceRegions(Analyzer.ImageToByte(imageFrame), analyzer.ssdProtoFile, analyzer.ssdFile);
PointF[][][] Landmarks = ((IAnalyzer)analyzer).getLandmarks(Analyzer.ImageToByte(imageFrame), Faces, analyzer.facemarkFileName);

pictureBox1.Image = analyzer.getOpMask(imageFrame, Faces, Landmarks);
pictureBox1.Image = ((IAnalyzer)analyzer).getOpMask(Analyzer.ImageToByte(imageFrame), Faces, Landmarks);
}
}
}
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions Blur/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EMGU.CV" version="4.0.1.3373" targetFramework="net461" />
<package id="ZedGraph" version="5.1.7" targetFramework="net461" />
</packages>
Loading

0 comments on commit 8148645

Please sign in to comment.