mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 06:46:53 +08:00
Fixed error when ALPR loads a non-existant image file
This commit is contained in:
@@ -39,14 +39,28 @@ namespace alpr
|
|||||||
{
|
{
|
||||||
|
|
||||||
std::ifstream ifs(filepath.c_str(), std::ios::binary|std::ios::ate);
|
std::ifstream ifs(filepath.c_str(), std::ios::binary|std::ios::ate);
|
||||||
std::ifstream::pos_type pos = ifs.tellg();
|
|
||||||
|
|
||||||
std::vector<char> buffer(pos);
|
if (ifs)
|
||||||
|
{
|
||||||
|
std::ifstream::pos_type pos = ifs.tellg();
|
||||||
|
|
||||||
ifs.seekg(0, std::ios::beg);
|
std::vector<char> buffer(pos);
|
||||||
ifs.read(&buffer[0], pos);
|
|
||||||
|
|
||||||
return this->recognize( buffer );
|
ifs.seekg(0, std::ios::beg);
|
||||||
|
ifs.read(&buffer[0], pos);
|
||||||
|
|
||||||
|
return this->recognize( buffer );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "file does not exist: " << filepath << std::endl;
|
||||||
|
AlprResults emptyResults;
|
||||||
|
emptyResults.epoch_time = getEpochTime();
|
||||||
|
emptyResults.img_width = 0;
|
||||||
|
emptyResults.img_height = 0;
|
||||||
|
emptyResults.total_processing_time_ms = 0;
|
||||||
|
return emptyResults;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AlprResults Alpr::recognize(std::vector<char> imageBytes)
|
AlprResults Alpr::recognize(std::vector<char> imageBytes)
|
||||||
|
Reference in New Issue
Block a user