// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void readPipeline(QFilterParametersReader::Pointer paramsReader, FilterPipeline::Pointer pipeline) { FilterManager* filtManager = FilterManager::Instance(); QSettings* prefs = paramsReader->getPrefs(); prefs->beginGroup(DREAM3D::Settings::PipelineBuilderGroup); bool ok = false; int filterCount = prefs->value("Number_Filters").toInt(&ok); prefs->endGroup(); if (false == ok) {filterCount = 0;} for (int i = 0; i < filterCount; ++i) { QString gName = QString::number(i); // Open the group to get the name of the filter then close again. prefs->beginGroup(gName); QString filterName = prefs->value("Filter_Name", "").toString(); prefs->endGroup(); // qDebug() << filterName; IFilterFactory::Pointer factory = filtManager->getFactoryForFilter(filterName); AbstractFilter::Pointer filter = factory->create(); if(NULL != filter.get()) { filter->readFilterParameters(paramsReader.get(), i); pipeline->pushBack(filter); } } }
bool YbGetVideoRules(const std::wstring& filename) { FilterManager* m = FilterManager::getManager(); if(m == NULL) { return false; } return m->getVideoRules(filename); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- AbstractFilter::Pointer InstantiateFilter(QString filtName) { // Now instantiate the PhWriter Filter from the FilterManager FilterManager* fm = FilterManager::Instance(); IFilterFactory::Pointer filterFactory = fm->getFactoryForFilter(filtName); if (NULL == filterFactory.get() ) { std::stringstream ss; ss << "The OrientationTransformTest Requires the use of the " << filtName.toStdString() << " filter. Did the plugins load?"; DREAM3D_TEST_THROW_EXCEPTION(ss.str()) }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int TestFilterAvailability() { // Now instantiate the PhWriter Filter from the FilterManager QString filtName = "PhWriter"; FilterManager* fm = FilterManager::Instance(); IFilterFactory::Pointer filterFactory = fm->getFactoryForFilter(filtName); if (NULL == filterFactory.get() ) { std::stringstream ss; ss << "The PhIOTest Requires the use of the " << filtName.toStdString() << " filter which is found in the IO Plugin"; DREAM3D_TEST_THROW_EXCEPTION(ss.str()) }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int TestFilterAvailability() { // Now instantiate the ReadCtfData Filter from the FilterManager QString filtName = "ReadCtfData"; FilterManager* fm = FilterManager::Instance(); IFilterFactory::Pointer filterFactory = fm->getFactoryForFilter(filtName); if (NULL == filterFactory.get()) { std::stringstream ss; ss << "The CtfCachingTest requires the use of the " << filtName.toStdString() << " filter which is found in the OrientationAnalysis Plugin"; DREAM3D_TEST_THROW_EXCEPTION(ss.str()) }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int TestFilterAvailability() { // Now instantiate the FindDifferenceMapTest Filter from the FilterManager QString filtName = "ConditionalSetValue"; FilterManager* fm = FilterManager::Instance(); IFilterFactory::Pointer filterFactory = fm->getFactoryForFilter(filtName); if (NULL == filterFactory.get()) { std::stringstream ss; ss << "The ConditionalSetValueTest Requires the use of the " << filtName.toStdString() << " filter which is found in Core Filters"; DREAM3D_TEST_THROW_EXCEPTION(ss.str()) }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int DataContainerReader::readExistingPipelineFromFile(hid_t fileId) { herr_t err = 0; m_PipelineFromFile->clear(); H5FilterParametersReader::Pointer reader = H5FilterParametersReader::New(); // HDF5: Open the "Pipeline" Group hid_t pipelineGroupId = H5Gopen(fileId, DREAM3D::StringConstants::PipelineGroupName.toLatin1().data(), H5P_DEFAULT); reader->setPipelineGroupId(pipelineGroupId); // Use QH5Lite to ask how many "groups" are in the "Pipeline Group" QList<QString> groupList; err = QH5Utilities::getGroupObjects(pipelineGroupId, H5Utilities::H5Support_GROUP, groupList); // Loop over the items getting the "ClassName" attribute from each group QString classNameStr = ""; for (int32_t i = 0; i < groupList.size(); i++) { QString ss = QString::number(i, 10); err = QH5Lite::readStringAttribute(pipelineGroupId, ss, "ClassName", classNameStr); if (err < 0) { qDebug() << "Filter Index = " << i; } // Instantiate a new filter using the FilterFactory based on the value of the className attribute FilterManager* fm = FilterManager::Instance(); IFilterFactory::Pointer ff = fm->getFactoryForFilter(classNameStr); if (NULL != ff.get()) { AbstractFilter::Pointer filter = ff->create(); if (NULL != filter.get()) { // Read the parameters filter->readFilterParameters( reader.get(), i); // Add filter to m_PipelineFromFile m_PipelineFromFile->pushBack(filter); } } } err = H5Gclose(pipelineGroupId); return err; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void GenerateMatlabCode(const QString& outDir) { // Sanity check to make sure we have our output directory: QDir dir(outDir); dir.mkpath("."); // Get the FilterManager which will have a list of ALL of our FilterManager* fm = FilterManager::Instance(); FilterManager::Collection factories = fm->getFactories(); QMapIterator<QString, IFilterFactory::Pointer> iter(factories); // Loop on each filter while(iter.hasNext()) { iter.next(); IFilterFactory::Pointer factory = iter.value(); AbstractFilter::Pointer filter = factory->create(); GenerateCodeForFilter(outDir, filter); } }
int FilterManagerTEST::T_applyFilterChain() { int fail = 0; logger->trace("=============================="); logger->trace("Testing applyFilterChain():"); logger->trace(" Creating FM under normal mode..."); FilterManager* fm = new FilterManager("fm"); logger->trace(" Using factory, making 4 random filters..."); Filter* f1,*f2,*f3,*f4; f1 = FilterFactory::createFilter(); f2 = FilterFactory::createNullImgFilter(); f3 = FilterFactory::createNullFPGAFilter(); f4 = FilterFactory::createFilter(); logger->trace(" Inserting f1 as \"task 3\" to FRONT..."); fm->insertFilter("task 3",f1,"FRONT"); logger->trace(" Inserting f2 as \"task 1\"..."); fm->insertFilter("task 1",f2,"task 3"); logger->trace(" Inserting f3 as \"task 2\" between f1,f2..."); fm->insertFilter("task 2",f3,"task 3"); logger->trace(" Inserting f4 as \"task 4\" to REAR..."); fm->insertFilter("task 4",f4); logger->trace(" Making img objs..."); cv::Mat img = cv::Mat::zeros(2,2,CV_8UC1); ImgData* data = new ImgData("input",img); logger->trace(" Applying all filters..."); int res = fm->applyFilterChain(data); logger->trace(" Checking data ID..."); logger->trace(" "+data->getID()); if (data->getID() == "fm") logger->trace(" ok"); else { logger->warn(" NOT ok, ID not set!"); fail++; } logger->trace(" "+data->getTrack()+"error code "+std::to_string(res)); if (data->getTrack() == "task 1; task 2-1; task 3; task 4; ") if (res == 1) logger->trace(" ok"); else { logger->warn(" NOT ok, error code incorrect"); } else { logger->warn(" NOT ok, track record not expected"); } img.release(); delete data; delete fm; logger->trace("Testing complete."); if (fail > 0) logger->warn(" TEST FAILED: applyFilterChain"); logger->trace("=============================="); return fail; }
int main(int argc, char** argv) { QApplication app(argc, argv); MainWindow mw; mw.show(); #if 0 try { ImageSource * src; src = new ImageSource("test.jpg"); Image img = src->getImage(); FilterManager<CpuGrayFilter> filterCPU; filterCPU.process(img); std::cout<< "filter CPU time:" << filterCPU.getTime().total_microseconds() <<"us"<< std::endl; ImageWidget foo; foo.setImage(img); foo.setWindowTitle("Vis - CPU"); foo.show(); #ifdef USE_CUDA Image img2 = src->getImage(); FilterManager<GpuGrayFilter> filterGPU; filterGPU.process(img2); std::cout<< "filter GPU time:" << filterGPU.getTime().total_microseconds()<<"us" << std::endl; ImageWidget foo2; foo2.setImage(img2); foo2.setWindowTitle("Vis - GPU"); foo2.show(); #endif } catch(IException & ex) { std::cout <<ex.getMessage().toStdString() << std::endl; return 1; } #endif return app.exec(); }
int FilterManagerTEST::T_Constructor() { int fail = 0; logger->trace("=============================="); logger->trace("Testing FilterManager constructor:"); logger->trace(" Constructing normal mode fm under ID \"normal fm\"..."); FilterManager* fm = new FilterManager("normal fm"); logger->trace(" Complete."); logger->trace(" Accessing initialized parameters..."); logger->trace(" Using getFMID()..."); logger->trace(" "+fm->getFMID()); if (fm->getFMID() == "normal fm") logger->trace(" ok"); else { logger->warn(" NOT ok, fmID incorrect"); fail++; } logger->trace(" Using getCount()..."); logger->trace(" "+std::to_string(fm->getSizeOfFilterChain())); if (fm->getSizeOfFilterChain() == 0) logger->trace(" ok"); else { logger->warn(" NOT ok, size of filter chain not 0"); fail++; } logger->trace(" Using getMode()..."); if (fm->getMode() == 0) logger->trace(" ok"); else { logger->warn(" NOT ok: Mode incorrect"); fail += 1; } logger->trace(" Complete."); logger->trace(" Deleting \"normal fm\"..."); delete fm; logger->trace(" Constructing normal mode fm under ID \"auto fm\"..."); fm = new FilterManager("auto fm",1); logger->trace(" Complete."); logger->trace(" Accessing initialized parameters..."); logger->trace(" Using getFMID()..."); logger->trace(" "+fm->getFMID()); if (fm->getFMID() == "auto fm") logger->trace(" ok"); else { logger->warn(" NOT ok, fmID incorrect"); fail++; } logger->trace(" Using getCount()..."); logger->trace(" "+std::to_string(fm->getSizeOfFilterChain())); if (fm->getSizeOfFilterChain() == 0) logger->trace(" ok"); else { logger->warn(" NOT ok, size of filter chain not 0"); fail++; } logger->trace(" Using getMode()..."); if (fm->getMode() == 1) logger->trace(" ok"); else { logger->warn(" NOT ok: Mode incorrect"); fail += 1; } logger->trace(" Complete."); delete fm; logger->trace("Testing complete."); if (fail > 0) logger->warn(" TEST FAILED: FilterManager constructor"); logger->trace("=============================="); return fail; }
int FilterManagerTEST::T_replaceFilter() { int fail = 0; logger->trace("=============================="); logger->trace("Testing replaceFilter():"); logger->trace(" Test under custom ID mode..."); FilterManager* fm = new FilterManager("fm"); logger->trace(" Using factory, making 4 general filters..."); Filter* f1,*f2,*f3,*f4,*f5,*f6,*f7,*f8; f1 = FilterFactory::createFilter(); f2 = FilterFactory::createFilter(); f3 = FilterFactory::createFilter(); f4 = FilterFactory::createFilter(); f5 = FilterFactory::createNullImgFilter(); f6 = FilterFactory::createNullFPGAFilter(); f7 = FilterFactory::createFilter(); f8 = FilterFactory::createFilter(); logger->trace(" Inserting f1 as \"task 3\" to FRONT..."); fm->insertFilter("task 3",f1,"FRONT"); logger->trace(" Inserting f2 as \"task 1\"..."); fm->insertFilter("task 1",f2,"task 3"); logger->trace(" Inserting f3 as \"task 2\" between f1,f2..."); fm->insertFilter("task 2",f3,"task 3"); logger->trace(" Inserting f4 as \"task 4\" to REAR..."); fm->insertFilter("task 4",f4); logger->trace(" Replacing \"task 3\" with f5 under key \"task 5\"..."); fm->replaceFilter("task 5",f5,"task 3"); logger->trace(" Replacing \"FRONT\" with f2 under key \"task 6\"..."); fm->replaceFilter("task 6",f6,"FRONT"); logger->trace(" Using getFilterChainIDs()..."); std::vector<std::string> list = fm->getFilterChainIDs(); std::string res; for (std::vector<std::string>::iterator it = list.begin(); it != list.end(); it++) res += " "+*it; logger->trace(" "+res); if (res == " task 6 task 2 task 5 task 4") logger->trace(" ok"); else { logger->warn(" NOT ok, list unexpected"); fail += 1; } logger->trace(" Try replacing w/ non unique ID..."); res = std::to_string(fm->replaceFilter("task 5",f7,"task 5")); logger->trace(" error code: "+res); if (res == "2") logger->trace(" ok"); else { logger->warn(" NOT ok, incorrect error"); fail += 1; } logger->trace(" Try replacing out of range..."); res = std::to_string(fm->replaceFilter("task 8",f8,"what task?")); logger->trace(" error code: "+res); if (res == "1") logger->trace(" ok"); else { logger->warn(" NOT ok, incorrect error"); fail += 1; } logger->trace(" Try replacing using auto ID mode..."); res = std::to_string(fm->replaceFilter(f8,"task 2")); logger->trace(" error code: "+res); if (res == "4") logger->trace(" ok"); else { logger->warn(" NOT ok, incorrect error"); fail += 1; } delete fm; delete f7; delete f8; logger->trace(" Test under auto ID mode..."); fm = new FilterManager("fm",1); logger->trace(" Using factory..."); // Filter* f1,*f2,*f3,*f4,*f5,*f6,*f7,*f8; f1 = FilterFactory::createFilter(); f2 = FilterFactory::createFilter(); f3 = FilterFactory::createFilter(); f4 = FilterFactory::createFilter(); f5 = FilterFactory::createNullImgFilter(); f6 = FilterFactory::createNullFPGAFilter(); f7 = FilterFactory::createFilter(); f8 = FilterFactory::createFilter(); logger->trace(" Inserting f1 to FRONT..."); fm->insertFilter(f1,"FRONT"); logger->trace(" Inserting f2..."); fm->insertFilter(f2); logger->trace(" Inserting f3 between f1,f2..."); fm->insertFilter(f3,"2 GenericFilter"); logger->trace(" Inserting f4 to REAR..."); fm->insertFilter(f4,"REAR"); logger->trace(" Replacing \"2 GenericFilter\" with f5..."); fm->replaceFilter(f5,"2 GenericFilter"); logger->trace(" Replacing \"FRONT\" with f6..."); fm->replaceFilter(f6,"FRONT"); logger->trace(" Using getFilterChainIDs()..."); list = fm->getFilterChainIDs(); res = ""; for (std::vector<std::string>::iterator it = list.begin(); it != list.end(); it++) res += " "+*it; logger->trace(" "+res); if (res == " 6 NullFPGAFilter 3 GenericFilter 5 NullImgFilter 4 GenericFilter") logger->trace(" ok"); else { logger->warn(" NOT ok, list unexpected"); fail += 1; } logger->trace(" Try replacing out of range..."); res = std::to_string(fm->insertFilter(f7,"what task?")); logger->trace(" error code: "+res); if (res == "1") logger->trace(" ok"); else { logger->warn(" NOT ok, incorrect error"); fail += 1; } delete fm; delete f7; delete f8; logger->trace("Testing complete."); if (fail > 0) logger->warn(" TEST FAILED: replaceFilter()"); logger->trace("=============================="); return fail; }
int FilterManagerTEST::T_insertFilter() { int fail = 0; logger->trace("=============================="); logger->trace("Testing insertFilter():"); logger->trace(" Test under custom ID mode..."); FilterManager* fm = new FilterManager("fm"); logger->trace(" Using factory, making 4 general filters..."); Filter* f1,*f2,*f3,*f4,*f5; f1 = FilterFactory::createFilter(); f2 = FilterFactory::createFilter(); f3 = FilterFactory::createFilter(); f4 = FilterFactory::createFilter(); f5 = FilterFactory::createFilter(); logger->trace(" Inserting f1 as \"task 3\" to FRONT..."); fm->insertFilter("task 3",f1,"FRONT"); logger->trace(" Inserting f2 as \"task 1\"..."); fm->insertFilter("task 1",f2,"task 3"); logger->trace(" Inserting f3 as \"task 2\" between f1,f2..."); fm->insertFilter("task 2",f3,"task 3"); logger->trace(" Inserting f4 as \"task 4\" to REAR..."); fm->insertFilter("task 4",f4); logger->trace(" Using getFilterChainIDs()..."); std::vector<std::string> list = fm->getFilterChainIDs(); std::string res; for (std::vector<std::string>::iterator it = list.begin(); it != list.end(); it++) res += " "+*it; logger->trace(" "+res); if (res == " task 1 task 2 task 3 task 4") logger->trace(" ok"); else { logger->warn(" NOT ok, list unexpected"); fail += 1; } logger->trace(" Try inserting w/ non unique ID..."); res = std::to_string(fm->insertFilter("task 2",f5)); logger->trace(" error code: "+res); if (res == "2") logger->trace(" ok"); else { logger->warn(" NOT ok, incorrect error"); fail += 1; } logger->trace(" Try inserting out of range..."); res = std::to_string(fm->insertFilter("task 2",f5,"what task?")); logger->trace(" error code: "+res); if (res == "1") logger->trace(" ok"); else { logger->warn(" NOT ok, incorrect error"); fail += 1; } logger->trace(" Try inserting with no filterID arg..."); res = std::to_string(fm->insertFilter(f5,"Task 2")); logger->trace(" error code: "+res); if (res == "4") logger->trace(" ok"); else { logger->warn(" NOT ok, incorrect error"); fail += 1; } delete f5; delete fm; logger->trace(" Test under auto ID mode..."); fm = new FilterManager("fm",1); logger->trace(" Using factory, making 4 general filters..."); f1 = FilterFactory::createFilter(); f2 = FilterFactory::createFilter(); f3 = FilterFactory::createFilter(); f4 = FilterFactory::createFilter(); f5 = FilterFactory::createFilter(); logger->trace(" Inserting f1 to FRONT..."); fm->insertFilter(f1,"FRONT"); logger->trace(" Inserting f2..."); fm->insertFilter(f2); logger->trace(" Inserting f3 between f1,f2..."); fm->insertFilter(f3,"2 GenericFilter"); logger->trace(" Inserting f4 to REAR..."); fm->insertFilter(f4,"REAR"); res = ""; logger->trace(" Using getFilterChainIDs()..."); list = fm->getFilterChainIDs(); for (std::vector<std::string>::iterator it = list.begin(); it != list.end(); it++) res += " "+*it; logger->trace(" "+res); if (res == " 1 GenericFilter 3 GenericFilter 2 GenericFilter 4 GenericFilter") logger->trace(" ok"); else { logger->warn(" NOT ok, list unexpected"); fail += 1; } logger->trace(" Try inserting w/ custom ID..."); res = std::to_string(fm->insertFilter("task 2",f5)); logger->trace(" error code: "+res); if (res == "0") logger->trace(" ok"); else { logger->warn(" NOT ok, incorrect error"); fail += 1; } logger->trace(" Try inserting out of range..."); res = std::to_string(fm->insertFilter(f5,"what task?")); logger->trace(" error code: "+res); if (res == "1") logger->trace(" ok"); else { logger->warn(" NOT ok, incorrect error"); fail += 1; } logger->trace("Testing complete."); delete fm; if (fail > 0) logger->warn(" TEST FAILED: insertFilter()"); logger->trace("=============================="); return fail; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- FilterPipeline::Pointer JsonFilterParametersReader::ReadPipelineFromFile(QString filePath, IObserver* obs) { QFileInfo fInfo(filePath); if (filePath.isEmpty() == true) { return FilterPipeline::NullPointer(); } QFileInfo fi(filePath); if (fi.exists() == false) { return FilterPipeline::NullPointer(); } FilterManager* filtManager = FilterManager::Instance(); FilterFactory<EmptyFilter>::Pointer emptyFilterFactory = FilterFactory<EmptyFilter>::New(); filtManager->addFilterFactory("EmptyFilter", emptyFilterFactory); JsonFilterParametersReader::Pointer reader = JsonFilterParametersReader::New(); int err = reader->openFile(filePath); if (err < 0) { if (NULL != obs) { PipelineMessage pm(JsonFilterParametersReader::ClassName(), "File '" + fInfo.fileName() + "' could not be opened for reading.", -1, PipelineMessage::Error); obs->processPipelineMessage(pm); } return FilterPipeline::NullPointer(); } reader->openGroup(DREAM3D::Settings::PipelineBuilderGroup); int filterCount = reader->readValue(DREAM3D::Settings::NumFilters, 0); reader->closeGroup(); FilterPipeline::Pointer pipeline = FilterPipeline::New(); for (int i = 0; i < filterCount; ++i) { // Open the group to get the name of the filter then close again. reader->openFilterGroup(NULL, i); QString filterName = reader->readString(DREAM3D::Settings::FilterName, ""); reader->closeFilterGroup(); //qDebug() << "Group: " << gName << " FilterName: " << filterName; if (filterName.isEmpty() == false) { IFilterFactory::Pointer factory = filtManager->getFactoryForFilter(filterName); if (factory.get() != NULL) { AbstractFilter::Pointer filter = factory->create(); if (NULL != filter.get()) { filter->readFilterParameters(reader.get(), i); pipeline->pushBack(filter); } } else // Could not find the filter because the specific name has not been registered. This could // be due to a name change for the filter. { EmptyFilter::Pointer filter = EmptyFilter::New(); QString humanLabel = QString("UNKNOWN FILTER: ") + filterName; filter->setHumanLabel(humanLabel); filter->setOriginalFilterName(filterName); pipeline->pushBack(filter); if (NULL != obs) { QString ss = QObject::tr("An implementation for filter '%1' could not be located. Possible reasons include a name change of the filter, plugin not loading or a simple spelling mistake? A blank filter has been inserted in its place.").arg(filterName); PipelineMessage pm(filterName, ss, -66066, PipelineMessage::Error); pm.setPrefix("JsonFilterParametersReader::ReadPipelineFromFile()"); obs->processPipelineMessage(pm); } } } else { EmptyFilter::Pointer filter = EmptyFilter::New(); QString humanLabel = QString("MISSING FILTER: ") + filterName; filter->setHumanLabel(humanLabel); filter->setOriginalFilterName(filterName); pipeline->pushBack(filter); if (NULL != obs) { QString gName = QString::number(i); QString ss = QObject::tr("A filter for index '%1' is missing in the file. Is the numbering of the filters correct in the pipeline file?").arg(gName); PipelineMessage pm(filterName, ss, -66067, PipelineMessage::Error); pm.setPrefix("JsonFilterParametersReader::ReadPipelineFromFile()"); obs->processPipelineMessage(pm); } } } return pipeline; }
int RGBFilterTEST::T_filter() { int fail = 0; logger->trace("=============================="); logger->trace("Testing filter():"); // logger->trace(" Using imread..."); // cv::Mat img = cv::imread("rgb_mode_0.jpg",CV_LOAD_IMAGE_COLOR); // if (! img.data) // logger->warn(" OH NO, img not read"); logger->trace(" Using camCap..."); ImgDataTEST* imgTest = new ImgDataTEST(); cv::Mat img = imgTest->camCap(); cvDestroyWindow("camCap"); logger->trace(" Loading test image into a ImgData wrapper..."); ImgData* testImg = new ImgData("raw",img); logger->trace(" Copying ImgData to second wrapper..."); ImgData* testImg2 = new ImgData(*testImg); logger->trace(" Showing one copy of test image (should be named \"raw\")..."); testImg->showImg(); logger->trace(" Filtering first data w/ full luminosity specturm, aka mode 0..."); logger->trace(" Init int arr[3]..."); int arr[] = {25,-15,-20}; logger->trace(" Using filter factory, create mode 0 filter..."); RGBFilter* rgbFilter = new RGBFilter(arr);//(RGBFilter*)FilterFactory::createRGBFilter(arr); logger->trace(" Creating filter manager w/ id \"RGBFilter MODE 0\"..."); FilterManager* fm = new FilterManager("RGBFilter MODE 0"); logger->trace(" Inserting filter as \"rgb mode 0\"..."); fm->insertFilter("rgb mode 0",rgbFilter); logger->trace(" Attempt filtering using filter manager..."); fm->applyFilterChain(testImg); logger->trace(" Showing filtered test image..."); testImg->showImg(); logger->trace(" Expect 2 windows, \"raw\" and \"RGBFilter MODE 0\", the latter should be red shifted"); logger->trace(" If true, hit space, else hit esc"); char key; while (1) { key = cvWaitKey(0); if (char(key) == 32) { logger->trace(" ok"); break; } else if (char(key) == 27) { logger->warn(" NOT ok, details of output under mode 0 not correct"); fail++; break; } } logger->trace(" Filtering data 2 w/ 3 zones of luminosity separately, aka mode 1..."); logger->trace(" Init int high[3],mid[3],shad[3]..."); int high[] = {255,255,255}; int mid[] = {50,-30,-30}; int shad[] = {-255,-255,-255}; logger->trace(" Using filter factory, create mode 1 filter..."); RGBFilter* rgbFilter2 = new RGBFilter(high,mid,shad);//(RGBFilter*)FilterFactory::createRGBFilter(high,mid,shad); logger->trace(" Creating filter manager w/ id \"RGBFilter MODE 1\"..."); FilterManager* fm2 = new FilterManager("RGBFilter MODE 1"); logger->trace(" Inserting filter as \"rgb mode 1\"..."); fm2->insertFilter("rgb mode 1",rgbFilter2); logger->trace(" Attempt filtering using filter manager..."); fm2->applyFilterChain(testImg2); logger->trace(" Showing filtered test image..."); testImg2->showImg(); logger->trace(" Expect 3 windows in total, \"raw\" and \"RGBFilter MODE 0\" and \"RGBFilter MODE 1\", the latter should be red shifted, but a bit differently"); logger->trace(" If true, hit space, else hit esc"); while (1) { key = cvWaitKey(0); if (char(key) == 32) { logger->trace(" ok"); break; } else if (char(key) == 27) { logger->warn(" NOT ok, details of output under mode 1 not correct"); fail++; break; } } delete fm; delete fm2; cvDestroyWindow("raw"); testImg->closeImg(); testImg2->closeImg(); delete testImg; delete testImg2; img.release(); if (fail > 0) logger->warn(" TEST FAILED: filter()"); logger->trace("=============================="); return fail; }