From c389561754db39880aca3a8646af24f27c8a52e8 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Mon, 2 Jun 2014 20:52:28 -0400 Subject: [PATCH] Check for invalid images before attempting to detect --- src/openalpr/alpr_impl.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/openalpr/alpr_impl.cpp b/src/openalpr/alpr_impl.cpp index 156734d..c9a4ad0 100644 --- a/src/openalpr/alpr_impl.cpp +++ b/src/openalpr/alpr_impl.cpp @@ -70,6 +70,15 @@ std::vector AlprImpl::recognize(cv::Mat img) getTime(&startTime); + if (!img.data) + { + // Invalid image + if (this->config->debugGeneral) + std::cerr << "Invalid image" << std::endl; + + vector emptyVector; + return emptyVector; + } // Find all the candidate regions vector plateRegions = plateDetector->detect(img);