Commit 5b706885 authored by Lorena García's avatar Lorena García

Channels check before cvtColor() function

parent 06b03a7b
......@@ -190,8 +190,15 @@ bool TrackerMedianFlowImpl::medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& old
std::vector<Point2f> pointsToTrackOld,pointsToTrackNew;
Mat oldImage_gray,newImage_gray;
cvtColor( oldImage, oldImage_gray, COLOR_BGR2GRAY );
cvtColor( newImage, newImage_gray, COLOR_BGR2GRAY );
if (oldImage.channels() != 1)
cvtColor( oldImage, oldImage_gray, COLOR_BGR2GRAY );
else
oldImage.copyTo(oldImage_gray);
if (newImage.channels() != 1)
cvtColor( newImage, newImage_gray, COLOR_BGR2GRAY );
else
newImage.copyTo(newImage_gray);
//"open ended" grid
for(int i=0;i<params.pointsInGrid;i++){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment