Esempio n. 1
0
        private void openButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Stop any on-going acquisition
                stopButton.PerformClick();

                // Close the camera if one has already been opened
                if (_session != null)
                {
                    _session.Close();
                    _session = null;
                }

                // Create the session
                _session = new ImaqdxSession(cameraName.Text);

                // Update the tree of attributes
                PopulateTree();

                // Update the UI buttons
                startButton.Enabled = true;
            }
            catch (ImaqdxException error)
            {
                MessageBox.Show(error.ToString(), "NI-IMAQdx Error");
            }
        }
Esempio n. 2
0
        private void startButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Read UI controls
                string cameraName = cameraComboBox.Text;
                selectedAcquisitionType = (ImaqdxAcquisitionType)acquisitionModeComboBox.SelectedItem;
                numBuffersUsed          = (int)numberOfBuffersControl.Value;
                selectedBufferWaitMode  = bufferWaitMode.Text;

                // Open a new session and configure a grab
                _session = new ImaqdxSession(cameraName);
                _session.Acquisition.Configure(selectedAcquisitionType, numBuffersUsed);
                _session.Acquisition.Start();

                // Update UI state
                startButton.Enabled             = false;
                stopButton.Enabled              = true;
                numberOfBuffersControl.Enabled  = false;
                acquisitionModeComboBox.Enabled = false;
                bufferWaitMode.Enabled          = false;
                cameraComboBox.Enabled          = false;

                // Start up background worker to acquire images
                acquisitionWorker.RunWorkerAsync();
            }
            catch (ImaqdxException ex)
            {
                _session.Close();
                _session = null;
                MessageBox.Show(ex.Message, "NI-IMAQdx Error");
            }
        }
Esempio n. 3
0
        private void startButton_Click(object sender, EventArgs e)
        {
            try
            {
                imageScrollBar.Enabled = false;
                int numberOfImages = (int)numImages.Value;

                // Open camera
                _session = new ImaqdxSession(cameraComboBox.Text);

                // Create array of images
                images = new VisionImage[numberOfImages];
                for (int i = 0; i < images.Length; ++i)
                {
                    images[i] = new VisionImage();
                }

                // Acquire the sequence of images
                _session.Sequence(images, numberOfImages);

                // Close the camera
                _session.Close();

                // Update UI controls
                imageViewer.Attach(images[0]);
                imageScrollBar.Minimum = 0;
                imageScrollBar.Value   = imageScrollBar.Minimum;
                imageScrollBar.Maximum = numberOfImages - 1;
                imageScrollBar.Enabled = true;
            }
            catch (ImaqdxException ex)
            {
                MessageBox.Show(ex.Message, "NI-IMAQdx Error");
            }
        }
Esempio n. 4
0
 private void stopButton_Click(object sender, EventArgs e)
 {
     try
     {
         acquisitionWorker.CancelAsync();
         if (_session != null)
         {
             _session.Close();
             _session = null;
         }
         bufNumTextBox.Text = "";
     }
     catch (ImaqdxException ex)
     {
         MessageBox.Show(ex.Message, "NI-IMAQdx Error");
     }
 }
Esempio n. 5
0
        private void stopButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Notify the acquisition worker that we are stopping
                acquisitionWorker.CancelAsync();

                // Close the session
                if (_session != null)
                {
                    _session.Close();
                    _session = null;
                }
            }
            catch (ImaqdxException ex)
            {
                MessageBox.Show(ex.Message, "NI-IMAQdx Error");
            }
        }
Esempio n. 6
0
        private void startButton_Click(object sender, EventArgs e)
        {
            try
            {
                startButton.Enabled = false;
                int numberOfImages = (int)numImages.Value;

                // Open the camera
                _session = new ImaqdxSession(cameraComboBox.Text);

                // Create images
                images = new VisionImage[numberOfImages];
                for (uint i = 0; i < images.Length; ++i)
                {
                    images[i] = new VisionImage();
                }

                // Configure and start the camera
                _session.Acquisition.Configure(ImaqdxAcquisitionType.SingleShot, numberOfImages);
                _session.Acquisition.Start();

                // Get each image in the sequence
                for (uint i = 0; i < images.Length; ++i)
                {
                    _session.Acquisition.GetImageAt(images[i], i);
                }

                // Stop, Unconfigure, and Close the camera
                _session.Acquisition.Stop();
                _session.Acquisition.Unconfigure();
                _session.Close();
                _session = null;

                // Attach the viewer to the first image
                imageViewer.Attach(images[0]);

                // Setup the scroll bar to select the images
                imageScrollBar.Minimum = 0;
                imageScrollBar.Value   = imageScrollBar.Minimum;
                imageScrollBar.Maximum = numberOfImages - 1;
                imageScrollBar.Enabled = true;
            }
            catch (ImaqdxException ex)
            {
                MessageBox.Show(ex.Message, "NI-IMAQdx Error");
            }
            startButton.Enabled = true;
        }
Esempio n. 7
0
        private void startButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Open camera
                _session = new ImaqdxSession(cameraComboBox.Text);

                // Snap an image
                _session.Snap(imageViewer.Image);

                // Close the camera
                _session.Close();
            }
            catch (ImaqdxException ex)
            {
                MessageBox.Show(ex.Message, "NI-IMAQdx Error");
            }
        }
Esempio n. 8
0
        private void startButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Open camera
                _session = new ImaqdxSession(cameraComboBox.Text);

                // Configure and start a single-shot acquisition with 1 image
                _session.Acquisition.Configure(ImaqdxAcquisitionType.SingleShot, 1);
                _session.Acquisition.Start();

                // Get our image
                _session.Acquisition.GetImageAt(image, 0);

                //Stop, unconfigure, and close camera
                _session.Acquisition.Stop();
                _session.Acquisition.Unconfigure();
                _session.Close();
            }
            catch (ImaqdxException ex)
            {
                MessageBox.Show(ex.Message, "NI-IMAQdx Error");
            }
        }