Commit 7968baf2 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

continuing fixing rgbd samples

parent ca2474be
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <opencv2/highgui.hpp> #include <opencv2/highgui.hpp>
#include <opencv2/calib3d.hpp> #include <opencv2/calib3d.hpp>
#include <opencv2/imgproc.hpp> #include <opencv2/imgproc.hpp>
#include <opencv2/core/utility.hpp>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
...@@ -48,6 +49,32 @@ using namespace cv::rgbd; ...@@ -48,6 +49,32 @@ using namespace cv::rgbd;
#define BILATERAL_FILTER 0// if 1 then bilateral filter will be used for the depth #define BILATERAL_FILTER 0// if 1 then bilateral filter will be used for the depth
class MyTickMeter
{
public:
MyTickMeter() { reset(); }
void start() { startTime = getTickCount(); }
void stop()
{
int64 time = getTickCount();
if ( startTime == 0 )
return;
++counter;
sumTime += ( time - startTime );
startTime = 0;
}
int64 getTimeTicks() const { return sumTime; }
double getTimeSec() const { return (double)getTimeTicks()/getTickFrequency(); }
int64 getCounter() const { return counter; }
void reset() { startTime = sumTime = 0; counter = 0; }
private:
int64 counter;
int64 sumTime;
int64 startTime;
};
static static
void writeResults( const string& filename, const vector<string>& timestamps, const vector<Mat>& Rt ) void writeResults( const string& filename, const vector<string>& timestamps, const vector<Mat>& Rt )
{ {
...@@ -154,7 +181,7 @@ int main(int argc, char** argv) ...@@ -154,7 +181,7 @@ int main(int argc, char** argv)
} }
odometry->set("cameraMatrix", cameraMatrix); odometry->set("cameraMatrix", cameraMatrix);
TickMeter gtm; MyTickMeter gtm;
int count = 0; int count = 0;
for(int i = 0; !file.eof(); i++) for(int i = 0; !file.eof(); i++)
{ {
...@@ -167,7 +194,7 @@ int main(int argc, char** argv) ...@@ -167,7 +194,7 @@ int main(int argc, char** argv)
// Read one pair (rgb and depth) // Read one pair (rgb and depth)
// example: 1305031453.359684 rgb/1305031453.359684.png 1305031453.374112 depth/1305031453.374112.png // example: 1305031453.359684 rgb/1305031453.359684.png 1305031453.374112 depth/1305031453.374112.png
#if BILATERAL_FILTER #if BILATERAL_FILTER
TickMeter tm_bilateral_filter; MyTickMeter tm_bilateral_filter;
#endif #endif
{ {
string rgbFilename = str.substr(timestampLength + 1, rgbPathLehgth ); string rgbFilename = str.substr(timestampLength + 1, rgbPathLehgth );
...@@ -213,7 +240,7 @@ int main(int argc, char** argv) ...@@ -213,7 +240,7 @@ int main(int argc, char** argv)
Mat Rt; Mat Rt;
if(!Rts.empty()) if(!Rts.empty())
{ {
TickMeter tm; MyTickMeter tm;
tm.start(); tm.start();
gtm.start(); gtm.start();
bool res = odometry->compute(frame_curr, frame_prev, Rt); bool res = odometry->compute(frame_curr, frame_prev, Rt);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment