AFEngine C++ lib. Auto focus engine for different software lens controllers.

€600.00

AFEngine C++ library provides auto focus function for different software lens controllers.

LICENSE: We sell source code of this library as is, without future updates and technical support according to perpetual non-exclusive royalty-free license. You pay once and can use this library in your software and hardware products without limits. Please read the license agreement before purchasing: LICENSE.

AFEngine C++ library provides auto focus function for different software lens controllers.

LICENSE: We sell source code of this library as is, without future updates and technical support according to perpetual non-exclusive royalty-free license. You pay once and can use this library in your software and hardware products without limits. Please read the license agreement before purchasing: LICENSE.

Overview

AFEngine C++ library provides auto focus function for different software lens controllers. AFEngine class doesn’t control lens directly. It just get lens state and gives what should lens controller doing for reaching optimal focus position. The library provides various auto focus features: push focus, continuous auto focus (after changing zoom), auto focus timeout, autofocus sensitivity trigger, auto focus ROI change and auto focus ROI detection. The library has a simple interface for embedding in different software lens controllers. To ensure autofocus operation, the user must transfer each new video frame to the library, as well as transfer the current zoom and focus positions. The library depends on Frame library (provides description of video frame class, source code included, Apache 2.0 license) and on Denoiser library (provides noise cancellation algorithm, source code included, Apache 2.0 license). The library uses C++17 standard.

Documentation

Documentation: GO TO DOCUMENTATION

Simple interface

class AFEngine 
{
public:
    /// Get engine version.
    static std::string getVersion();

    /// Add video frame for processing.
    bool addVideoFrame(cr::video::Frame& frame);
    
    /// Update data to get AF State Machine value.
    int updateData(int zoomPos, int focusPos, int& reqPos);

    /// Set the AFEngine param.
    bool setParam(AFParam id, float value);

    /// Get the AFEngine param.
    float getParam(AFParam id);

    /// Execute command.
    bool executeCommand(AFCommand id);
};

Simple example

#include "yourLens.h"
***
/// Class constructor.
cr::lens::yourLens::yourLens()
{
    ***
     m_afEngine.setParam(cr::af::AFParam::FOCUS_MOVE_THRESHOLD, 0);
    m_afEngine.setParam(cr::af::AFParam::ZOOM_MOVE_THRESHOLD, 0);
    m_afEngine.setParam(cr::af::AFParam::FOCUS_POSITION_ACCURACY, 350);
    m_afEngine.setParam(cr::af::AFParam::FF_DECREASE_THRESHOLD, 80);
}
/// Add video frame to calculate focus factor.
void cr::lens::yourLens::addVideoFrame(cr::video::Frame& frame)
{
    m_afEngine.addVideoFrame(frame);
}

void cr::lens::yourLens::lensCommunicationThreadFunction()
{
    ***
    int reqPos=0;
    int afAction = 0;
    int afActionPrev = 0;
    ***
    while(true)
    {
        ***
        afAction = m_afEngine.updateData(m_params.zoomPos,
                                        m_params.focusPos,
                                        reqPos);
        if(afAction == 0)
        m_params.afIsActive = false;
        else
        m_params.afIsActive = true;
        switch(afAction)
        {
            case 0:  // nothing to do

            break;
            case 1:  // move to far
            if(afAction!= afActionPrev)
            {
                   /// Place code to move lens FAR with AF_HW_SPEED
            }
            break;
            case 2:  // move to Start or optimal
            if(afAction!= afActionPrev)
            {
                /// Place code to move lens as fast as possible to FOCUS_TO_ABS_POS = reqPos  
            }
            break;
            case 3:  // move to near
            if(afAction!= afActionPrev)
            {
                /// Place code to move lens FAR with AF_HW_SPEED
            }
            break;
        }
        afActionPrev = afAction;
    }
}