pColorPacket CAtmoOutputFilter::Filtering(pColorPacket ColorPacket) { switch (m_pAtmoConfig->getLiveViewFilterMode()) { case afmNoFilter: return ColorPacket; break; case afmCombined: return MeanFilter(ColorPacket, false); break; case afmPercent: return PercentFilter(ColorPacket, false); break; } return ColorPacket; }
void CAtmoOutputFilter::ResetFilter(void) { // reset filter values MeanFilter(NULL, true); PercentFilter(NULL, true); }
int main( int argc, char** argv ) { printf( "Scale Space Cost Aggregation\n" ); if( argc != 11 ) { printf( "Usage: [CC_METHOD] [CA_METHOD] [PP_METHOD] [C_ALPHA] [lImg] [rImg] [lDis] [rDis] [maxDis] [disSc]\n" ); printf( "\nPress any key to continue...\n" ); getchar(); return -1; } string ccName = argv[ 1 ]; string caName = argv[ 2 ]; string ppName = argv[ 3 ]; double costAlpha = atof( argv[ 4 ] ); string lFn = argv[ 5 ]; string rFn = argv[ 6 ]; string lDisFn = argv[ 7 ]; string rDisFn = argv[ 8 ]; int maxDis = atoi( argv[ 9 ] ); int disSc = atoi( argv[ 10 ] ); // // Load left right image // printf( "\n--------------------------------------------------------\n" ); printf( "Load Image: (%s) (%s)\n", argv[ 5 ], argv[ 6 ] ); printf( "--------------------------------------------------------\n" ); Mat lImg = imread( lFn, CV_LOAD_IMAGE_COLOR ); Mat rImg = imread( rFn, CV_LOAD_IMAGE_COLOR ); if( !lImg.data || !rImg.data ) { printf( "Error: can not open image\n" ); printf( "\nPress any key to continue...\n" ); getchar(); return -1; } // set image format cvtColor( lImg, lImg, CV_BGR2RGB ); cvtColor( rImg, rImg, CV_BGR2RGB ); lImg.convertTo( lImg, CV_64F, 1 / 255.0f ); rImg.convertTo( rImg, CV_64F, 1 / 255.0f ); // time double duration; duration = static_cast<double>(getTickCount()); // // Stereo Match at each pyramid // int PY_LVL = 5; // build pyramid and cost volume Mat lP = lImg.clone(); Mat rP = rImg.clone(); SSCA** smPyr = new SSCA*[ PY_LVL ]; CCMethod* ccMtd = getCCType( ccName ); CAMethod* caMtd = getCAType( caName ); PPMethod* ppMtd = getPPType( ppName ); for( int p = 0; p < PY_LVL; p ++ ) { if( maxDis < 5 ) { PY_LVL = p; break; } printf( "\n\tPyramid: %d:", p ); smPyr[ p ] = new SSCA( lP, rP, maxDis, disSc ); smPyr[ p ]->CostCompute( ccMtd ); smPyr[ p ]->CostAggre( caMtd ); // pyramid downsample maxDis = maxDis / 2 + 1; disSc *= 2; pyrDown( lP, lP ); pyrDown( rP, rP ); } printf( "\n--------------------------------------------------------\n" ); printf( "\n Cost Aggregation in Scale Space\n" ); printf( "\n--------------------------------------------------------\n" ); // new method SolveAll( smPyr, PY_LVL, costAlpha ); // old method //for( int p = PY_LVL - 2 ; p >= 0; p -- ) { // smPyr[ p ]->AddPyrCostVol( smPyr[ p + 1 ], costAlpha ); //} // // Match + Postprocess // smPyr[ 0 ]->Match(); smPyr[ 0 ]->PostProcess( ppMtd ); Mat lDis = smPyr[ 0 ]->getLDis(); Mat rDis = smPyr[ 0 ]->getRDis(); #ifdef _DEBUG for( int s = 0; s < PY_LVL; s ++ ) { smPyr[ s ]->Match(); Mat sDis = smPyr[ s ]->getLDis(); ostringstream sStr; sStr << s; string sFn = sStr.str( ) + "_ld.png"; imwrite( sFn, sDis ); } saveOnePixCost( smPyr, PY_LVL ); #endif #ifdef USE_MEDIAN_FILTER // // Median Filter Output // MeanFilter( lDis, lDis, 3 ); #endif duration = static_cast<double>(getTickCount())-duration; duration /= cv::getTickFrequency(); // the elapsed time in sec printf( "\n--------------------------------------------------------\n" ); printf( "Total Time: %.2lf s\n", duration ); printf( "--------------------------------------------------------\n" ); // // Save Output // imwrite( lDisFn, lDis ); imwrite( rDisFn, rDis ); delete [] smPyr; delete ccMtd; delete caMtd; delete ppMtd; return 0; }