Results 1 to 6 of 6

Thread: Large overhead when adjusting gain

  1. #1
    Join Date
    Jun 2014
    Posts
    22

    Question Large overhead when adjusting gain

    Hi,

    I found there is a considerate delay when I switch the gain values. The interesting part is that when I use the same method adjusting the exposure, I don' see the large delay. So I want to make sure if it's a known behavior or because of something I did was wrong.

    My code is below, it updates the gain of the camera every 50 frames. The SetGainAbsolute function in the code is modified from Stefan's SetExposureAbsolute function by replacing "Exposure" with "Gain".

    The delay causes more than 60% FPS drop. For example for 50Hz capturing, the rate will drop to below 25Hz when adjusting the gain (and then goes back up to 50Hz). For exposure adjusting, it is only 10%-20%.



    Thanks very much for your reply.


    YZ

    PHP Code:
        /*************************************************************************/
        /* Start to run the test                                                                                                               */
        /*************************************************************************/
        
    int nTotalTests     10;
        
    double dfGain       0.5;
        
    double dfGainD      dfGain;

        for(
    int i 0nTotalTestsi++)
        {
            
    dfGain      dfGainD*(double)(i+1);
            
    lPrevTimeInMs GetTime();
            
    StartTimer();
            
    SetGainAbsolute(mpGrabberdfGain);
            
    mpGrabber->startLive();
            for(
    int f 0nNumTotalFramesf++)
            {
                
    StartTimer();
                
    pSink->snapImages(1);
                
    StopTimer();
                
    lCurrTime GetTime();
                
    oRez.push_back(lCurrTime lPrevTime);
                
    lPrevTime lCurrTime;
            }
            
    StartTimer();
            
    mpGrabber->stopLive();
            
    StopTimer();
        } 
    PHP Code:
    bool SetGainAbsoluteDShowLib::Grabber *pGrabberdouble dGain )
    {
        
    bool bOK false;
        
    DShowLib::tIVCDAbsoluteValuePropertyPtr pGainRange;
        
    DShowLib::tIVCDSwitchPropertyPtr pGainAuto;

        
    pGainRange NULL;
        
    pGainAuto NULL;
        
        
    tIVCDPropertyItemsPtr pItems pGrabber->getAvailableVCDProperties();
        if( 
    pItems != )
        { 
            
    // Try to find the Gain item. 
            
    tIVCDPropertyItemPtr pGainItem pItems->findItemVCDID_Gain );
            if( 
    pGainItem != )
            { 
                
    // Try to find the value and auto elements 
                
    tIVCDPropertyElementPtr pGainValueElement pGainItem->findElementVCDElement_Value );
                
    tIVCDPropertyElementPtr pGainAutoElement pGainItem->findElementVCDElement_Auto );

                
    // If an auto element exists, try to acquire a switch interface 
                
    if( pGainAutoElement != )
                { 
                    
    pGainAutoElement->getInterfacePtrpGainAuto );
                    
    pGainAuto->setSwitch(false); // Disable auto, otherwise we can not set Gain.
                



                
    // If a value element exists, try to acquire a range interface 
                
    if( pGainValueElement != )
                { 
                    
    pGainValueElement->getInterfacePtrpGainRange );

                    
    double min pGainRange->getRangeMin();
                    
    double max pGainRange->getRangeMax();

                    if ( 
    dGain min )
                    {
                        
    dGain min;
                    }
                    else if( 
    dGain max )
                    {
                        
    dGain max;
                    }
                                    
                    
    // Here we set the the Gain value.
                    
    pGainRange->setValuedGain); 
                    
    bOK true;
                } 
            } 
        }
        return 
    bOK;

    Last edited by yan_zhao_ep; June 23, 2014 at 21:07:19.

  2. #2
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,861

    Re: Large overhead when adjusting gain

    Which camera model do you use? I lost it somewhere.
    Also you can use DShowLib::tIVCDAbsoluteValuePropertyPtr pGainRange; as global variable, so you only query it once for your camera.
    Best regards
    Stefan
    IC Imaging Control Support

  3. #3
    Join Date
    Jun 2014
    Posts
    22

    Re: Large overhead when adjusting gain

    It's a DFK23UP031.

    I'll try to put pGainRange outside the function.

  4. #4
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,861

    Re: Large overhead when adjusting gain

    However, this should be fast enough too.
    I suppose the number of buffers in your sink is greater than one. If not set it to a value greater one.

    Setting a gain value should not take noticeable time. Not more, than exposure. The gain automatic runs in the camera driver, it sends new gain values all the time to the camera, if the automatic is enabled.

    The line
    pGainRange->setValue( dGain);
    is the interresting one for you, which you may insert directly in your snapImage loop.
    Best regards
    Stefan
    IC Imaging Control Support

  5. #5
    Join Date
    Jun 2014
    Posts
    22

    Re: Large overhead when adjusting gain

    Hi Stefan,

    Thanks for your help. Actually I made a mistake in the code that I stopped and started live as I did for ROI update.

    Now the function works fine after I moving startLive and stopLive out of my test loop.



    Regards,

    YZ

  6. #6
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,861

    Re: Large overhead when adjusting gain

    Very well.
    Best regards
    Stefan
    IC Imaging Control Support

Similar Threads

  1. Windows8 and ICcapture.AS produces too large videos
    By TeroP in forum Astronomy Cameras Support Forum
    Replies: 6
    Last Post: November 6, 2012, 16:17:24
  2. Electronic gain and IC capture gain
    By lorenzo_V in forum Hardware and Driver
    Replies: 6
    Last Post: April 2, 2012, 17:14:54
  3. Adjusting Exposure in LabVIEW?
    By videmus in forum IC Imaging Control ActiveX
    Replies: 5
    Last Post: August 5, 2008, 10:06:39
  4. gain or not gain or contrast
    By stefan6973 in forum IC Imaging Control C++ Class Library
    Replies: 1
    Last Post: September 16, 2005, 18:27:55
  5. MemBufferCollections Deallocate/Allocate large buffers problem?
    By bitsnbites13 in forum IC Imaging Control C++ Class Library
    Replies: 2
    Last Post: May 17, 2005, 15:14:42

Tags for this Thread

Bookmarks

Posting Permissions

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