public override Sardauscan.Core.ScanData DoTask(Sardauscan.Core.ScanData source) { if (!HardwareAvailable) { throw new Exception(string.Format("HardWare missing : TURNTABLE:{0} LASER:{1} CAMERA:{2}", HardwarePresentTrace(TurnTable), HardwarePresentTrace(Laser), HardwarePresentTrace(Camera))); } double RotationStep = (double)Math.Round(360.0 / (NumberOfGrab - 1), 2); ScanData ret = new ScanData(); UpdatePercent(0, ret); TurnTable.InitialiseRotation(); Laser.TurnAll(false); int index = 0; for (double currentAngle = 0; currentAngle < 360f; currentAngle += RotationStep) { if (this.CancelPending) { return(ret); } Bitmap imgoff = GetCapture(); string path = Path.Combine(Folder, string.Format("capture{0}.jpg", ++index, (int)currentAngle)); imgoff.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg); int percent = (int)((currentAngle / 360f) * 100f); UpdatePercent(percent, ret); TurnTable.Rotate(currentAngle, false); Thread.Sleep(1000); } return(null); }
public override ScanData DoTask(ScanData source) { if (!HardwareAvailable) { throw new Exception(string.Format("HardWare missing : TURNTABLE:{0} LASER:{1} CAMERA:{2}", HardwarePresentTrace(TurnTable), HardwarePresentTrace(Laser), HardwarePresentTrace(Camera))); } RotationStep = (double)Math.Round(TurnTable.MinimumRotation() + (15f - TurnTable.MinimumRotation()) * ((100 - Precision) / 100f), 2); Settings settings = Settings.Get <Settings>(); CameraLoc.X = settings.Read(Settings.CAMERA, Settings.X, 0f); CameraLoc.Y = settings.Read(Settings.CAMERA, Settings.Y, 270f); CameraLoc.Z = settings.Read(Settings.CAMERA, Settings.Z, 70f); double thres = settings.Read(Settings.LASER_COMMON, Settings.MAGNITUDE_THRESHOLD, 10); int min = settings.Read(Settings.LASER_COMMON, Settings.MIN_WIDTH, 1); int max = settings.Read(Settings.LASER_COMMON, Settings.MAX_WIDTH, 60); ICameraProxy camera = Settings.Get <ICameraProxy>(); ImageProcessor = new ImageProcessor(thres, min, max); SizeF tableSize = new SizeF( (float)settings.Read(Settings.TABLE, Settings.DIAMETER, 20f), (float)settings.Read(Settings.TABLE, Settings.HEIGHT, 15f) ); Lasers = new List <LaserInfo>(LaserId.Length); for (int i = 0; i < LaserId.Length; i++) { Lasers.Add(new LaserInfo(LaserId[i], CameraLoc, tableSize)); } ScanData ret = new ScanData(); UpdatePercent(0, ret); int fadeTime = settings.Read(Settings.LASER_COMMON, Settings.FADE_DELAY, 100); TurnTable.InitialiseRotation(); int laserCount = Lasers.Count; // Scan all laser location, for (double currentAngle = 0; currentAngle < 360f; currentAngle += RotationStep) { if (this.CancelPending) { return(ret); } Laser.TurnAll(false); // All laser off Thread.Sleep(fadeTime); // wait fade laser Bitmap imgoff = GetCapture(); for (int laserIndex = 0; laserIndex < laserCount; laserIndex++) { Laser.Turn(Lasers[laserIndex].Id, true); Thread.Sleep(fadeTime); // wait fade laser Bitmap imgon = GetCapture(); Laser.Turn(Lasers[laserIndex].Id, false); List <PointF> laserloc = ImageProcessor.Process(imgoff, imgon, null); Point3DList samplePoints = Lasers[laserIndex].MapPoints(laserloc, UseTexture ? imgoff : null, UseCorrectionMatrix); PositionPostProcess(ref samplePoints, -Utils.DEGREES_TO_RADIANS(currentAngle)); ScanLine line = new ScanLine(laserIndex, samplePoints); line.DisplayAsLine = true; ret.Add(line); } int percent = (int)((currentAngle / 360f) * 100f); UpdatePercent(percent, ret); TurnTable.Rotate(currentAngle, false); } LineSort lineSort = new LineSort(); ret = lineSort.Run(ret, CallerControl, this.Worker, this.WorkerArg); if (!string.IsNullOrEmpty(FileName)) { string path = Path.Combine(Program.UserDataPath, FileName); ScanDataIO.Write(path, ret); } return(ret); }