Merge pull request #74 from twelve17/gray_mat

Detect and use source grayscale mat if applicable.
This commit is contained in:
Matthew Hill
2015-01-06 22:31:55 -05:00
2 changed files with 19 additions and 4 deletions

View File

@@ -49,7 +49,15 @@ namespace alpr
{ {
Mat frame_gray; Mat frame_gray;
cvtColor( frame, frame_gray, CV_BGR2GRAY ); if (frame.channels() > 2)
{
cvtColor( frame, frame_gray, CV_BGR2GRAY );
}
else
{
frame_gray = frame;
}
vector<PlateRegion> detectedRegions; vector<PlateRegion> detectedRegions;
for (int i = 0; i < regionsOfInterest.size(); i++) for (int i = 0; i < regionsOfInterest.size(); i++)
@@ -128,4 +136,4 @@ namespace alpr
} }
} }

View File

@@ -5,11 +5,18 @@ using namespace std;
namespace alpr namespace alpr
{ {
PipelineData::PipelineData(Mat colorImage, Rect regionOfInterest, Config* config) PipelineData::PipelineData(Mat colorImage, Rect regionOfInterest, Config* config)
{ {
this->colorImg = colorImage; this->colorImg = colorImage;
cvtColor(this->colorImg, this->grayImg, CV_BGR2GRAY); if (colorImage.channels() > 2)
{
cvtColor(this->colorImg, this->grayImg, CV_BGR2GRAY);
}
else
{
this->grayImg = colorImage;
}
this->regionOfInterest = regionOfInterest; this->regionOfInterest = regionOfInterest;
this->config = config; this->config = config;