private void CameraResolutionComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            //            const int VIDEOWIDTH = 1024; // Depends on video device caps
            //           const int VIDEOHEIGHT = 480; // Depends on video device caps
            //            const int VIDEOWIDTH = 1280; // Depends on video device caps
            //            const int VIDEOHEIGHT = 720; // Depends on video device caps
            //            const int VIDEOBITSPERPIXEL = 24; // BitsPerPixel values determined by device

            Sardauscan.Hardware.DSCameraProxy.Resolution res = (Sardauscan.Hardware.DSCameraProxy.Resolution) this.CameraResolutionComboBox.SelectedItem;
            DSCameraInfo camInfo = (DSCameraInfo)this.CameraComboBox.SelectedItem;

            DisposeCamera();
            if (res != null && camInfo != null)
            {
                try
                {
                    Camera = new DSCameraProxy(camInfo, res, null /*PreviewPanel*/);
                    Settings.Get <Settings>().Write(Settings.LAST_USED, Settings.CAMERA_RESOLUTION, res.ToString());
                    Settings.Get <Settings>().Write(Settings.LAST_USED, Settings.CAMERA_DEVICE, camInfo.UniqueId);
                    Proxy = Camera;
                    this.PreviewControl.Proxy = Proxy;
                }
                catch
                {
                }
            }
        }
        public static eHardware GetFromInstance(ICameraProxy cam, ITurnTableProxy table, ILaserProxy laser)
        {
            eHardware ret = eHardware.None;

            ret = GetModified(ret, eHardware.Camera, cam != null);
            ret = GetModified(ret, eHardware.Table, table != null);
            ret = GetModified(ret, eHardware.Laser, laser != null);
            return(ret);
        }
Example #3
0
        public LocationMapper(Vector3d laserLocation, Vector3d cameraLocation, SizeF tableSize)
        {
            m_LaserPos  = laserLocation;
            m_CameraPos = cameraLocation;
            TableSize   = tableSize;

            ICameraProxy camera = Settings.Get <ICameraProxy>();

            m_Image = new Size(camera.ImageWidth, camera.ImageHeight);

            m_focalLength = camera.FocalLength;
            m_Sensor      = new SizeF((float)camera.SensorWidth, (float)camera.SensorHeight);

            m_LaserPlane = new Plane(new Vector3d(), new Vector3d());
            CalculateLaserPlane();
        }
Example #4
0
 private void CameraResolutionComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     DisposeCamera();
     if (Moniker != null && Resolution != null)
     {
         try
         {
             NetCamera = new NetCameraProxy(Moniker, Resolution);
             Settings.Get <Settings>().Write(Settings.LAST_USED, Settings.CAMERA_RESOLUTION, Resolution.ToString());
             Guid id;
             Moniker.GetClassID(out id);
             Settings.Get <Settings>().Write(Settings.LAST_USED, Settings.CAMERA_DEVICE, id.ToString());
             Proxy = NetCamera;
             this.CameraControl.Proxy = Proxy;
         }
         catch
         {
         }
     }
 }
Example #5
0
 private void OnIdle(object sender, EventArgs e)
 {
     try
     {
         bool ignore = false;
         if (!ignore && Visible)
         {
             DateTime now     = DateTime.Now;
             bool     expired = (now - lastImageTime).TotalMilliseconds > 10;
             if (expired)
             {
                 ICameraProxy camera = Settings.Get <ICameraProxy>();
                 if (camera != null)
                 {
                     CurrentImage  = camera.AcquireImage();
                     lastImageTime = now;
                     ViewPanel.Invalidate();
                 }
                 else
                 {
                     bool lasthasImage = CurrentImage != null;
                     CurrentImage = null;
                     if (lasthasImage)
                     {
                         ViewPanel.Invalidate();
                     }
                 }
                 ILaserProxy laser = Settings.Get <ILaserProxy>();
                 expired = (now - lastImageTime).TotalMilliseconds > 750;
                 if (laser != null)
                 {
                     LaserControl.Proxy = laser;
                     LaserControl.AlignControls();
                 }
             }
         }
     }
     catch
     {
     }
 }
Example #6
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);
        }
		private void CameraResolutionComboBox_SelectedIndexChanged(object sender, EventArgs e)
		{
			//            const int VIDEOWIDTH = 1024; // Depends on video device caps
			//           const int VIDEOHEIGHT = 480; // Depends on video device caps
			//            const int VIDEOWIDTH = 1280; // Depends on video device caps
			//            const int VIDEOHEIGHT = 720; // Depends on video device caps
			//            const int VIDEOBITSPERPIXEL = 24; // BitsPerPixel values determined by device

			Sardauscan.Hardware.DSCameraProxy.Resolution res = (Sardauscan.Hardware.DSCameraProxy.Resolution)this.CameraResolutionComboBox.SelectedItem;
			DSCameraInfo camInfo = (DSCameraInfo)this.CameraComboBox.SelectedItem;
			DisposeCamera();
			if (res != null && camInfo != null)
			{
				try
				{
					Camera = new DSCameraProxy(camInfo, res, null/*PreviewPanel*/);
					Settings.Get<Settings>().Write(Settings.LAST_USED, Settings.CAMERA_RESOLUTION, res.ToString());
					Settings.Get<Settings>().Write(Settings.LAST_USED, Settings.CAMERA_DEVICE, camInfo.UniqueId);
					Proxy = Camera;
					this.PreviewControl.Proxy = Proxy ;
				}
				catch
				{
				}
			}
		}
		private void CameraResolutionComboBox_SelectedIndexChanged(object sender, EventArgs e)
		{
			DisposeCamera();
			if (Moniker != null && Resolution != null)
			{
				try
				{
					NetCamera = new NetCameraProxy(Moniker, Resolution);
					Settings.Get<Settings>().Write(Settings.LAST_USED, Settings.CAMERA_RESOLUTION, Resolution.ToString());
					Guid id;
					Moniker.GetClassID(out id);
					Settings.Get<Settings>().Write(Settings.LAST_USED, Settings.CAMERA_DEVICE, id.ToString());
					Proxy = NetCamera;
					this.CameraControl.Proxy = Proxy;
				}
				catch
				{
				}
			}
		}