using System; using System.Collections.Generic; using System.Runtime.InteropServices; using Vinno.DataManager.Process; using Vinno.DataManager.Utilities; using Vinno.DataTypes; namespace WingAIDiagnosisService.URMManage { [StructLayout(LayoutKind.Sequential)] public class URMProcessParams { public double DownsampleIndex { get; set; } public double IntPowerDen { get; set; } public double IntPowerDir { get; set; } public double SigmaGauss { get; set; } public double VessScale { get; set; } public double VelMaxScaler { get; set; } public double VelMinScaler { get; set; } public int iterations { get; set; } public double URMSigmaDen { get; set; } public double URMSigmaStep { get; set; } public int URMDirIterGauss { get; set; } public URMProcessParams() { DownsampleIndex = 3; IntPowerDen = 0.33; IntPowerDir = 0.25; SigmaGauss = 0.8; VessScale = 0.6; VelMaxScaler = 1; VelMinScaler = 0; iterations = 1; URMSigmaDen = 5; URMSigmaStep = 0.1; URMDirIterGauss = 10; } } [StructLayout(LayoutKind.Sequential)] public class URMImgBaseParam { public IntPtr Denptr { get; set; } //Den的分析后数据 public IntPtr Dirptr { get; set; } //Dir的分析后数据 public IntPtr Velptr { get; set; } //Vel的分析后数据 public IntPtr Angleptr { get; set; }//360图的数据 public IntPtr MaskPtr { get; set; }//Mask public int Urmsrcwidth { get; set; }//URM分析后的数据宽度 public int Urmsrcheight { get; set; }//URM分析后的数据高度 public double Res { get; set; } public double ScaleOfPixel_x { get; set; } public double ScaleOfPixel_y { get; set; } public int ImgProcessVer { get; set; }//后处理算法版本 0 Ver2(<2.7) 1 Ver3(2.7) public int vespekeltype { get; set; } } [StructLayout(LayoutKind.Sequential)] public class URMImgDrawParam { public IntPtr Screenimgptr { get; set; } public int Screenimgwidth { get; set; } public int Screenimgheight { get; set; } public int ZoomOn { get; set; } public double ZoomRoix { get; set; } public double ZoomRoiy { get; set; } public double ZoomRoiwidth { get; set; } public double ZoomRoiheight { get; set; } public int Roix { get; set; } public int Roiy { get; set; } public int Roiwidth { get; set; } public int Roiheight { get; set; } public int LeftRight { get; set; } public int UpDown { get; set; } } [StructLayout(LayoutKind.Sequential)] public class URMVideoParam { public double _VideoDownSampleIndex { get; set; } public double _VideoType { get; set; } public double _VideoScaler { get; set; } public URMVideoParam() { _VideoDownSampleIndex = 2; _VideoType = 1; _VideoScaler = 3; } } public class URMProcessAlg { [DllImport("ImageProcessAlgWrapLib.dll", CharSet = CharSet.Ansi)] private static extern IntPtr PIA_CreateURMProcess(IntPtr imagePP); [DllImport("ImageProcessAlgWrapLib.dll")] private static extern void PIA_SetURMParam(IntPtr handPtr, URMProcessParams srParams); [DllImport("ImageProcessAlgWrapLib.dll")] private static extern void PIA_SetURMImgBaseParams(IntPtr handPtr, URMImgBaseParam srParams); [DllImport("ImageProcessAlgWrapLib.dll")] private static extern void PIA_SetURMImgDrawParams(IntPtr handPtr, URMImgDrawParam srParams); [DllImport("ImageProcessAlgWrapLib.dll")] private static extern void PIA_CalURMImg(IntPtr handPtr, ref double barmax, ref double barmin, int type); [DllImport("ImageProcessAlgWrapLib.dll")] private static extern void PIA_DrawURMImg(IntPtr handPtr, int type, IntPtr colormap, int mixflag); [DllImport("ImageProcessAlgWrapLib.dll")] private static extern bool PIA_CalURMMeasurImg(IntPtr handle, IntPtr urmdmeasurimgptr, int urmtype, ref double barmax, ref double barmin); [DllImport("ImageProcessAlgWrapLib.dll")] private static unsafe extern void PIA_CalURMTraceMaskImg(IntPtr handle, int width, int height, DPoint* Points, int PointCount); [DllImport("ImageProcessAlgWrapLib.dll")] private static unsafe extern void PIA_CalURMVideo(IntPtr handle, IntPtr dstarray, URMVideoParam videoparam, URMPoint* Points, int framecount, int* PointsCounts, IntPtr colormap, int mixflage); [DllImport("ImageProcessAlgWrapLib.dll")] private static unsafe extern void PIA_PreURMVideo(IntPtr handle, URMVideoParam videoparam, URMPoint* Points, int framecount, int* PointsCounts, ref double barmax, ref double barmin); [DllImport("ImageProcessAlgWrapLib.dll")] private static extern void PIA_DrawURMVideo(IntPtr handle, int index, IntPtr colormapptr, int mixflag); [DllImport("ImageProcessAlgWrapLib.dll")] private static extern void PIA_URMMain_Release(IntPtr handPtr); private IntPtr _handle; public URMProcessAlg(ImagePP imgpp) { _handle = PIA_CreateURMProcess(imgpp.Handle); } public void SetURMParam(URMProcessParams srParams) { PIA_SetURMParam(_handle, srParams); } public void SetURMBaseParam(URMImgBaseParam Params) { PIA_SetURMImgBaseParams(_handle, Params); } public void SetURMDrawParam(URMImgDrawParam Params) { PIA_SetURMImgDrawParams(_handle, Params); } public void CalURMImg(ref double barmax, ref double barmin, int type) { PIA_CalURMImg(_handle, ref barmax, ref barmin, type); } public void DrawURM(int type, IntPtr colormap, int mixflag) { PIA_DrawURMImg(_handle, type, colormap, mixflag); } public void CalURMMeasurImg(IntPtr urmdmeasurimgptr, int urmtype, ref double barmax, ref double barmin) { PIA_CalURMMeasurImg(_handle, urmdmeasurimgptr, urmtype, ref barmax, ref barmin); } public unsafe void CalTraceMaskImg(int width, int height, List Points) { var pointarray = Points.ToArray(); fixed (DPoint* pointptr = pointarray) { PIA_CalURMTraceMaskImg(_handle, width, height, pointptr, Points.Count); } } public unsafe void CalURMVideo(NativeArray dstarray, URMVideoParam videoparam, URMPoint* Points, int framecount, int* PointsCounts, IntPtr colormap, int mixflag) { PIA_CalURMVideo(_handle, dstarray.Start, videoparam, Points, framecount, PointsCounts, colormap, mixflag); } public unsafe void PreURMVideo(URMVideoParam videoparam, URMPoint* Points, int framecount, int* PointsCounts, ref double barmax, ref double barmin) { PIA_PreURMVideo(_handle, videoparam, Points, framecount, PointsCounts, ref barmax, ref barmin); } public void DrawURMVideo(int index, IntPtr colormap, int mixflag) { PIA_DrawURMVideo(_handle, index, colormap, mixflag); } public void Release() { PIA_URMMain_Release(_handle); } } }