我正在向我的iOS应用程序添加卡片扫描功能,并尝试添加眩光检测。因此,在扫描过程中检测到眩光时,系统会提示用户重新放置卡。
我尝试使用OpenCV实现它 https://www.pyimagesearch.com/2016/10/31/detecting-multiple-bright-spots-in-an-image-with-python-and-opencv/
https://www.pyimagesearch.com/2014/09/29/finding-brightest-spot-image-using-python-opencv/
Finding bright spots in a image using opencv
但是考虑到我对OpenCV和计算机视觉的了解很少,我无法获得理想的结果。
请正确地指导我如何使用OpenCV / CoreImage / GPUImage实现眩光检测。
到目前为止我的代码
+ (bool) imageHavingGlare:(CMSampleBufferRef)buffer {
cv::Mat matImage = [OpenCVWrapper matFromBuffer:buffer];
cv::Mat matImageGrey;
cv::cvtColor(matImage, matImageGrey, CV_BGRA2GRAY);
GaussianBlur(matImageGrey, matImageGrey, cvSize(11,11), 0);
cv::Mat matImageBinarized;
cv::threshold(matImageGrey, matImageBinarized, 30, 255, CV_THRESH_BINARY | CV_THRESH_OTSU);
double min, max;
cv::Point min_loc, max_loc;
cv::minMaxLoc(matImageBinarized, &min, &max, &min_loc, &max_loc);
if(((max_loc.x > 0) && (max_loc.y > 0)))
{
return true;
}
return false;
}