diff --git a/src/openalpr/licenseplatecandidate.cpp b/src/openalpr/licenseplatecandidate.cpp index b8a107d..7159ebb 100644 --- a/src/openalpr/licenseplatecandidate.cpp +++ b/src/openalpr/licenseplatecandidate.cpp @@ -89,8 +89,11 @@ namespace alpr cv::Mat color_transmtx = cv::getPerspectiveTransform(projectedPoints, deskewed_points); cv::warpPerspective(pipeline_data->colorImg, pipeline_data->color_deskewed, color_transmtx, pipeline_data->color_deskewed.size()); - // Make a grayscale copy as well for faster processing downstream - cv::cvtColor(pipeline_data->color_deskewed, pipeline_data->crop_gray, CV_BGR2GRAY); + if (pipeline_data->color_deskewed.channels() > 2) + { + // Make a grayscale copy as well for faster processing downstream + cv::cvtColor(pipeline_data->color_deskewed, pipeline_data->crop_gray, CV_BGR2GRAY); + } if (this->config->debugGeneral) @@ -102,7 +105,7 @@ namespace alpr // to match the newly deskewed license plate crop vector newLines; for (unsigned int i = 0; i < pipeline_data->textLines.size(); i++) - { + { vector textArea = imgTransform.transformSmallPointsToBigImage(pipeline_data->textLines[i].textArea); vector linePolygon = imgTransform.transformSmallPointsToBigImage(pipeline_data->textLines[i].linePolygon);