Skip to content

Commit 5bbca68

Browse files
committed
bioinspired: add time measurement in sample
1 parent ca7683e commit 5bbca68

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

modules/bioinspired/samples/retinaDemo.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,23 @@ int main(int argc, char* argv[])
101101
cv::UMat retinaOutput_magno;
102102

103103
// processing loop with stop condition
104-
bool continueProcessing=true; // FIXME : not yet managed during process...
105-
while(continueProcessing)
104+
int64 totalTime = 0;
105+
int64 totalFrames = 0;
106+
while(true)
106107
{
107108
// if using video stream, then, grabbing a new frame, else, input remains the same
108109
if (videoCapture.isOpened())
109110
videoCapture>>inputFrame;
111+
if(inputFrame.empty())
112+
break;
110113

111114
// run retina filter
115+
int64 frameTime = cv::getTickCount();
112116
myRetina->run(inputFrame);
113117
// Retrieve and display retina output
118+
frameTime = cv::getTickCount() - frameTime;
119+
totalTime += frameTime;
120+
totalFrames++;
114121
myRetina->getParvo(retinaOutput_parvo);
115122
myRetina->getMagno(retinaOutput_magno);
116123
cv::imshow("retina input", inputFrame);
@@ -121,13 +128,12 @@ int main(int argc, char* argv[])
121128
if(key == 'q')
122129
break;
123130
}
124-
}catch(cv::Exception e)
131+
std::cout << "\nMean frame processing time: " << (totalTime / cv::getTickFrequency()) / totalFrames << " s" << std::endl;
132+
std::cout << "Retina demo end" << std::endl;
133+
}
134+
catch(const cv::Exception& e)
125135
{
126136
std::cerr<<"Error using Retina : "<<e.what()<<std::endl;
127137
}
128-
129-
// Program end message
130-
std::cout<<"Retina demo end"<<std::endl;
131-
132138
return 0;
133139
}

0 commit comments

Comments
 (0)