Fixed classify-chars misc utility bug caused by cropping outside of bounds of image

This commit is contained in:
Matt Hill
2015-06-29 23:41:33 -04:00
parent 70504a8718
commit 6d9d8201e1

View File

@@ -248,7 +248,13 @@ int main( int argc, const char** argv )
continue; continue;
stringstream filename; stringstream filename;
Mat cropped = pipeline_data.thresholds[t](pipeline_data.charRegions[c]);
// Ensure that crop rect does not extend beyond extent of image.
cv::Rect char_region = expandRect(pipeline_data.charRegions[c], 0, 0,
pipeline_data.thresholds[t].cols,
pipeline_data.thresholds[t].rows);
Mat cropped = pipeline_data.thresholds[t](char_region);
filename << outDir << "/" << humanInputs[c] << "-" << t << "-" << files[i]; filename << outDir << "/" << humanInputs[c] << "-" << t << "-" << files[i];
imwrite(filename.str(), cropped); imwrite(filename.str(), cropped);
cout << "Writing char image: " << filename.str() << endl; cout << "Writing char image: " << filename.str() << endl;