FontScanResult* FontScanJoiner::Scan(int32_t nCW, int32_t nCH, FontPattern::Ptr pPattern) { FontScanResult* pCurrentResult = mContext.CreateFontScanResult(); pCurrentResult->pattern = pPattern; for(auto& sample : pPattern->GetSamples()) { int32_t w = nCW + sample.w; int32_t h = nCH + sample.h; if(w >= mImage.width() || w < 0 || h >= mImage.height() || h < 0) { pCurrentResult->unMatched.emplace(w, h); } else if(Color::IsBackground(mImage(w, h, 0), mImage(w, h, 1), mImage(w, h, 2))) { pCurrentResult->unMatched.emplace(w, h); } else { pCurrentResult->matched.emplace(w, h); } } int32_t tolerateCount = pPattern->GetSampleCount() * TOLERATE_RATE; if(pCurrentResult->unMatched.size() <= tolerateCount) { return pCurrentResult; } return nullptr; }
position localizeOpticDisk(const cv::Mat *image, double windSize) { char meanImage[image->rows][image->cols]; for (int i = windSize + 1; i < image->rows; i++) { for (int j = windSize + 1; j < image->cols; j++) { meanImage[i][j] = image->at<cv::Vec3b>(i - windSize - 1, j - windSize - 1)[1] + image->at<cv::Vec3b>(i + windSize, j + windSize)[1] - image->at<cv::Vec3b>(i + windSize, j - windSize - 1)[1] - image->at<cv::Vec3b>(i - windSize - 1, j + windSize)[1]; } } cv::Mat mImage(image->rows, image->cols, 1, meanImage); mImage /= std::pow(windSize, 2); double min, max; cv::minMaxLoc(mImage, &min, &max); mImage = mImage == max; /* TODO: [X,Y] = find(meanIm); ind = 1; if (size(X,1)>1) x_seged = abs(X - (height/2)); [c ind]=min(x_seged); end x = X(ind); y = Y(ind); */ position pos; return pos; }