Skip to main content

Very simple open device and show live video in C++ - Knowledgebase / Software / Software for Windows - The Imaging Source Helpdesk

Very simple open device and show live video in C++

Authors list

In case you use Microsoft Visual Studio C++ and IC Imaging Control 3.4, then you start at https://theimagingsource.deskpro.com/en/kb/articles/creating-a-visual-studio-c-project-with-ic-imaging-control

IC Imaging Control 3.4 can be downloaded from https://www.theimagingsource.com/support/downloads-for-windows/software-development-kits-sdks/icimagingcontrol/

The main() is simple:

int main(int argc, char* argv[])

{

   DShowLib::InitLibrary();

   atexit( ExitLibrary );

   Grabber grabber;

      grabber.openDev("DFK 33UX183");

      if( !grabber.isDevValid())

   {

      return -1;

   }

   grabber.setVideoFormat("RGB24 (640x480)");

   grabber.startLive();

   std::cout << "Press any key to continue!" << std::endl;

   std::cin.get();

   grabber.stopLive();

   return 0;

}

In case you use another C++ environment and the C Wrapper DLL from https://www.theimagingsource.com/support/downloads-for-windows/software-development-kits-sdks/tisgrabberdll/:


#include <stdio.h>

#include <conio.h>

#include <tisgrabber.h>

int main()

{

    HGRABBER hGrabber; // The handle of the grabber object.

    IC_InitLibrary(NULL);

    hGrabber = IC_CreateGrabber();

    if( hGrabber )

    {

        IC_OpenVideoCaptureDevice(hGrabber,"DMK 23UV024");

        if( IC_IsDevValid(hGrabber))

        {

    IC_SetVideoFormat(hGrabber,"RGB24 (640x480)");

            IC_StartLive(hGrabber,1);

            printf("Press any key to stop the live video\n" );

            _getch();

            IC_StopLive(hGrabber);

        }

        IC_ReleaseGrabber(&hGrabber);

    }

    return 0;

}

If you use Microsoft Visual Studio C++, then IC Imaging Control is recommended, because it is more sophisticated.

Helpful Unhelpful