예제 #1
0
        private void connectButton_Click(object sender, EventArgs e)
        {
            cam = sdk.OpenCamera(cameraSelection.SelectedItem.ToString(), false);
            //Set Camera parameters
            //cam.OperationMode = OperationMode.SoftwareTriggered;
            //cam.ExposureTime_us = 10000;
            //cam.FramesPerTrigger_zeroForUnlimited = 1;//Camera will only pull 1 frame
            //cam.OnImageFrameAvailable += OnFrameAvailable; // Register for Image Received Event
            //cam.Arm();


            this.cam.OnImageFrameAvailable += OnFrameAvailable;
            //this._bitDepth = cam.BitDepth;

            this.cam.OperationMode = OperationMode.SoftwareTriggered;
            this.cam.Arm();
            this.cam.IssueSoftwareTrigger();


            this._dispatcherTimerUpdateUI.Interval = TimeSpan.FromMilliseconds(50);
            this._dispatcherTimerUpdateUI.Tick    += this.DispatcherTimerUpdateUI_Tick;
            this._dispatcherTimerUpdateUI.Start();

            connectionStatusLabel.Visible         = true;
            connectButton.Enabled                 = false;
            disconnectButton.Enabled              = true;
            this.mainForm.CameraConnectivityText  = "Connected";
            this.mainForm.CameraConnectivityColor = Color.Green;
            imageOutput.Visible = true;
        }
예제 #2
0
        private void Optocheck_Load(object sender, EventArgs e)
        {
            ports = SerialPort.GetPortNames();
            sdk.OnCameraConnect    += Sdk_OnCameraConnect;    // Constantly check for if camera gets connected
            sdk.OnCameraDisconnect += Sdk_OnCameraDisconnect; // Constantly check for if camera gets disconnected
            iradionPath             = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\Iradion";
            imagesFolder            = System.IO.Directory.CreateDirectory(iradionPath + "\\Images").ToString();
            imagesPath              = System.IO.Path.Combine(iradionPath, imagesFolder).ToString();

            if (ports.Length > 0) // if there is at least one COM port
            {
                port = new SerialPort(ports[0], 115200, Parity.None, 8, StopBits.One);
                try
                {
                    port.Open(); // open first available port
                    statusOfCNCLabel.Text      = "Connected";
                    statusOfCNCLabel.ForeColor = Color.Green;
                }
                catch (Exception)
                {
                }
            }

            if (nums.Count > 0)                       // if there is at least one camera connected
            {
                cam = sdk.OpenCamera(nums[0], false); // auto open first available cam
                statusOfCameraLabel.Text      = "Connected";
                statusOfCameraLabel.ForeColor = Color.Green;

                //Set Camera parameters
                this.cam.OperationMode   = OperationMode.SoftwareTriggered;
                this.cam.ExposureTime_us = 10000;
                this.cam.FramesPerTrigger_zeroForUnlimited = 1;                // Camera will only pull 1 frame
                this.cam.OnImageFrameAvailable            += OnFrameAvailable; // Register for Image Received Event
                if (!cam.IsArmed)
                {
                    this.cam.Arm();               // arm the camera to take images
                }
            }
        }