释放动态库
This commit is contained in:
@@ -23,7 +23,7 @@ namespace Camera
|
|||||||
private const string PASSWD = "Yexian.net.168";
|
private const string PASSWD = "Yexian.net.168";
|
||||||
|
|
||||||
// 调试模式
|
// 调试模式
|
||||||
private const Boolean IsDebug = true;
|
private const Boolean IsDebug = false;
|
||||||
|
|
||||||
// 配置文件目录
|
// 配置文件目录
|
||||||
private string _configPath;
|
private string _configPath;
|
||||||
@@ -87,11 +87,18 @@ namespace Camera
|
|||||||
|
|
||||||
private static bool _isEmguCvAvailable = false;
|
private static bool _isEmguCvAvailable = false;
|
||||||
private static string _emguCvError = "";
|
private static string _emguCvError = "";
|
||||||
|
private static bool _isDllExtracted = false;
|
||||||
|
|
||||||
public static bool CheckEmguCv()
|
public static bool CheckEmguCv()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (!_isDllExtracted)
|
||||||
|
{
|
||||||
|
ExtractDlls();
|
||||||
|
_isDllExtracted = true;
|
||||||
|
}
|
||||||
|
|
||||||
using (var testImage = new Image<Bgr, byte>(1, 1))
|
using (var testImage = new Image<Bgr, byte>(1, 1))
|
||||||
{
|
{
|
||||||
testImage.Dispose();
|
testImage.Dispose();
|
||||||
@@ -107,6 +114,47 @@ namespace Camera
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ExtractDlls()
|
||||||
|
{
|
||||||
|
string appDir = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
|
bool is64Bit = Environment.Is64BitProcess;
|
||||||
|
|
||||||
|
string[] dllFiles = is64Bit
|
||||||
|
? new string[] { "x64.cvextern.dll", "x64.opencv_ffmpeg310_64.dll" }
|
||||||
|
: new string[] { "x86.cvextern.dll", "x86.opencv_ffmpeg310.dll" };
|
||||||
|
|
||||||
|
string[] destFiles = is64Bit
|
||||||
|
? new string[] { "cvextern.dll", "opencv_ffmpeg310_64.dll" }
|
||||||
|
: new string[] { "cvextern.dll", "opencv_ffmpeg310.dll" };
|
||||||
|
|
||||||
|
for (int i = 0; i < dllFiles.Length; i++)
|
||||||
|
{
|
||||||
|
string destPath = Path.Combine(appDir, destFiles[i]);
|
||||||
|
if (!File.Exists(destPath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var stream = typeof(Camera).Assembly.GetManifestResourceStream("Camera." + dllFiles[i]))
|
||||||
|
{
|
||||||
|
if (stream != null)
|
||||||
|
{
|
||||||
|
using (var fs = new FileStream(destPath, FileMode.Create))
|
||||||
|
{
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
|
||||||
|
{
|
||||||
|
fs.Write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsEmguCvAvailable()
|
public static bool IsEmguCvAvailable()
|
||||||
{
|
{
|
||||||
return _isEmguCvAvailable;
|
return _isEmguCvAvailable;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="..\packages\EmguCV.3.1.0.1\build\EmguCV.props" Condition="Exists('..\packages\EmguCV.3.1.0.1\build\EmguCV.props')" />
|
<Import Project="..\packages\EmguCV.3.1.0.1\build\EmguCV.props" Condition="Exists('..\packages\EmguCV.3.1.0.1\build\EmguCV.props')" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
@@ -101,10 +101,10 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="x64\cvextern.dll" />
|
<EmbeddedResource Include="x64\cvextern.dll" />
|
||||||
<Content Include="x64\opencv_ffmpeg310_64.dll" />
|
<EmbeddedResource Include="x64\opencv_ffmpeg310_64.dll" />
|
||||||
<Content Include="x86\cvextern.dll" />
|
<EmbeddedResource Include="x86\cvextern.dll" />
|
||||||
<Content Include="x86\opencv_ffmpeg310.dll" />
|
<EmbeddedResource Include="x86\opencv_ffmpeg310.dll" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
|||||||
@@ -35,16 +35,17 @@
|
|||||||
//
|
//
|
||||||
// pictureBox1
|
// pictureBox1
|
||||||
//
|
//
|
||||||
this.pictureBox1.Location = new System.Drawing.Point(30, 50);
|
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.pictureBox1.Name = "pictureBox1";
|
this.pictureBox1.Name = "pictureBox1";
|
||||||
this.pictureBox1.Size = new System.Drawing.Size(454, 376);
|
this.pictureBox1.Size = new System.Drawing.Size(800, 450);
|
||||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||||
this.pictureBox1.TabIndex = 0;
|
this.pictureBox1.TabIndex = 0;
|
||||||
this.pictureBox1.TabStop = false;
|
this.pictureBox1.TabStop = false;
|
||||||
//
|
//
|
||||||
// button1
|
// button1
|
||||||
//
|
//
|
||||||
this.button1.Location = new System.Drawing.Point(569, 152);
|
this.button1.Location = new System.Drawing.Point(644, 80);
|
||||||
this.button1.Name = "button1";
|
this.button1.Name = "button1";
|
||||||
this.button1.Size = new System.Drawing.Size(109, 49);
|
this.button1.Size = new System.Drawing.Size(109, 49);
|
||||||
this.button1.TabIndex = 1;
|
this.button1.TabIndex = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user