Results 1 to 2 of 2

Thread: AnsiC.c example to check if a device is in use

  1. #1
    Join Date
    Sep 2014

    AnsiC.c example to check if a device is in use

    I'm using the Ansi C DLL to (hopefully) control a camera from TIS. I'm having trouble understanding one of the code examples in the file AnsiC.c, included in the IC Imaging Control C Library

    Which of the calls to the DLL actually determines if the device is in use? It seems that the output of GetUniqueName is compared to the output of GetUniqueNameFromList, but this doesn't make any sense to me. Is one of these outputs expected to depend on whether or not the device is in use? The documentation does not seem to indicate this in any way. Should I read more carefully, or is this undocumented behavior?

    Also, when I run this code myself, it always shows the same output from these two function calls, even when I'm simultaneously streaming images from the camera using IC Capture 2.2. Is this expected behavior?

    /*! This functions shows, how to check, whether a video capture device is already
    	in use.
    void CheckDevice()
    	int i,o;
    	int iDeviceCount;
    	char szUniqueName[121];
    	HGRABBER Grabbers[10];
    	int iFound = 0;
    	for( i = 0; i < 10; i++ )				// Create some grabber objects for testing this function
    		Grabbers[i] = IC_CreateGrabber();
    	IC_OpenVideoCaptureDevice(  Grabbers[5], "DFK 21F04" );
    	if( !IC_IsDevValid(Grabbers[5]))  printf("Failed to open test device.\n");
    	iDeviceCount = IC_GetDeviceCount();			// Count the connected video capture devices
    	for( i = 0; i < iDeviceCount; i++ )
    		printf("Device %s\nUnique Name : %s\n\n",IC_GetDevice(i),IC_GetUniqueNamefromList(i));
    		for( o = 0; o < 10 && iFound == 0; o++)
    			if( IC_IsDevValid(Grabbers[o]))
    				if( IC_GetUniqueName(Grabbers[o], szUniqueName,120) == IC_SUCCESS)
    					if( strcmp( IC_GetUniqueNamefromList(i) , szUniqueName) == 0 )
    						printf("Device already in use. (Grabber %d)\n",o);
    						iFound = 1;
    	for( i = 0; i < 10; i++ )				// Create some grabber objects for testing this function

  2. #2
    Join Date
    Jan 2003
    Bremen, Germany

    Re: AnsiC.c example to check if a device is in use


    The only way to check, whether a camera is already streaming a live video, is trying to start the live video. If this fails, then either the camera is already streaming or another error happens.

    You can not determine, whether another application uses the camera. You can open the the camera twice and set properties, but the live stream can be started once only.

    The function aboves shows only, how identify a camera unique, if you have a camera in your application in use. This is to avoid to open your camera twice in the same program. That means, you must handle a list of currently used cameras in your program and compare it with all available cameras. This is done with IC_GetUniqueName(). This functions returns a unique name for each camera, even if you have connected many cameras of the same type.
    Best regards
    IC Imaging Control Support

Similar Threads

  1. Check if DFG/USB2-it is present
    By Masmeta in forum IC Imaging Control .NET
    Replies: 1
    Last Post: October 18, 2012, 15:49:11
  2. How to check auto whitebalance value ?
    By cephek in forum IC Imaging Control .NET
    Replies: 1
    Last Post: August 11, 2009, 14:52:07
  3. Could you check my DFK21AU04!!
    By aseitasi in forum Astronomy Cameras Support Forum
    Replies: 1
    Last Post: December 11, 2008, 10:05:58
  4. How can i check whether there is a grabber ?
    By RedSand in forum IC Imaging Control C++ Class Library
    Replies: 1
    Last Post: March 30, 2004, 08:31:25

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts