IC Imaging Control C++

Grabber::getAvailableVideoNorms Method

Grabber::getAvailableVideoNorms Method

Returns a list of all video norms supported by the current video capture device.
Syntax:
tVidNrmListPtr getAvailableVideoNorms() const
Return value:

A pointer to a list of VideoNormItems or 0, if an error occurred.

Remarks:

This method generates a list of all video norms (e.g. PAL, NTSC, ...) supported by the currently active video capture device. Some video devices (i.e. DCAM cameras) do not support video norms, therefore this list may be empty. Grabber::hasVideoNorms may be used to determine whether the device supports video norms.

Sample:
///////////////////////////////////////////////////////////////////////////////
//
// This example demonstrates how to query the available
// video norms and formats.
// If the current video capture device supports video norms, the available
// video formats depend on the current video norm. This example allows the user
// to select a video norm in this case, before it retrieves the video formats.
//
// If the current video capture device does not support video norms, the video
// formats are retrieved immediately.
//
#include "stdafx.h"
#include <conio.h>
#include "TISUDSHL.h"
using namespace _DSHOWLIB_NAMESPACE;
int main(int argc, char* argv[])
{
    int choice, input;
    int i=0;
    // Initialize the library.
    if( !DShowLib::InitLibrary() )
    {
        fprintf( stderr, "The library could not be initialized ");
        fprintf( stderr, "(invalid license key?).\n");
        exit( 1 );
    }
    Grabber *grabber=new Grabber();
    Grabber::tVidCapDevListPtr pVidCapDevList = grabber->getAvailableVideoCaptureDevices();
    if( pVidCapDevList == 0 || pVidCapDevList->empty() )
    {
        delete grabber;
        exit( 1 ); // No device available.
    }
    // Retrieve all available video capture devices and display them.
    printf( "Available Grabbers: \n" );
    for ( Grabber::tVidCapDevListPtr::value_type::iterator it =
              pVidCapDevList->begin();
          it != pVidCapDevList->end();
          ++it )
    {
        printf( "[%i] %s\n", i++, it->c_str() );
    }
    // Prompt the user to select a video capture device.
    printf( "Your Choice: ");
    input=scanf( "%i", &choice );
    // Open the selected video capture device.
    if ( choice>=0 && choice < pVidCapDevList->size() )
    {
        grabber->openDev( pVidCapDevList->at( choice ) );
    }
    else
    {
        delete grabber;
        exit( 0 ); // No Grabber selected, exit the example.
    }
    // Check whether video norms are available with the current video capture device.
    if ( grabber->hasVideoNorms() )
    {
        // Query for all available video norms.
        Grabber::tVidNrmListPtr pVidNrmList = grabber->getAvailableVideoNorms();
        if ( pVidNrmList == 0 )
        {
            fprintf( stderr, "Error: %s\n", grabber->getLastError() );
            delete grabber;
            exit( 1 );
        }
        while ( true )
        {
            i=0;
            // Display the available video norms.
            printf( "\n\nAvailable video norms:\n" );
            for ( Grabber::tVidNrmListPtr::value_type::iterator it =
                      pVidNrmList->begin();
                  it != pVidNrmList->end();
                  ++it )
            {
                printf( "[%i] %s\n", i++, it->c_str() );
            }
            // Prompt the user to select a video norm.
            printf( "Your choice (q to quit): ");
            // Exit the example if nothing was entered.
            input=scanf( "%i", &choice );
            if ( input == 0 )  break;
            if ( choice>=0 && choice <pVidNrmList->size() )
            {
                // Set the selected video norm to the video capture device before
                // retrieving the according video formats.
                grabber->setVideoNorm( pVidNrmList->at( choice ) );
                printf( "\n\nVideo Formats available for %s: \n", pVidNrmList->at( choice ).c_str() );
                // Now retrieve the video formats.
                Grabber::tVidFmtListPtr pVidFmtList = grabber->getAvailableVideoFormats();
                if ( pVidFmtList == 0 ) // No video formats available?
                {
                    fprintf( stderr, "Error: %s\n", grabber->getLastError() );
                    break;
                }
                i = 0;
                // List the available video formats.
                for ( Grabber::tVidFmtListPtr::value_type::iterator it =
                          pVidFmtList->begin();
                      it != pVidFmtList->end();
                      ++it )
                {
                    printf( "[%i] %s\n", i++, it->c_str() );
                }
            }
        }
    }
    else
    {
        // If the current video capture device does not support video norms,
        // the available video formats can be retrieved immediately.
        printf( "\n\nVideo Formats available: \n" );
        Grabber::tVidFmtListPtr pVidFmtList = grabber->getAvailableVideoFormats();
        if ( pVidFmtList == 0 ) // No video formats available?
        {
            fprintf( stderr, "Error: %s\n", grabber->getLastError() );
        }
        else
        {
            i = 0;
            // Display all available video formats on the screen.
            for ( Grabber::tVidFmtListPtr::value_type::iterator it =
                      pVidFmtList->begin();
                  it != pVidFmtList->end();
                  ++it )
            {
                printf( "[%i] %s\n", i++, it->c_str() );
            }
        }
    }
    delete grabber;
    printf("Press any key to continue");
    getch();
    return 0;
}
"sym">();

    return 0;


See also: Grabber, Grabber::isVideoNormAvailableWithCurDev, Grabber::hasVideoNorms, Grabber::getVideoNorm, Grabber::setVideoNorm, Grabber::tVidNrmListPtr

<< Grabber

Get in touch with us


About The Imaging Source

Established in 1990, The Imaging Source is one of the leading manufacturers of industrial cameras, frame grabbers and video converters for production automation, quality assurance, logistics, medicine, science and security.

Our comprehensive range of cameras with USB 3.1, USB 3.0, USB 2.0, GigE interfaces and other innovative machine vision products are renowned for their high quality and ability to meet the performance requirements of demanding applications.

Automated Imaging Association ISO 9001:2015 certified

Contact us