Cleaned up API. No longer backwards compatible

This commit is contained in:
Matt Hill
2014-10-05 16:27:56 -04:00
parent fa96f53dbf
commit 396737bd3d
6 changed files with 121 additions and 86 deletions

View File

@@ -37,7 +37,7 @@ const std::string MAIN_WINDOW_NAME = "ALPR main window";
const bool SAVE_LAST_VIDEO_STILL = false;
const std::string LAST_VIDEO_STILL_LOCATION = "/tmp/laststill.jpg";
std::string getJson(Alpr* alpr, std::vector<AlprResult> results);
/** Function Headers */
bool detectandshow(Alpr* alpr, cv::Mat frame, std::string region, bool writeJson);
@@ -272,14 +272,15 @@ int main( int argc, const char** argv )
bool detectandshow( Alpr* alpr, cv::Mat frame, std::string region, bool writeJson)
{
std::vector<uchar> buffer;
cv::imencode(".bmp", frame, buffer );
timespec startTime;
getTime(&startTime);
std::vector<AlprResult> results = alpr->recognize(buffer);
std::vector<AlprRegionOfInterest> regionsOfInterest;
regionsOfInterest.push_back(AlprRegionOfInterest(0,0, frame.cols, frame.rows));
AlprResults results = alpr->recognize(frame.data, frame.elemSize(), frame.cols, frame.rows, regionsOfInterest );
timespec endTime;
getTime(&endTime);
double totalProcessingTime = diffclock(startTime, endTime);
@@ -289,27 +290,27 @@ bool detectandshow( Alpr* alpr, cv::Mat frame, std::string region, bool writeJso
if (writeJson)
{
std::cout << alpr->toJson(results, totalProcessingTime) << std::endl;
std::cout << alpr->toJson( results ) << std::endl;
}
else
{
for (int i = 0; i < results.size(); i++)
for (int i = 0; i < results.plates.size(); i++)
{
std::cout << "plate" << i << ": " << results[i].result_count << " results";
std::cout << "plate" << i << ": " << results.plates[i].result_count << " results";
if (measureProcessingTime)
std::cout << " -- Processing Time = " << results[i].processing_time_ms << "ms.";
std::cout << " -- Processing Time = " << results.plates[i].processing_time_ms << "ms.";
std::cout << std::endl;
for (int k = 0; k < results[i].topNPlates.size(); k++)
for (int k = 0; k < results.plates[i].topNPlates.size(); k++)
{
std::cout << " - " << results[i].topNPlates[k].characters << "\t confidence: " << results[i].topNPlates[k].overall_confidence << "\t template_match: " << results[i].topNPlates[k].matches_template << std::endl;
std::cout << " - " << results.plates[i].topNPlates[k].characters << "\t confidence: " << results.plates[i].topNPlates[k].overall_confidence << "\t template_match: " << results.plates[i].topNPlates[k].matches_template << std::endl;
}
}
}
return results.size() > 0;
return results.plates.size() > 0;
}