User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
isp:sample_ae_implementation_in_c [2018/06/17 21:24] – [Helpers] Igor Yefmovisp:sample_ae_implementation_in_c [2022/04/04 23:32] (current) – external edit 127.0.0.1
Line 292: Line 292:
 }</code> }</code>
  
 +====== Sample usage ======
 +
 +This is a copy-paste of the code used in [[manual:Aria]] utility for the POC. This code has minimal comments but should be fairly easy to follow:
 +
 +<code c++>namespace{
 +
 +static CString _corrOp2Txt(AE::CorrOp _op){
 +    using op = AE::CorrOp;
 +    switch(_op){
 +    case op::noop:      return {};
 +    case op::inc_exp:   return L"+++ Increasing Exposure";
 +    case op::inc_gl:    return L"+++ Increasing GLOBAL gain";
 +    case op::inc_green: return L"+++ PANIC! Increasing GREEN gain";
 +    case op::dec_exp:   return L"--- Reducing Exposure";
 +    case op::dec_gl:    return L"--- Reducing GLOBAL gain";
 +    case op::dec_green: return L"--- Reducing GREEN gain";
 +    }
 +    return {};
 +}
 +
 +}
 +
 +
 +void ImgAnalyzerDlg::_aeInfo()
 +{
 +    if(((CButton *)(GetDlgItem(IDC_CHECK_ISA_AE)))->GetCheck() != BST_CHECKED){
 +        return;
 +    }
 +    const auto & stats = m_analyzer.getStats();
 +    const auto correct = ((CButton*)(GetDlgItem(IDC_CHECK_ISA_AE_CORRECT)))->GetCheck() == BST_CHECKED;
 +    const auto aeTolerance = PerPart(GetDlgItemInt(IDC_EDIT_ISA_AE_RIGHT, NULL, FALSE), 1000);
 +    const int aeTgtLuma = GetDlgItemInt(IDC_EDIT_ISA_AE_BRIGHTNESS, NULL, FALSE);
 +    const PerPart aeHysteresis{GetDlgItemInt(IDC_EDIT_ISA_AE_HYSTERESIS, NULL, FALSE), 100};
 +    AE ae{m_fx3.sensor(), stats, aeTolerance, aeTgtLuma, aeHysteresis};
 +    const auto rez = ae(correct);
 +
 +    // display the information
 +    {
 +        const PerPart pxUsed{stats.ae.pixels, stats.total.pixels};
 +        CString msg;
 +        msg.AppendFormat(L"Pixels used: %d (%.1f%%)\n", stats.ae.pixels, pxUsed * 100);
 +        msg.AppendFormat(L"Under/over-exposed: %d/%d\n", rez.underExposed, rez.overExposed);
 +        msg.AppendFormat(L"BL adj.: %d\n", rez.adjBL);
 +        msg.AppendFormat(L"Avg Y.: %d\n", rez.avgY);
 +        msg.AppendFormat(L"Brightness adj.: %.2f\n", rez.adjY);
 +        msg += _corrOp2Txt(ae.details().op);
 +        SetDlgItemTextW(IDC_STATIC_ISA_AE, msg);
 +    }
 +}
 +</code>
 +
 +====== Initial values ======
 +
 +Following are the initial defaults for the variables that affect the process of automatic image brightness (Black Level, Exposure, Gains) adjustment:
 +^ Name (as seen in ''%%ImgAnalyzerDlg%%::_aeInfo()'' above) ^ Value ^
 +| ''aeTolerance'' | ''1/1000'' |
 +| ''aeTgtLuma'' | ''90'' |
 +| ''aeHysteresis'' | ''5/100'' |
 +| "center window" dimensions | ''50%'' vertically and horizontally, centered at image's center |

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information