簡體   English   中英

改善OCR結果

[英]Improve OCR result

我正在基於視頻的車牌檢測技術開發項目。

它是這樣的: 在此處輸入圖片說明

當我想在車板上使用OCR時,我的問題就開始了。 我在一些圖片上進行了測試,效果非常好。 這是一些例子: 在此處輸入圖片說明

但是,當我把檢測到的盤子放進去時,結果非常糟糕:

在此處輸入圖片說明

因此,我想問您是否對我有一些建議,如何改善OCR結果?

這是我獲取二進制圖像的方式:

cv::Mat equalized;
    cv::equalizeHist(gray, equalized);
    cv::imshow("Hist. Eq.", equalized);

    /* Bilateral filter helps to improve the segmentation process */

    cv::Mat blur;
    cv::bilateralFilter(equalized, blur, 9, 75, 75);
    cv::imshow("Filter", blur);


    /* Threshold to binarize the image */

    cv::Mat thres;
    cv::adaptiveThreshold(blur, thres, 255, cv::ADAPTIVE_THRESH_GAUSSIAN_C, cv::THRESH_BINARY, 15, 2); //15, 2
    cv::imshow("Threshold", thres);

也許還有更多過濾器? 如果有幫助,我可以添加更多代碼。

我的第一個主意是用盤子做些更大的矯正。

這是我如何使用我的矩形獲得矢量:

std::vector< std::vector< cv::Point> > LP_contours;
    cv::findContours(img_threshold, LP_contours, 0, 1);
    std::vector<std::vector<cv::Point> > contours_poly(LP_contours.size());
    for (int ii = 0; ii < LP_contours.size(); ii++)
        if (LP_contours[ii].size() > 100 && contourArea(LP_contours[ii]) > 3000 && contourArea(LP_contours[ii]) < 10000) 
        {
            cv::approxPolyDP(cv::Mat(LP_contours[ii]), contours_poly[ii], 3, true);
            cv::Rect appRect(boundingRect(cv::Mat(contours_poly[ii])));

            if (appRect.width > appRect.height && appRect.width>160 && appRect.width < 190 && appRect.height>40 && appRect.height < 60)
                boundRect.push_back(appRect);
        }

我想通過簡單的代碼更改appRect的大小:

appRect.height += 10;
appRect.width += 10;

但這是行不通的。 我是openCV的新手,我對這類人員有疑問。 你有一些建議如何擴大規模嗎?

感謝您的所有時間和幫助。

這是一個簡化的代碼段,您可以手動更改boundRect參數以在openCV中獲得所需的ROI:

int main()
{
    cv::Mat image = cv::imread("car.jpg",0);

    cv::Rect boundRect{ 200,164,140,25 };
    cv::Mat cropped_image = image(boundRect);

    cv::namedWindow("Image");
    cv::imshow("Image", image);

    cv::namedWindow("Original cropped Image");
    cv::imshow("Original cropped Image", cropped_image);

    cv::Rect new_boundRect = boundRect;
    new_boundRect.x += 10;
    new_boundRect.y += 2;
    new_boundRect.width -= 10;
    new_boundRect.height -= 10;

    cv::Mat new_cropped_image = image(new_boundRect);
    cv::namedWindow("New cropped Image");
    cv::imshow("New cropped Image", new_cropped_image);

    cv::waitKey();
    return 0;
}

圖片:

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM