LEADTOOLS Multimedia (Leadtools.Multimedia assembly) Send comments on this topic. | Back to Introduction | Help Version 17.0.3.22
NumberOfLines Property
See Also 
Leadtools.Multimedia Namespace > AnalogVideoDecoder Class : NumberOfLines Property



Gets the number of scan lines in the video signal.

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property NumberOfLines As Integer
Visual Basic (Usage)Copy Code
Dim instance As AnalogVideoDecoder
Dim value As Integer
 
value = instance.NumberOfLines
C# 
public int NumberOfLines {get;}
C++/CLI 
public:
property int NumberOfLines {
   int get();
}

Property Value

A value indicating the number of scan lines.

Example

Visual BasicCopy Code
Public _result As Boolean = False
      Public _form As CaptureCtrlForm = New CaptureCtrlForm()
      Public Sub AvailableTVFormatsExample()
         Try
            ' reference the forms capture control
            Dim capturectrl As CaptureCtrl = _form.CaptureCtrl

            Dim outFile As String = Path.Combine(LEAD_VARS.MediaDir, "AnalogVideoDecoder_AvailableTVFormatsExample.avi")
            Dim lines As Integer = 0
            Dim allResults As Boolean = True

            ' select the first device with analog in it's name
            ' Replace "Analog" with your tuner device name
            If capturectrl.VideoDevices("Analog") Is Nothing Then
               Throw New Exception("No analog video capture device available")
            End If

            capturectrl.VideoDevices("Analog").Selected = True

            Dim analogvideodecoder As AnalogVideoDecoder = capturectrl.AnalogVideoDecoder
            Dim availableFormats As AnalogVideoStandard = analogvideodecoder.AvailableTVFormats
            Dim tvFormat As AnalogVideoStandard = analogvideodecoder.TVFormat

            ' Check if format is NTSC and set it if not
            If tvFormat <> AnalogVideoStandard.NTSC_M_J AndAlso (availableFormats And AnalogVideoStandard.NTSC_M_J) = AnalogVideoStandard.NTSC_M_J Then
               ' set the analog video decoder TV format
               analogvideodecoder.TVFormat = AnalogVideoStandard.NTSC_M_J

               ' check the changed format
               allResults = allResults And (analogvideodecoder.TVFormat = AnalogVideoStandard.NTSC_M_J)
            End If

            ' Check if Horizontal Locked is enabled
            Dim vLocked As Boolean = capturectrl.AnalogVideoDecoder.HorizontalLocked

            ' Some video device's Analog Decoder implementations do not
            ' support the following properties, so we wrap these property 
            ' accesses with a special try block to catch possible exceptions
            Try
               ' Check if VCR Horizontal Sync locking is enabled and set if not
               Dim vcrLocked As Boolean = capturectrl.AnalogVideoDecoder.VCRHorizontalLocking
               If (Not vcrLocked) Then
                  ' set VCR horzontal sync locking
                  capturectrl.AnalogVideoDecoder.VCRHorizontalLocking = True

                  ' include this as one of our checks
                  allResults = allResults And capturectrl.AnalogVideoDecoder.VCRHorizontalLocking
               End If

               ' Check if output enabled is set and set if not
               Dim outputEnabled As Boolean = capturectrl.AnalogVideoDecoder.OutputEnable
               If (Not outputEnabled) Then
                  ' enable output
                  capturectrl.AnalogVideoDecoder.OutputEnable = True

                  ' include this as one of our checks
                  allResults = allResults And capturectrl.AnalogVideoDecoder.OutputEnable
               End If
            Catch cex As COMException
               ' if the device does not support the properties above
               ' skip it and dont fail
               If cex.ErrorCode <> CInt(ErrorCode.E_PROP_ID_UNSUPPORTED) AndAlso cex.ErrorCode <> CInt(ErrorCode.E_PROP_SET_UNSUPPORTED) Then
                  Throw cex
               End If
            End Try

            Dim tries As Integer = 0

            ' check scan line count a few times 
            ' initial frames may differ from format spec, until frame data 
            ' has propogated through the capture graph
            Do While lines <> 525 AndAlso tries < 10
               ' get the number of scan lines in the output format
               lines = capturectrl.AnalogVideoDecoder.NumberOfLines
               System.Diagnostics.Debug.WriteLine("TV Format: " & analogvideodecoder.TVFormat.ToString() & ", Scan Lines: " & lines.ToString())
               tries += 1
            Loop

            ' include the line count check
            allResults = allResults And (lines = 525 AndAlso tries < 10)
            System.Diagnostics.Debug.WriteLine("Tries: " & tries.ToString())

            ' test results
            _result = allResults
         Catch e1 As Exception
            _result = False
         End Try
      End Sub

Public NotInheritable Class LEAD_VARS
   Public Const MediaDir As String = "C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 17\Media"
End Class
C#Copy Code
public bool _result = false;
      public CaptureCtrlForm _form = new CaptureCtrlForm();
      public void AvailableTVFormatsExample()
      {
         try
         {
            // reference the forms capture control
            CaptureCtrl capturectrl = _form.CaptureCtrl;

            string outFile = Path.Combine(LEAD_VARS.MediaDir, "AnalogVideoDecoder_AvailableTVFormatsExample.avi");
            int lines = 0;
            bool allResults = true;

            // select the first device with analog in it's name
            // Replace "Analog" with your tuner device name
            if (capturectrl.VideoDevices["Analog"] == null)
               throw new Exception("No analog video capture device available");

            capturectrl.VideoDevices["Analog"].Selected = true;

            AnalogVideoDecoder analogvideodecoder = capturectrl.AnalogVideoDecoder;
            AnalogVideoStandard availableFormats = analogvideodecoder.AvailableTVFormats;
            AnalogVideoStandard tvFormat = analogvideodecoder.TVFormat;

            // Check if format is NTSC and set it if not
            if (tvFormat != AnalogVideoStandard.NTSC_M_J
               && (availableFormats & AnalogVideoStandard.NTSC_M_J) == AnalogVideoStandard.NTSC_M_J)
            {
               // set the analog video decoder TV format
               analogvideodecoder.TVFormat = AnalogVideoStandard.NTSC_M_J;

               // check the changed format
               allResults &= (analogvideodecoder.TVFormat == AnalogVideoStandard.NTSC_M_J);
            }

            // Check if Horizontal Locked is enabled
            bool vLocked = capturectrl.AnalogVideoDecoder.HorizontalLocked;

            // Some video device's Analog Decoder implementations do not
            // support the following properties, so we wrap these property 
            // accesses with a special try block to catch possible exceptions
            try
            {
               // Check if VCR Horizontal Sync locking is enabled and set if not
               bool vcrLocked = capturectrl.AnalogVideoDecoder.VCRHorizontalLocking;
               if (!vcrLocked)
               {
                  // set VCR horzontal sync locking
                  capturectrl.AnalogVideoDecoder.VCRHorizontalLocking = true;

                  // include this as one of our checks
                  allResults &= capturectrl.AnalogVideoDecoder.VCRHorizontalLocking;
               }

               // Check if output enabled is set and set if not
               bool outputEnabled = capturectrl.AnalogVideoDecoder.OutputEnable;
               if (!outputEnabled)
               {
                  // enable output
                  capturectrl.AnalogVideoDecoder.OutputEnable = true;

                  // include this as one of our checks
                  allResults &= capturectrl.AnalogVideoDecoder.OutputEnable;
               }
            }
            catch (COMException cex)
            {
               // if the device does not support the properties above
               // skip it and dont fail
               if (cex.ErrorCode != (int)ErrorCode.E_PROP_ID_UNSUPPORTED
                  && cex.ErrorCode != (int)ErrorCode.E_PROP_SET_UNSUPPORTED)
                  throw cex;
            }

            int tries = 0;

            // check scan line count a few times 
            // initial frames may differ from format spec, until frame data 
            // has propogated through the capture graph
            while (lines != 525 && tries++ < 10)
            {
               // get the number of scan lines in the output format
               lines = capturectrl.AnalogVideoDecoder.NumberOfLines;
               System.Diagnostics.Debug.WriteLine("TV Format: " + analogvideodecoder.TVFormat.ToString() + ", Scan Lines: " + lines.ToString());
            }

            // include the line count check
            allResults &= (lines == 525 && tries < 10);
            System.Diagnostics.Debug.WriteLine("Tries: " + tries.ToString());

            // test results
            _result = allResults;
         }
         catch (Exception)
         {
            _result = false;
         }
      }

static class LEAD_VARS
{
   public const string MediaDir = @"C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 17\Media";
}

Remarks

This property is updated with the number of scan lines in the video signal. The retrieved value is generally 525 lines for NTSC and 625 lines for PAL or SECAM.

For more detailed information, refer to the Microsoft documentation for IAMAnalogVideoDecoder.get_NumberOfLines.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also