|
|
@@ -12,6 +12,12 @@ namespace MvvmScaffoldFrame48.DLL.ImageAlgorithm
|
|
|
{
|
|
|
public static class HikVisionAlgorithmRelated
|
|
|
{
|
|
|
+ /// <summary>
|
|
|
+ /// Bitmap转MVDImage
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="cBitmapImg"></param>
|
|
|
+ /// <param name="cMvdImg"></param>
|
|
|
+ /// <exception cref="MvdException"></exception>
|
|
|
public static void ConvertBitmap2MVDImage(Bitmap cBitmapImg, CMvdImage cMvdImg)
|
|
|
{
|
|
|
// 参数合法性判断
|
|
|
@@ -90,6 +96,12 @@ namespace MvvmScaffoldFrame48.DLL.ImageAlgorithm
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// MVDImage转Bitmap
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="cMvdImg"></param>
|
|
|
+ /// <param name="cBitmapImg"></param>
|
|
|
+ /// <exception cref="MvdException"></exception>
|
|
|
public static void ConvertMVDImage2Bitmap(CMvdImage cMvdImg, ref Bitmap cBitmapImg)
|
|
|
{
|
|
|
// 参数合法性判断
|
|
|
@@ -199,5 +211,67 @@ namespace MvvmScaffoldFrame48.DLL.ImageAlgorithm
|
|
|
throw ex;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 加载图片(从文件)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="LoadImagePath"></param>
|
|
|
+ public static CMvdImage LoadImage(string LoadImagePath)
|
|
|
+ {
|
|
|
+ CMvdImage m_stInputImage = null;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(LoadImagePath))
|
|
|
+ {
|
|
|
+ if (null == m_stInputImage)
|
|
|
+ {
|
|
|
+ m_stInputImage = new CMvdImage();
|
|
|
+ }
|
|
|
+ m_stInputImage.InitImage(LoadImagePath);
|
|
|
+ Console.WriteLine("Finish loading image from [" + LoadImagePath + "].");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (MvdException ex)
|
|
|
+ {
|
|
|
+ Console.WriteLine("Fail to load image from [" + LoadImagePath + "]. ErrorCode: 0x" + ex.ErrorCode.ToString("X"));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Console.WriteLine("Fail to load image from [" + LoadImagePath + "]. Error: " + ex.Message);
|
|
|
+ }
|
|
|
+ return m_stInputImage;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 加载图片(从Bitmap)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="bitmap"></param>
|
|
|
+ public static CMvdImage LoadImage(Bitmap bitmap)
|
|
|
+ {
|
|
|
+ CMvdImage m_stInputImage = null;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (bitmap != null)
|
|
|
+ {
|
|
|
+ if (null == m_stInputImage)
|
|
|
+ {
|
|
|
+ m_stInputImage = new CMvdImage();
|
|
|
+ }
|
|
|
+ //m_stInputImage.InitImage(bitmap);
|
|
|
+ ConvertBitmap2MVDImage(bitmap, m_stInputImage);
|
|
|
+
|
|
|
+ Console.WriteLine("Finish loading image from [BitMap].");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (MvdException ex)
|
|
|
+ {
|
|
|
+ Console.WriteLine("Fail to load image from [BitMap]. ErrorCode: 0x" + ex.ErrorCode.ToString("X"));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Console.WriteLine("Fail to load image from [BitMap]. Error: " + ex.Message);
|
|
|
+ }
|
|
|
+ return m_stInputImage;
|
|
|
+ }
|
|
|
}
|
|
|
}
|