Changed Linux timestamp behavior. Explicitly using CLOCK_MONOTONIC_RAW and CLOCK_REALTIME

This commit is contained in:
Matt Hill
2015-03-16 22:12:37 -04:00
parent f7ed84d5db
commit 39c4756ce7
20 changed files with 120 additions and 79 deletions

View File

@@ -286,7 +286,7 @@ void streamRecognitionThread(void* arg)
{ {
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
std::vector<AlprRegionOfInterest> regionsOfInterest; std::vector<AlprRegionOfInterest> regionsOfInterest;
regionsOfInterest.push_back(AlprRegionOfInterest(0,0, latestFrame.cols, latestFrame.rows)); regionsOfInterest.push_back(AlprRegionOfInterest(0,0, latestFrame.cols, latestFrame.rows));
@@ -294,7 +294,7 @@ void streamRecognitionThread(void* arg)
AlprResults results = alpr.recognize(latestFrame.data, latestFrame.elemSize(), latestFrame.cols, latestFrame.rows, regionsOfInterest); AlprResults results = alpr.recognize(latestFrame.data, latestFrame.elemSize(), latestFrame.cols, latestFrame.rows, regionsOfInterest);
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
double totalProcessingTime = diffclock(startTime, endTime); double totalProcessingTime = diffclock(startTime, endTime);
if (tdata->clock_on) if (tdata->clock_on)
@@ -304,10 +304,9 @@ void streamRecognitionThread(void* arg)
if (results.plates.size() > 0) if (results.plates.size() > 0)
{ {
long epoch_time = getEpochTime();
std::stringstream uuid_ss; std::stringstream uuid_ss;
uuid_ss << tdata->site_id << "-cam" << tdata->camera_id << "-" << epoch_time; uuid_ss << tdata->site_id << "-cam" << tdata->camera_id << "-" << getEpochTimeMs();
std::string uuid = uuid_ss.str(); std::string uuid = uuid_ss.str();
// Save the image to disk (using the UUID) // Save the image to disk (using the UUID)

View File

@@ -275,7 +275,7 @@ bool detectandshow( Alpr* alpr, cv::Mat frame, std::string region, bool writeJso
{ {
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
std::vector<AlprRegionOfInterest> regionsOfInterest; std::vector<AlprRegionOfInterest> regionsOfInterest;
regionsOfInterest.push_back(AlprRegionOfInterest(0,0, frame.cols, frame.rows)); regionsOfInterest.push_back(AlprRegionOfInterest(0,0, frame.cols, frame.rows));
@@ -283,7 +283,7 @@ bool detectandshow( Alpr* alpr, cv::Mat frame, std::string region, bool writeJso
AlprResults results = alpr->recognize(frame.data, frame.elemSize(), frame.cols, frame.rows, regionsOfInterest ); AlprResults results = alpr->recognize(frame.data, frame.elemSize(), frame.cols, frame.rows, regionsOfInterest );
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
double totalProcessingTime = diffclock(startTime, endTime); double totalProcessingTime = diffclock(startTime, endTime);
if (measureProcessingTime) if (measureProcessingTime)
std::cout << "Total Time to process image: " << totalProcessingTime << "ms." << std::endl; std::cout << "Total Time to process image: " << totalProcessingTime << "ms." << std::endl;

View File

@@ -187,18 +187,18 @@ int main( int argc, const char** argv )
string fullpath = inDir + "/" + files[i]; string fullpath = inDir + "/" + files[i];
frame = imread( fullpath.c_str() ); frame = imread( fullpath.c_str() );
getTime(&startTime); getTimeMonotonic(&startTime);
vector<Rect> regionsOfInterest; vector<Rect> regionsOfInterest;
regionsOfInterest.push_back(Rect(0, 0, frame.cols, frame.rows)); regionsOfInterest.push_back(Rect(0, 0, frame.cols, frame.rows));
alpr.recognize(frame, regionsOfInterest); alpr.recognize(frame, regionsOfInterest);
getTime(&endTime); getTimeMonotonic(&endTime);
double endToEndTime = diffclock(startTime, endTime); double endToEndTime = diffclock(startTime, endTime);
cout << " -- End to End recognition time: " << endToEndTime << "ms." << endl; cout << " -- End to End recognition time: " << endToEndTime << "ms." << endl;
endToEndTimes.push_back(endToEndTime); endToEndTimes.push_back(endToEndTime);
getTime(&startTime); getTimeMonotonic(&startTime);
vector<PlateRegion> regions = plateDetector->detect(frame); vector<PlateRegion> regions = plateDetector->detect(frame);
getTime(&endTime); getTimeMonotonic(&endTime);
double regionDetectionTime = diffclock(startTime, endTime); double regionDetectionTime = diffclock(startTime, endTime);
cout << " -- Region detection time: " << regionDetectionTime << "ms." << endl; cout << " -- Region detection time: " << regionDetectionTime << "ms." << endl;
@@ -209,18 +209,18 @@ int main( int argc, const char** argv )
PipelineData pipeline_data(frame, regions[z].rect, &config); PipelineData pipeline_data(frame, regions[z].rect, &config);
getTime(&startTime); getTimeMonotonic(&startTime);
stateIdentifier.recognize(&pipeline_data); stateIdentifier.recognize(&pipeline_data);
getTime(&endTime); getTimeMonotonic(&endTime);
double stateidTime = diffclock(startTime, endTime); double stateidTime = diffclock(startTime, endTime);
cout << "\tRegion " << z << ": State ID time: " << stateidTime << "ms." << endl; cout << "\tRegion " << z << ": State ID time: " << stateidTime << "ms." << endl;
stateIdTimes.push_back(stateidTime); stateIdTimes.push_back(stateidTime);
getTime(&startTime); getTimeMonotonic(&startTime);
LicensePlateCandidate lp(&pipeline_data); LicensePlateCandidate lp(&pipeline_data);
lp.recognize(); lp.recognize();
getTime(&endTime); getTimeMonotonic(&endTime);
double analysisTime = diffclock(startTime, endTime); double analysisTime = diffclock(startTime, endTime);
cout << "\tRegion " << z << ": Analysis time: " << analysisTime << "ms." << endl; cout << "\tRegion " << z << ": Analysis time: " << analysisTime << "ms." << endl;
@@ -228,16 +228,16 @@ int main( int argc, const char** argv )
{ {
lpAnalysisPositiveTimes.push_back(analysisTime); lpAnalysisPositiveTimes.push_back(analysisTime);
getTime(&startTime); getTimeMonotonic(&startTime);
ocr.performOCR(&pipeline_data); ocr.performOCR(&pipeline_data);
getTime(&endTime); getTimeMonotonic(&endTime);
double ocrTime = diffclock(startTime, endTime); double ocrTime = diffclock(startTime, endTime);
cout << "\tRegion " << z << ": OCR time: " << ocrTime << "ms." << endl; cout << "\tRegion " << z << ": OCR time: " << ocrTime << "ms." << endl;
ocrTimes.push_back(ocrTime); ocrTimes.push_back(ocrTime);
getTime(&startTime); getTimeMonotonic(&startTime);
ocr.postProcessor.analyze("", 25); ocr.postProcessor.analyze("", 25);
getTime(&endTime); getTimeMonotonic(&endTime);
double postProcessTime = diffclock(startTime, endTime); double postProcessTime = diffclock(startTime, endTime);
cout << "\tRegion " << z << ": PostProcess time: " << postProcessTime << "ms." << endl; cout << "\tRegion " << z << ": PostProcess time: " << postProcessTime << "ms." << endl;
postProcessTimes.push_back(postProcessTime); postProcessTimes.push_back(postProcessTime);

View File

@@ -55,7 +55,7 @@ namespace alpr
{ {
std::cerr << "file does not exist: " << filepath << std::endl; std::cerr << "file does not exist: " << filepath << std::endl;
AlprResults emptyResults; AlprResults emptyResults;
emptyResults.epoch_time = getEpochTime(); emptyResults.epoch_time = getEpochTimeMs();
emptyResults.img_width = 0; emptyResults.img_width = 0;
emptyResults.img_height = 0; emptyResults.img_height = 0;
emptyResults.total_processing_time_ms = 0; emptyResults.total_processing_time_ms = 0;

View File

@@ -72,12 +72,12 @@ namespace alpr
AlprFullDetails AlprImpl::recognizeFullDetails(cv::Mat img, std::vector<cv::Rect> regionsOfInterest) AlprFullDetails AlprImpl::recognizeFullDetails(cv::Mat img, std::vector<cv::Rect> regionsOfInterest)
{ {
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
AlprFullDetails response; AlprFullDetails response;
response.results.epoch_time = getEpochTime(); response.results.epoch_time = getEpochTimeMs();
response.results.img_width = img.cols; response.results.img_width = img.cols;
response.results.img_height = img.rows; response.results.img_height = img.rows;
@@ -126,7 +126,7 @@ namespace alpr
PipelineData pipeline_data(img, plateRegion.rect, config); PipelineData pipeline_data(img, plateRegion.rect, config);
timespec platestarttime; timespec platestarttime;
getTime(&platestarttime); getTimeMonotonic(&platestarttime);
LicensePlateCandidate lp(&pipeline_data); LicensePlateCandidate lp(&pipeline_data);
@@ -196,7 +196,7 @@ namespace alpr
} }
timespec plateEndTime; timespec plateEndTime;
getTime(&plateEndTime); getTimeMonotonic(&plateEndTime);
plateResult.processing_time_ms = diffclock(platestarttime, plateEndTime); plateResult.processing_time_ms = diffclock(platestarttime, plateEndTime);
if (plateResult.topNPlates.size() > 0) if (plateResult.topNPlates.size() > 0)
@@ -222,7 +222,7 @@ namespace alpr
} }
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
response.results.total_processing_time_ms = diffclock(startTime, endTime); response.results.total_processing_time_ms = diffclock(startTime, endTime);
if (config->debugTiming) if (config->debugTiming)

View File

@@ -29,7 +29,7 @@ namespace alpr
ColorFilter::ColorFilter(Mat image, Mat characterMask, Config* config) ColorFilter::ColorFilter(Mat image, Mat characterMask, Config* config)
{ {
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
this->config = config; this->config = config;
@@ -53,7 +53,7 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << " -- ColorFilter Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << " -- ColorFilter Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }
} }

View File

@@ -102,7 +102,7 @@ namespace alpr
//-- Detect plates //-- Detect plates
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
float maxWidth = ((float) w) * (config->maxPlateWidthPercent / 100.0f) * this->scale_factor; float maxWidth = ((float) w) * (config->maxPlateWidthPercent / 100.0f) * this->scale_factor;
float maxHeight = ((float) h) * (config->maxPlateHeightPercent / 100.0f) * this->scale_factor; float maxHeight = ((float) h) * (config->maxPlateHeightPercent / 100.0f) * this->scale_factor;
@@ -118,7 +118,7 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << "LBP Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << "LBP Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }

View File

@@ -98,7 +98,7 @@ namespace alpr
//-- Detect plates //-- Detect plates
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
float maxWidth = ((float) w) * (config->maxPlateWidthPercent / 100.0f) * this->scale_factor; float maxWidth = ((float) w) * (config->maxPlateWidthPercent / 100.0f) * this->scale_factor;
float maxHeight = ((float) h) * (config->maxPlateHeightPercent / 100.0f) * this->scale_factor; float maxHeight = ((float) h) * (config->maxPlateHeightPercent / 100.0f) * this->scale_factor;
@@ -121,7 +121,7 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << "LBP Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << "LBP Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }

View File

@@ -53,7 +53,7 @@ namespace alpr
cout << "PlateCorners::findPlateCorners" << endl; cout << "PlateCorners::findPlateCorners" << endl;
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
int horizontalLines = this->plateLines->horizontalLines.size(); int horizontalLines = this->plateLines->horizontalLines.size();
int verticalLines = this->plateLines->verticalLines.size(); int verticalLines = this->plateLines->verticalLines.size();
@@ -118,7 +118,7 @@ namespace alpr
if (pipelineData->config->debugTiming) if (pipelineData->config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << "Plate Corners Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << "Plate Corners Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }

View File

@@ -47,7 +47,7 @@ namespace alpr
cout << "PlateLines findLines" << endl; cout << "PlateLines findLines" << endl;
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
// Ignore input images that are pure white or pure black // Ignore input images that are pure white or pure black
@@ -129,7 +129,7 @@ namespace alpr
if (pipelineData->config->debugTiming) if (pipelineData->config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << "Plate Lines Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << "Plate Lines Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }

View File

@@ -69,7 +69,7 @@ namespace alpr
{ {
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
Mat originalCrop = pipeline_data->crop_gray; Mat originalCrop = pipeline_data->crop_gray;
@@ -113,7 +113,7 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << "deskew Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << "deskew Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }

View File

@@ -54,7 +54,7 @@ namespace alpr
void OCR::performOCR(PipelineData* pipeline_data) void OCR::performOCR(PipelineData* pipeline_data)
{ {
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
postProcessor.clear(); postProcessor.clear();
@@ -131,7 +131,7 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << "OCR Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << "OCR Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }
} }

View File

@@ -152,7 +152,7 @@ namespace alpr
void PostProcess::analyze(string templateregion, int topn) void PostProcess::analyze(string templateregion, int topn)
{ {
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
// Get a list of missing positions // Get a list of missing positions
for (int i = letters.size() -1; i >= 0; i--) for (int i = letters.size() -1; i >= 0; i--)
@@ -201,7 +201,7 @@ namespace alpr
findAllPermutations(tmp, 0, config->postProcessMaxSubstitutions); findAllPermutations(tmp, 0, config->postProcessMaxSubstitutions);
timespec sortStartTime; timespec sortStartTime;
getTime(&sortStartTime); getTimeMonotonic(&sortStartTime);
int numelements = topn; int numelements = topn;
if (allPossibilities.size() < topn) if (allPossibilities.size() < topn)
@@ -212,7 +212,7 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec sortEndTime; timespec sortEndTime;
getTime(&sortEndTime); getTimeMonotonic(&sortEndTime);
cout << " -- PostProcess Sort Time: " << diffclock(sortStartTime, sortEndTime) << "ms." << endl; cout << " -- PostProcess Sort Time: " << diffclock(sortStartTime, sortEndTime) << "ms." << endl;
} }
@@ -290,7 +290,7 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << "PostProcess Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << "PostProcess Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }

View File

@@ -40,7 +40,7 @@ namespace alpr
//CharacterRegion charRegion(img, debug); //CharacterRegion charRegion(img, debug);
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
if (pipeline_data->plate_inverted) if (pipeline_data->plate_inverted)
bitwise_not(pipeline_data->crop_gray, pipeline_data->crop_gray); bitwise_not(pipeline_data->crop_gray, pipeline_data->crop_gray);
@@ -110,7 +110,7 @@ namespace alpr
// Do the histogram analysis to figure out char regions // Do the histogram analysis to figure out char regions
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
vector<Mat> allHistograms; vector<Mat> allHistograms;
@@ -166,7 +166,7 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << " -- Character Segmentation Create and Score Histograms Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << " -- Character Segmentation Create and Score Histograms Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }
@@ -189,7 +189,7 @@ namespace alpr
} }
} }
getTime(&startTime); getTimeMonotonic(&startTime);
filterEdgeBoxes(pipeline_data->thresholds, candidateBoxes, medianCharWidth, avgCharHeight); filterEdgeBoxes(pipeline_data->thresholds, candidateBoxes, medianCharWidth, avgCharHeight);
candidateBoxes = filterMostlyEmptyBoxes(pipeline_data->thresholds, candidateBoxes); candidateBoxes = filterMostlyEmptyBoxes(pipeline_data->thresholds, candidateBoxes);
@@ -204,7 +204,7 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << " -- Character Segmentation Box cleaning/filtering Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << " -- Character Segmentation Box cleaning/filtering Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }
@@ -226,7 +226,7 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << "Character Segmenter Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << "Character Segmenter Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }
} }

View File

@@ -52,7 +52,7 @@ namespace alpr
bool StateIdentifier::recognize(PipelineData* pipeline_data) bool StateIdentifier::recognize(PipelineData* pipeline_data)
{ {
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
Mat plateImg = Mat(pipeline_data->grayImg, pipeline_data->regionOfInterest); Mat plateImg = Mat(pipeline_data->grayImg, pipeline_data->regionOfInterest);
@@ -75,7 +75,7 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << "State Identification Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << "State Identification Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }

View File

@@ -71,11 +71,24 @@ namespace alpr
return (0); return (0);
} }
void getTime(timespec* time) void getTimeMonotonic(timespec* time)
{ {
clock_gettime(0, time); clock_gettime(0, time);
} }
long getTimeMonotonicMs()
{
timespec time;
getTimeMonotonic(&time);
timespec time_start;
time_start.tv_sec = 0;
time_start.tv_nsec = 0;
return diffclock(time_start, time);
}
double diffclock(timespec time1,timespec time2) double diffclock(timespec time1,timespec time2)
{ {
timespec delta = diff(time1,time2); timespec delta = diff(time1,time2);
@@ -101,26 +114,48 @@ namespace alpr
} }
long getEpochTime() long getEpochTimeMs()
{ {
return std::time(0) * 1000; return std::time(0) * 1000;
} }
#else #else
void getTime(timespec* time) void _getTime(bool realtime, timespec* time)
{ {
#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time #ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
clock_serv_t cclock; clock_serv_t cclock;
mach_timespec_t mts; mach_timespec_t mts;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
clock_get_time(cclock, &mts); clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock); mach_port_deallocate(mach_task_self(), cclock);
time->tv_sec = mts.tv_sec; time->tv_sec = mts.tv_sec;
time->tv_nsec = mts.tv_nsec; time->tv_nsec = mts.tv_nsec;
#else #else
clock_gettime(CLOCK_MONOTONIC, time); if (realtime)
#endif clock_gettime(CLOCK_REALTIME, time);
else
clock_gettime(CLOCK_MONOTONIC, time);
#endif
}
// Returns a monotonic clock time unaffected by time changes (e.g., NTP)
// Useful for interval comparisons
void getTimeMonotonic(timespec* time)
{
_getTime(false, time);
}
long getTimeMonotonicMs()
{
timespec time;
getTimeMonotonic(&time);
timespec time_start;
time_start.tv_sec = 0;
time_start.tv_nsec = 0;
return diffclock(time_start, time);
} }
double diffclock(timespec time1,timespec time2) double diffclock(timespec time1,timespec time2)
@@ -148,13 +183,18 @@ namespace alpr
} }
long getEpochTime() // Returns wall clock time since Unix epoch (Jan 1, 1970)
long getEpochTimeMs()
{ {
struct timeval tp; timespec time;
gettimeofday(&tp, NULL); _getTime(true, &time);
long ms = tp.tv_sec * 1000 + tp.tv_usec / 1000;
timespec epoch_start;
epoch_start.tv_sec = 0;
epoch_start.tv_nsec = 0;
return diffclock(epoch_start, time);
return ms;
} }
#endif #endif

View File

@@ -26,10 +26,12 @@
namespace alpr namespace alpr
{ {
void getTime(timespec* time); void getTimeMonotonic(timespec* time);
long getTimeMonotonicMs();
double diffclock(timespec time1,timespec time2); double diffclock(timespec time1,timespec time2);
long getEpochTime(); long getEpochTimeMs();
} }

View File

@@ -56,7 +56,7 @@ namespace alpr
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
pipeline_data->textLines.clear(); pipeline_data->textLines.clear();
@@ -70,12 +70,12 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << " -- Character Analysis Find Contours Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << " -- Character Analysis Find Contours Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }
//Mat img_equalized = equalizeBrightness(img_gray); //Mat img_equalized = equalizeBrightness(img_gray);
getTime(&startTime); getTimeMonotonic(&startTime);
for (unsigned int i = 0; i < pipeline_data->thresholds.size(); i++) for (unsigned int i = 0; i < pipeline_data->thresholds.size(); i++)
{ {
@@ -88,7 +88,7 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << " -- Character Analysis Filter Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << " -- Character Analysis Filter Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }
@@ -206,7 +206,7 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << "Character Analysis Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << "Character Analysis Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }

View File

@@ -121,7 +121,7 @@ namespace alpr
//Mat img_equalized = equalizeBrightness(img_gray); //Mat img_equalized = equalizeBrightness(img_gray);
timespec startTime; timespec startTime;
getTime(&startTime); getTimeMonotonic(&startTime);
vector<Mat> thresholds; vector<Mat> thresholds;
@@ -160,7 +160,7 @@ namespace alpr
if (config->debugTiming) if (config->debugTiming)
{ {
timespec endTime; timespec endTime;
getTime(&endTime); getTimeMonotonic(&endTime);
cout << " -- Produce Threshold Time: " << diffclock(startTime, endTime) << "ms." << endl; cout << " -- Produce Threshold Time: " << diffclock(startTime, endTime) << "ms." << endl;
} }

View File

@@ -20,7 +20,7 @@ using namespace alpr;
TEST_CASE( "JSON Serialization/Deserialization", "[json]" ) { TEST_CASE( "JSON Serialization/Deserialization", "[json]" ) {
AlprResults origResults; AlprResults origResults;
origResults.epoch_time = getEpochTime(); origResults.epoch_time = getEpochTimeMs();
origResults.img_width = 640; origResults.img_width = 640;
origResults.img_height = 480; origResults.img_height = 480;
origResults.total_processing_time_ms = 100; origResults.total_processing_time_ms = 100;