Ejemplo n.º 1
0
        //==========================================================================================
        /// <summary>
        /// Acquires the last raw image data.
        /// </summary>
        /// <param name="data">
        /// Raw data of the specified frame.
        /// </param>
        /// <returns>
        /// The image with the captured pixel data.
        /// </returns>
        /// <remarks>
        /// If the image type does not match the video format of the camera, this method changes the image type to a suitable format.
        /// The returned array is the same array you pass in. If <paramref name="data"/> is <see langword="null"/>, an array is created and returned.</remarks>
        /// <exception cref="System.ObjectDisposedException">
        /// The session has been disposed.
        /// </exception>
        //==========================================================================================
        public byte[] GetLastImageData(ref byte[] data)
        {
            _session.ValidateSessionHandle();

            ImaqdxSessionManager.GetImageData(_session.Handle, ImaqdxBufferNumberMode.Last, ref data);
            return(data);
        }
Ejemplo n.º 2
0
        //==========================================================================================
        /// <summary>
        /// Reset Ethernet camera address.
        /// </summary>
        /// <param name="name">
        /// The name of the camera you want to open. <paramref name="name"/> must match the configuration file name you used to configure the camera in MAX. You can also open a camera using its 64-bit serial number (<format type="monospace">uuid:XXXXXXXXXXXXXXXX</format>), where the number following uuid must be a 64-bit hexadecimal number representing the internal serial number of the camera.
        /// <note type="note">
        /// Specify <format type="monospace">uuid:serial number in hexadecimal representation</format> for the camera name when opening in listening mode. The serial number must match the serial number used in MAX.
        /// </note>
        /// </param>
        /// <param name="address">
        /// Network address for the camera.
        /// </param>
        /// <param name="subnet">
        /// Subnet mask for the camera.
        /// </param>
        /// <param name="gateway">
        /// Gateway for the camera.
        /// </param>
        /// <param name="timeout">
        /// Time, in milliseconds, allowed for the Ethernet camera to reset its network address. The default timeout is 1000 ms.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        ///     <paramref name="name"/> is <see langword="null"/>.
        /// <para>
        /// -or-
        /// </para>
        ///     <paramref name="address"/> is <see langword="null"/>.
        /// <para>
        /// -or-
        /// </para>
        ///     <paramref name="subnet"/> is <see langword="null"/>.
        /// <para>
        /// -or-
        /// </para>
        ///     <paramref name="gateway"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        ///     <paramref name="timeout"/> is less than zero.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        ///     <paramref name="name"/> is an empty string.
        /// </exception>
        //==========================================================================================
        public static void ResetEthernetCameraAddress(string name, IPAddress address, IPAddress subnet, IPAddress gateway, int timeout)
        {
            if (name == null)
            {
                throw ExceptionBuilder.ArgumentNull("name");
            }
            if (name.Length == 0)
            {
                throw ExceptionBuilder.EmptyString("name");
            }
            if (address == null)
            {
                throw ExceptionBuilder.ArgumentNull("address");
            }
            if (subnet == null)
            {
                throw ExceptionBuilder.ArgumentNull("subnet");
            }
            if (gateway == null)
            {
                throw ExceptionBuilder.ArgumentNull("gateway");
            }
            if (timeout < 0)
            {
                throw ExceptionBuilder.ArgumentOutOfRange("timeout");
            }

            ImaqdxSessionManager.ResetEthernetCameraAddress(name, address, subnet, gateway, timeout);
        }
Ejemplo n.º 3
0
        public byte[] GetNextImageData(ref byte[] data, out uint actualBufferNumber)
        {
            _session.ValidateSessionHandle();

            actualBufferNumber = ImaqdxSessionManager.GetImageData(_session.Handle, ImaqdxBufferNumberMode.Next, ref data);
            return(data);
        }
Ejemplo n.º 4
0
        public byte[] GetImageDataAt(ref byte[] data, uint bufferNumber, out uint actualBufferNumber)
        {
            _session.ValidateSessionHandle();

            actualBufferNumber = ImaqdxSessionManager.GetImageData(_session.Handle, bufferNumber, ref data);
            return(data);
        }
Ejemplo n.º 5
0
        //==========================================================================================
        /// <summary>
        /// Reads attributes from the current camera file and applies to the current session.
        /// </summary>
        /// <exception cref="System.ObjectDisposedException">
        /// The session has been disposed.
        /// </exception>
        //==========================================================================================
        public void ReadAttributesFromCameraFile()
        {
            _session.ValidateSessionHandle();

            // Reading in attributes loads values for the current attributes
            // The attribute collection does not need to be repopulated
            ImaqdxSessionManager.ReadAttributesFromCameraFile(_session.Handle);
        }
Ejemplo n.º 6
0
        public VisionImage GetNextImage(VisionImage image, out uint actualBufferNumber)
        {
            _session.ValidateSessionHandle();

            image = _session.CreateImage(image);
            actualBufferNumber = ImaqdxSessionManager.GetImage(_session.Handle, ImaqdxBufferNumberMode.Next, image);
            return(image);
        }
Ejemplo n.º 7
0
        public VisionImage GetImageAt(VisionImage image, uint bufferNumber, out uint actualBufferNumber)
        {
            _session.ValidateSessionHandle();

            image = _session.CreateImage(image);
            actualBufferNumber = ImaqdxSessionManager.GetImage(_session.Handle, bufferNumber, image);
            return(image);
        }
Ejemplo n.º 8
0
        //==========================================================================================
        /// <summary>
        /// Acquires the last frame into the image parameter.
        /// </summary>
        /// <param name="image">
        /// The image that receives the captured pixel data.
        /// </param>
        /// <returns>
        /// The image with the captured pixel data.
        /// </returns>
        /// <exception cref="System.ObjectDisposedException">
        /// The session has been disposed.
        /// </exception>
        /// <remarks>
        /// If the image type does not match the video format of the camera, this method changes the image type to a suitable format.
        /// The returned image is the same image you pass in. If <paramref name="image"/> is <see langword="null"/>, an image is created and returned.</remarks>
        //==========================================================================================
        public VisionImage GetLastImage(VisionImage image)
        {
            _session.ValidateSessionHandle();

            image = _session.CreateImage(image);
            ImaqdxSessionManager.GetImage(_session.Handle, ImaqdxBufferNumberMode.Last, image);
            return(image);
        }
Ejemplo n.º 9
0
        //==========================================================================================
        /// <summary>
        /// Detects Ethernet cameras on a network.
        /// </summary>
        /// <param name="address">
        /// Specifies the destination address for the discovery command. The default address is 255.255.255.255.
        /// </param>
        /// <param name="timeout">
        /// Specifies the time, in milliseconds, allowed for the Ethernet camera discovery to complete. The default timeout is 1000 ms.
        /// </param>
        /// <remarks>
        /// Use this method to detect Ethernet cameras on a network with a remote subnet. During discovery, this method is blocked and returns after the specified timeout. The address specifies the destination address for the discovery command. The default address is 255.255.255.255.
        /// </remarks>
        /// <exception cref="System.ArgumentNullException">
        ///     <paramref name="address"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        ///     <paramref name="timeout"/> is less than zero.
        /// </exception>
        //==========================================================================================
        public static void DiscoverEthernetCameras(IPAddress address, int timeout)
        {
            if (address == null)
            {
                throw ExceptionBuilder.ArgumentNull("address");
            }
            if (timeout < 0)
            {
                throw ExceptionBuilder.ArgumentOutOfRange("timeout");
            }

            ImaqdxSessionManager.DiscoverEthernetCameras(address, timeout);
        }
Ejemplo n.º 10
0
        //==========================================================================================
        /// <summary>
        /// Performs a manual reset on a camera. Stops any ongoing acquisitions.
        /// </summary>
        /// <param name="cameraName">
        /// The name of the camera you want to reset. <paramref name="cameraName"/>
        ///     <format type="monospace">(cam0, cam1, ..., camN) </format> must match the configuration file name you used to configure the camera in MAX. You can also open a camera using its 64-bit serial number <format type="monospace">(uuid:XXXXXXXXXXXXXXXX)</format>, where the number following uuid must be a 64-bit hexadecimal number representing the internal serial number of the camera.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        ///     <paramref name="cameraName"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        ///     <paramref name="cameraName"/> is an empty string.
        /// </exception>
        //==========================================================================================
        public static void Reset(string cameraName)
        {
            if (cameraName == null)
            {
                throw ExceptionBuilder.ArgumentNull("cameraName");
            }
            if (cameraName.Length == 0)
            {
                throw ExceptionBuilder.EmptyString("cameraName");
            }

            ImaqdxSessionManager.Reset(cameraName);
        }
Ejemplo n.º 11
0
        //==========================================================================================
        /// <summary>
        /// Writes current attributes to the specified file.</summary>
        /// <param name="fullPath">
        /// The full path of the file.
        /// </param>
        /// <exception cref="System.ObjectDisposedException">
        /// The session has been disposed.
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        ///     <paramref name="fullPath"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        ///     <paramref name="fullPath"/> is an empty string.
        /// </exception>
        //==========================================================================================
        public void WriteAttributesToFile(string fullPath)
        {
            _session.ValidateSessionHandle();
            if (fullPath == null)
            {
                throw ExceptionBuilder.ArgumentNull("fullPath");
            }
            if (fullPath.Length == 0)
            {
                throw ExceptionBuilder.EmptyString("fullPath");
            }

            ImaqdxSessionManager.WriteAttributesToFile(_session.Handle, fullPath);
        }
Ejemplo n.º 12
0
        //==========================================================================================
        /// <summary>
        /// Configures a low-level acquisition.
        /// </summary>
        /// <param name="acquisitionType">
        /// Specifies whether the acquisition is <see cref="NationalInstruments.Vision.Acquisition.Imaqdx.ImaqdxAcquisitionType.Continuous" crefType="Unqualified"/> or <see cref="NationalInstruments.Vision.Acquisition.Imaqdx.ImaqdxAcquisitionType.SingleShot" crefType="Unqualified"/>.
        /// </param>
        /// <param name="bufferCount">
        /// For a <see cref="NationalInstruments.Vision.Acquisition.Imaqdx.ImaqdxAcquisitionType.SingleShot" crefType="Unqualified"/>, this parameter specifies the number of images to acquire. For a continuous acquisition, this parameter specifies the number of buffers the driver uses internally.
        /// </param>
        /// <exception cref="System.ObjectDisposedException">
        /// The session has been disposed.
        /// </exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        ///     <paramref name="bufferCount"/> is less than or equal to zero.
        /// </exception>
        //==========================================================================================
        public void Configure(ImaqdxAcquisitionType acquisitionType, int bufferCount)
        {
            _session.ValidateSessionHandle();
            if (!Enum.IsDefined(typeof(ImaqdxAcquisitionType), acquisitionType))
            {
                throw ExceptionBuilder.InvalidEnumArgument("acquisitionType", (int)acquisitionType, typeof(ImaqdxAcquisitionType));
            }
            if (bufferCount <= 0)
            {
                throw ExceptionBuilder.ArgumentOutOfRange("bufferCount");
            }

            ImaqdxSessionManager.ConfigureAcquisition(_session.Handle, acquisitionType, bufferCount);
        }
Ejemplo n.º 13
0
        //==========================================================================================
        /// <summary>
        /// Determines if the specified name element is in the collection.
        /// </summary>
        /// <param name="name">
        /// Name of the attribute to locate in the collection.
        /// </param>
        /// <returns>
        ///     <see langword="true"/> if the collection contains <paramref name="name"/>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     <paramref name="name"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        ///     <paramref name="name"/> is empty.
        /// </exception>
        /// <exception cref="System.ObjectDisposedException">
        /// The session is disposed.
        /// </exception>
        //==========================================================================================
        public bool Contains(string name)
        {
            _session.ValidateSessionHandle();
            if (name == null)
            {
                throw ExceptionBuilder.ArgumentNull("name");
            }
            if (name.Length == 0)
            {
                throw ExceptionBuilder.EmptyString("name");
            }

            string fullName = ImaqdxSessionManager.GetFullAttributeName(_session.Handle, name);

            return(_attributeLookupTable.ContainsKey(fullName));
        }
Ejemplo n.º 14
0
        //==========================================================================================
        /// <summary>
        /// Reads attributes from the string parameter and applies to the current session.
        /// </summary>
        /// <param name="attributesString">
        /// The string that contains attribute information.
        /// </param>
        /// <exception cref="System.ObjectDisposedException">
        /// The session has been disposed.
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        ///     <paramref name="attributesString"/> is <see langword="null"/>.
        /// <para>
        /// -or-
        /// </para>
        ///     <paramref name="attributesString"/>  is an empty string.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        ///     <paramref name="attributesString"/> is an empty string.
        /// </exception>
        //==========================================================================================
        public void ReadAttributesFromString(string attributesString)
        {
            _session.ValidateSessionHandle();
            if (attributesString == null)
            {
                throw ExceptionBuilder.ArgumentNull("attributesString");
            }
            if (attributesString.Length == 0)
            {
                throw ExceptionBuilder.EmptyString("attributesString");
            }

            // Reading in attributes loads values for the current attributes
            // The attribute collection does not need to be repopulated
            ImaqdxSessionManager.ReadAttributesFromString(_session.Handle, attributesString);
        }
Ejemplo n.º 15
0
        //==========================================================================================
        /// <summary>
        /// Gets the <see cref="NationalInstruments.Vision.Acquisition.Imaqdx.ImaqdxAttribute" crefType="Unqualified"/> with the specified name.
        /// </summary>
        /// <value>
        /// The <see cref="NationalInstruments.Vision.Acquisition.Imaqdx.ImaqdxAttribute" crefType="Unqualified"/> with the specified name; <see langword="null"/> if an <see cref="NationalInstruments.Vision.Acquisition.Imaqdx.ImaqdxAttribute" crefType="Unqualified"/> with the specified name does not exist in the collection.
        ///
        /// </value>
        /// <param name="name">
        /// The name of the entry to locate in the collection.
        ///
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        ///     <paramref name="name"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// <paramref name="name"/> is an empty string.
        /// </exception>
        //==========================================================================================
        public ImaqdxAttribute this[string name]
        {
            get
            {
                _session.ValidateSessionHandle();
                if (name == null)
                {
                    throw ExceptionBuilder.ArgumentNull("name");
                }
                if (name.Length == 0)
                {
                    throw ExceptionBuilder.EmptyString("name");
                }

                string fullName = ImaqdxSessionManager.GetFullAttributeName(_session.Handle, name);
                if (_attributeLookupTable.ContainsKey(fullName))
                {
                    int index = _attributeLookupTable[fullName];
                    return(Items[index]);
                }

                return(null);
            }
        }
Ejemplo n.º 16
0
        //==========================================================================================
        /// <summary>
        /// Writes attributes to the string parameter and returns it.
        /// </summary>
        /// <returns>
        /// The string containing the written attributes.
        /// </returns>
        /// <exception cref="System.ObjectDisposedException">
        /// The object has been disposed.
        /// </exception>
        //==========================================================================================
        public string WriteAttributesToString()
        {
            _session.ValidateSessionHandle();

            return(ImaqdxSessionManager.WriteAttributesToString(_session.Handle));
        }
Ejemplo n.º 17
0
 //==========================================================================================
 /// <summary>
 /// Returns a list of all cameras on the host computer.
 /// </summary>
 /// <param name="connectedOnly">
 /// If  <paramref name="connectedOnly"/> is <see langword="true"/>, then the cameraInformationArray only contains cameras that are currently connected to the host computer. If <paramref name="connectedOnly"/> is <see langword="false"/>, then the cameraInformationArray contains cameras that are currently connected, and were previously connected, to the host computer.
 /// </param>
 /// <returns>
 /// A list of all cameras on the host computer.
 /// </returns>
 //==========================================================================================
 public static ImaqdxCameraInformation[] GetCameraInformation(bool connectedOnly)
 {
     return(ImaqdxSessionManager.GetCameraInformation(connectedOnly));
 }
Ejemplo n.º 18
0
        //==========================================================================================
        /// <summary>
        /// Writes current attributes to the camera file. This method is only required if you wish to save parameters.
        ///
        /// </summary>
        /// <exception cref="System.ObjectDisposedException">
        /// The session has been disposed.
        /// </exception>
        //==========================================================================================
        public void WriteAttributesToCameraFile()
        {
            _session.ValidateSessionHandle();

            ImaqdxSessionManager.WriteAttributesToCameraFile(_session.Handle);
        }
Ejemplo n.º 19
0
        //==========================================================================================
        /// <summary>
        /// Unconfigures an acquisition previously configured with <see cref="NationalInstruments.Vision.Acquisition.Imaqdx.ImaqdxAcquisition.Configure" crefType="Unqualified"/>.
        /// </summary>
        /// <exception cref="System.ObjectDisposedException">
        /// The session has been disposed.
        /// </exception>
        //==========================================================================================
        public void Unconfigure()
        {
            _session.ValidateSessionHandle();

            ImaqdxSessionManager.UnconfigureAcquisition(_session.Handle);
        }
Ejemplo n.º 20
0
        //==========================================================================================
        /// <summary>
        /// Stops an acquisition previously started with <see cref="NationalInstruments.Vision.Acquisition.Imaqdx.ImaqdxAcquisition.Start" crefType="Unqualified"/>.
        ///
        /// </summary>
        /// <exception cref="System.ObjectDisposedException">
        /// The session has been disposed.
        /// </exception>
        //==========================================================================================
        public void Stop()
        {
            _session.ValidateSessionHandle();

            ImaqdxSessionManager.StopAcquisition(_session.Handle);
        }
Ejemplo n.º 21
0
 //==========================================================================================
 /// <summary>
 /// Performs a manual reset on all connected cameras. Stops any ongoing acquisitions.
 /// </summary>
 //==========================================================================================
 public static void ResetAll()
 {
     ImaqdxSessionManager.ResetAll();
 }