1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
#include "opencv2/opencv.hpp" #include "opencv2/bioinspired/retina.hpp" #include <cstring> #include <iostream>
static void help(std::string errorMessage) { std::cout << "Program init error : " << errorMessage << std::endl; std::cout << "\nProgram call procedure : retinaDemo [processing mode] [Optional : media " "target] [Optional LAST parameter: \"log\" to activate retina log sampling]" << std::endl; std::cout << "\t[processing mode] :" << std::endl; std::cout << "\t -image : for still image processing" << std::endl; std::cout << "\t -video : for video stream processing" << std::endl; std::cout << "\t[Optional : media target] :" << std::endl; std::cout << "\t if processing an image or video file, then, specify the path and filename of " "the target to process" << std::endl; std::cout << "\t leave empty if processing video stream coming from a connected video device" << std::endl; std::cout << "\t[Optional : activate retina log sampling] : an optional last parameter can be " "specified for retina spatial log sampling" << std::endl; std::cout << "\t set \"log\" without quotes to activate this sampling, output frame size will " "be divided by 4" << std::endl; std::cout << "\nExamples:" << std::endl; std::cout << "\t-Image processing : ./retinaDemo -image lena.jpg" << std::endl; std::cout << "\t-Image processing with log sampling : ./retinaDemo -image lena.jpg log" << std::endl; std::cout << "\t-Video processing : ./retinaDemo -video myMovie.mp4" << std::endl; std::cout << "\t-Live video processing : ./retinaDemo -video" << std::endl; std::cout << "\nPlease start again with new parameters" << std::endl; }
int main(int argc, char *argv[]) { std::cout << "****************************************************" << std::endl; std::cout << "* Retina demonstration : demonstrates the use of is a wrapper class of the " "Gipsa/Listic Labs retina model." << std::endl; std::cout << "* This retina model allows spatio-temporal image processing (applied on still " "images, video sequences)." << std::endl; std::cout << "* As a summary, these are the retina model properties:" << std::endl; std::cout << "* => It applies a spectral whithening (mid-frequency details enhancement)" << std::endl; std::cout << "* => high frequency spatio-temporal noise reduction" << std::endl; std::cout << "* => low frequency luminance to be reduced (luminance range compression)" << std::endl; std::cout << "* => local logarithmic luminance compression allows details to be enhanced in " "low light conditions\n" << std::endl; std::cout << "* for more information, reer to the following papers :" << std::endl; std::cout << "* Benoit A., Caplier A., Durette B., Herault, J., \"USING HUMAN VISUAL SYSTEM " "MODELING FOR BIO-INSPIRED LOW LEVEL IMAGE PROCESSING\", Elsevier, Computer " "Vision and Image Understanding 114 (2010), pp. 758-773, DOI: " "http://dx.doi.org/10.1016/j.cviu.2010.01.011" << std::endl; std::cout << "* Vision: Images, Signals and Neural Networks: Models of Neural Processing in " "Visual Perception (Progress in Neural Processing),By: Jeanny Herault, ISBN: " "9814273686. WAPI (Tower ID): 113266891." << std::endl; std::cout << "* => reports comments/remarks at benoit.alexandre.vision@gmail.com" << std::endl; std::cout << "* => more informations and papers at : " "http://sites.google.com/site/benoitalexandrevision/" << std::endl; std::cout << "****************************************************" << std::endl; std::cout << " NOTE : this program generates the default retina parameters file " "'RetinaDefaultParameters.xml'" << std::endl; std::cout << " => you can use this to fine tune parameters and load them if you save to file " "'RetinaSpecificParameters.xml'" << std::endl;
cv::Mat inputFrame; cv::VideoCapture videoCapture;
inputFrame = cv::imread("box_in_scene.png", 1);
if (inputFrame.empty()) { help("Input media could not be loaded, aborting"); return -1; }
try { cv::Ptr<cv::bioinspired::Retina> myRetina = cv::bioinspired::Retina::create(inputFrame.size(), true, cv::bioinspired::RETINA_COLOR_BAYER, true, 2.0, 10.0);
myRetina->write("RetinaDefaultParameters.xml");
myRetina->setup("RetinaSpecificParameters.xml"); myRetina->clearBuffers();
cv::Mat retinaOutput_parvo; cv::Mat retinaOutput_magno;
bool continueProcessing = true; while (continueProcessing) { if (videoCapture.isOpened()) videoCapture >> inputFrame;
myRetina->run(inputFrame); 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(10); } } catch (cv::Exception e) { std::cerr << "Error using Retina : " << e.what() << std::endl; }
std::cout << "Retina demo end" << std::endl;
return 0; }
|