//============================================================================ // Name : retinademo.cpp // Author : Alexandre Benoit, benoit.alexandre.vision@gmail.com // Version : 0.1 // Copyright : LISTIC/GIPSA French Labs, july 2011 // Description : Gipsa/LISTIC Labs retina demo in C++, Ansi-style //============================================================================ #include #include #include "opencv2/bioinspired.hpp" #include "opencv2/highgui.hpp" static void help(std::string errorMessage) { std::cout<<"Program init error : "< It applies a spectral whithening (mid-frequency details enhancement)"< high frequency spatio-temporal noise reduction"< low frequency luminance to be reduced (luminance range compression)"< local logarithmic luminance compression allows details to be enhanced in low light conditions\n"< reports comments/remarks at benoit.alexandre.vision@gmail.com"< more informations and papers at : http://sites.google.com/site/benoitalexandrevision/"< you can use this to fine tune parameters and load them if you save to file 'RetinaSpecificParameters.xml'"<= 3) { std::cout<<"RetinaDemo: processing image "<>inputFrame; }else { // bad command parameter help("bad command parameter"); return -1; } if (inputFrame.empty()) { help("Input media could not be loaded, aborting"); return -1; } ////////////////////////////////////////////////////////////////////////////// // Program start in a try/catch safety context (Retina may throw errors) try { // create a retina instance with default parameters setup, uncomment the initialisation you wanna test cv::Ptr myRetina; // if the last parameter is 'log', then activate log sampling (favour foveal vision and subsamples peripheral vision) if (useLogSampling) { myRetina = cv::bioinspired::createRetina(inputFrame.size(), true, cv::bioinspired::RETINA_COLOR_BAYER, true, 2.0, 10.0); } else// -> else allocate "classical" retina : myRetina = cv::bioinspired::createRetina(inputFrame.size()); // save default retina parameters file in order to let you see this and maybe modify it and reload using method "setup" myRetina->write("RetinaDefaultParameters.xml"); // load parameters if file exists myRetina->setup("RetinaSpecificParameters.xml"); myRetina->clearBuffers(); // declare retina output buffers cv::Mat retinaOutput_parvo; cv::Mat retinaOutput_magno; // processing loop with stop condition bool continueProcessing=true; // FIXME : not yet managed during process... while(continueProcessing) { // if using video stream, then, grabbing a new frame, else, input remains the same if (videoCapture.isOpened()) videoCapture>>inputFrame; // run retina filter myRetina->run(inputFrame); // Retrieve and display retina output myRetina->getParvo(retinaOutput_parvo); myRetina->getMagno(retinaOutput_magno); cv::imshow("retina input", inputFrame); cv::imshow("Retina Parvo", retinaOutput_parvo); cv::imshow("Retina Magno", retinaOutput_magno); cv::waitKey(5); } }catch(cv::Exception e) { std::cerr<<"Error using Retina : "<