Exemple #1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            double exposuretime = Convert.ToDouble(cmdExposure.SelectedItem.ToString());

            if (IsConnected)
            {
                //driver.StartExposure(exposuretime, true);


                Cursor.Current       = Cursors.WaitCursor;
                btnTakeImage.Enabled = false;

                await Task.Run(async() =>
                {
                    driver.StartExposure(exposuretime, true);
                    while (!driver.ImageReady)
                    {
                        await Task.Delay(20);
                    }
                });

                if (chkPreview.Checked)
                {
                    Bitmap RawIMG;

                    try
                    {
                        Int32[,] _imagearray = (Int32[, ])driver.ImageArray;
                        RawIMG = Contrast(ColorBalance(createImage(_imagearray), 50, 50, 50), 15); //createImage(_imagearray);
                    }
                    catch
                    {
                        Int32[,,] _imagearray = (Int32[, , ])driver.ImageArray;
                        RawIMG = Contrast(ColorBalance(createImage(_imagearray), 50, 50, 50), 15);

                        if (ApiContainer.DslrCamera.IsLiveViewMode)
                        {
                            while (ApiContainer.DslrCamera.IsLiveViewMode && IsConnected)
                            {
                                _imagearray       = (Int32[, , ])driver.ImageArray;
                                RawIMG            = createImage(_imagearray);
                                pictTestfrm.Image = RawIMG;
                                driver.StartExposure(exposuretime, true);
                                await Task.Delay(10);
                            }
                        }
                    }

                    pictTestfrm.Image = RawIMG;
                }

                btnTakeImage.Enabled = true;
                Cursor.Current       = Cursors.Default;
            }
        }
        public unsafe Task <ImageView> Capture(double exposure)
        {
            return(new Task <ImageView>(() =>
            {
                _camera.StartExposure(exposure, true);

                Thread.Sleep((int)(exposure / 1000.0));

                while (!_camera.ImageReady)
                {
                    ;
                }

                var array = (int[, ])_camera.ImageArray;

                var xSize = array.GetUpperBound(0) + 1;
                var ySize = array.GetUpperBound(1) + 1;

                fixed(int *img = &(array[0, 0]))
                {
                    var pixels = new ushort[ySize * xSize];

                    for (var i = 0; i < pixels.Length; i++)
                    {
                        pixels[i] = (ushort)img[i];
                    }

                    return new ImageView {
                        XSize = xSize, YSize = ySize, Image = pixels
                    };
                }
            }));
        }
Exemple #3
0
        static void Main(string[] args)
        {
            // Uncomment the code that's required
#if UseChooser
            // choose the device
            string id = ASCOM.DriverAccess.Camera.Choose("");
            if (string.IsNullOrEmpty(id))
            {
                return;
            }
            // create this device
            ASCOM.DriverAccess.Camera device = new ASCOM.DriverAccess.Camera(id);
#else
            // this can be replaced by this code, it avoids the chooser and creates the driver class directly.
            ASCOM.DriverAccess.Camera device = new ASCOM.DriverAccess.Camera("ASCOM.SonyMirrorless.Camera");
#endif

            device.Connected = true;
            device.SetupDialog();
            // now run some tests, adding code to your driver so that the tests will pass.
            // these first tests are common to all drivers.
            Console.WriteLine("name " + device.Name);
            Console.WriteLine("description " + device.Description);
            Console.WriteLine("DriverInfo " + device.DriverInfo);
            Console.WriteLine("driverVersion " + device.DriverVersion);
            //            Console.WriteLine("sensorName " + device.SensorName);

            // TODO add more code to test the driver.
            int count = 0;

            ArrayList modes = device.ReadoutModes;

            device.FastReadout = true;
            while (true)
            {
                device.StartExposure(0.1, true);

                for (int i = 0; i < 100 && !device.ImageReady; i++)
                {
                    Thread.Sleep(250);
                }

                object o = device.ImageArray;
                count++;
                Console.WriteLine("Got an image #" + count.ToString());
                GC.Collect();
            }

            device.Connected = false;
            Console.WriteLine("Press Enter to finish");
            Console.ReadLine();
        }
Exemple #4
0
        public void StartExposure(double Duration, bool Light)
        {
            if (MyDriverType == 0)
            {
                MySSCamera.StartExposure(Duration, Light);
            }
            else
            {
                if (Duration < 0.0)
                {
                    throw new InvalidValueException("StartExposure", Duration.ToString(), "0.0 upwards");
                }
                if (cameraNumX > ccdWidth)
                {
                    throw new InvalidValueException("StartExposure", cameraNumX.ToString(), ccdWidth.ToString());
                }
                if (cameraNumY > ccdHeight)
                {
                    throw new InvalidValueException("StartExposure", cameraNumY.ToString(), ccdHeight.ToString());
                }
                if (cameraStartX > ccdWidth)
                {
                    throw new InvalidValueException("StartExposure", cameraStartX.ToString(), ccdWidth.ToString());
                }
                if (cameraStartY > ccdHeight)
                {
                    throw new InvalidValueException("StartExposure", cameraStartY.ToString(), ccdHeight.ToString());
                }

                cameraLastExposureDuration = Duration;
                exposureStart = DateTime.Now;
                System.Threading.Thread.Sleep((int)Duration * 1000);  // Sleep for the duration to simulate exposure
                tl.LogMessage("StartExposure", Duration.ToString() + " " + Light.ToString());
                cameraImageReady = true;
            }
        }
Exemple #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     driver.StartExposure(2, true);
 }
Exemple #6
0
 private void button1_Click(object sender, EventArgs e)
 {
     driver.StartExposure(2, true);
     SpinWait.SpinUntil(() => driver.CameraState == CameraStates.cameraIdle);
 }
Exemple #7
0
 public void StartExposure(double Duration, bool Light)
 {
     CheckConnected();
     m_camera.StartExposure(Duration, Light);
 }