File: basicRetina.cpp

package info (click to toggle)
opencv 3.2.0%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 238,480 kB
  • sloc: xml: 901,650; cpp: 703,419; lisp: 20,142; java: 17,843; python: 17,641; ansic: 603; cs: 601; sh: 516; perl: 494; makefile: 117
file content (91 lines) | stat: -rw-r--r-- 4,372 bytes parent folder | download
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
//============================================================================
// Name        : retinademo.cpp
// Author      : Alexandre Benoit, benoit.alexandre.vision@gmail.com
// Version     : 0.1
// Copyright   : LISTIC/GIPSA French Labs, May 2015
// Description : Gipsa/LISTIC Labs quick retina demo in C++, Ansi-style
//============================================================================

// include bioinspired module and OpenCV core utilities
#include "opencv2/bioinspired.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
#include <cstring>

// main function
int main(int argc, char* argv[]) {

  // basic input arguments checking
  if (argc>1)
  {
        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 a webcam 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;
       
        if (strcmp(argv[1],  "help")==0){
	    std::cout<<"No help provided for now, please test the retina Demo for a more complete program"<<std::endl;
        }
  }

  std::string inputMediaType=argv[1];
  // declare the retina input buffer.
  cv::Mat inputFrame;
  // setup webcam reader and grab a first frame to get its size
  cv::VideoCapture videoCapture(0); 
  videoCapture>>inputFrame;

  // allocate a retina instance with input size equal to the one of the loaded image
  cv::Ptr<cv::bioinspired::Retina> myRetina = cv::bioinspired::createRetina(inputFrame.size());

  /* retina parameters management methods use sample
     -> save current (here default) retina parameters to a xml file (you may use it only one time to get the file and modify it)
  */
  myRetina->write("RetinaDefaultParameters.xml");

  // -> load parameters if file exists
  myRetina->setup("RetinaSpecificParameters.xml");

  // reset all retina buffers (open your eyes)  
  myRetina->clearBuffers();

  // declare retina output buffers
  cv::Mat retinaOutput_parvo;
  cv::Mat retinaOutput_magno;

  //main processing loop
  bool stillProcess=true;
  while(stillProcess){
	
	// if using video stream, then, grabbing a new frame, else, input remains the same
	if (videoCapture.isOpened())
		videoCapture>>inputFrame;
        else
		stillProcess=false;
	// 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);
  }

}