Esempio n. 1
0
		public void TestLaser(int laserIndex, double theshold, int minLaserWidth, int maxLaserWidth)
		{
			if (!Available)
			{
				this.ReferencePictureBox.Image = global::Sardauscan.Properties.Resources.Denied;
				this.LaserPictureBox.Image = global::Sardauscan.Properties.Resources.Denied;
				this.DifferencePictureBox.Image = global::Sardauscan.Properties.Resources.Denied;
				this.ResultPictureBox.Image = global::Sardauscan.Properties.Resources.Denied;
				return;
			}
			try
			{
                int fadeTime = Settings.Get<Settings>().Read(Settings.LASER_COMMON, Settings.FADE_DELAY, 100);
                // turn all laser off and take reference picture
				LaserProxy.TurnAll(false);
                Thread.Sleep(fadeTime); // wait fade laser
                Bitmap refImg = CameraProxy.AcquireImage();
				SetPicture(ReferencePictureBox,refImg);

				// take laser picture
				LaserProxy.Turn(laserIndex, true);
                Thread.Sleep(fadeTime); // wait fade laser
				Bitmap laserImg = CameraProxy.AcquireImage();
				SetPicture(LaserPictureBox,laserImg);

				Bitmap debuggingImage = new Bitmap(refImg.Width, refImg.Height);
				
				ImageProcessor imgproc = new ImageProcessor(theshold, minLaserWidth, maxLaserWidth);

                List<PointF> laserloc = imgproc.Process(refImg,laserImg,debuggingImage);

				SetPicture(DifferencePictureBox,debuggingImage);

				// Write the pixel image
				debuggingImage = BitmapExtention.SavePixels(laserloc, refImg.Width, refImg.Height);
				SetPicture(ResultPictureBox,debuggingImage);
			}
			catch { }
		}
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
		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;
		}