我遵循了使用OpenCV的ANPR算法的示例/教程。
我下载了c++示例代码,并将此代码移植到iOS应用程序上。
使用一些示例照片,此代码运行良好。
现在,我会使用iPhone相机拍摄照片以传递给ANPR算法,但我经常得到一个错误(所以也崩溃)。错误如下:
int area = floodFill(input, mask, seed, Scalar(255,0,0), &ccomp, Scalar(loDiff, loDiff, loDiff), Scalar(upDiff, upDiff, upDiff), flags);
OpenCV错误:cvFloodFill中不支持的格式或格式组合(),file/src/floodfill.cpp, 621行
floodFill函数在此上下文中使用:
Mat mask;
mask.create(input.rows + 2, input.cols + 2, CV_8UC1);
mask= Scalar::all(0);
int loDiff = 30;
int upDiff = 30;
int connectivity = 4;
int newMaskVal = 255;
int NumSeeds = 10;
cv::Rect ccomp;
int flags = connectivity + (newMaskVal << 8 ) + CV_FLOODFILL_FIXED_RANGE + CV_FLOODFILL_MASK_ONLY;
for(int j=0; j<NumSeeds; j++){
cv::Point seed;
seed.x=rects[i].center.x+rand()%(int)minSize-(minSize/2);
seed.y=rects[i].center.y+rand()%(int)minSize-(minSize/2);
circle(result, seed, 1, Scalar(0,255,255), -1);
int area = cv::floodFill(input, mask, seed, Scalar(255,0,0), &ccomp,
Scalar(loDiff, loDiff, loDiff), Scalar(upDiff, upDiff, upDiff), flags);
printf("%d",area);
}
一些建议吗?
尝试在floodfill
的输入中使用灰色图像(img_gray
代替input
)