0

赤外線画像から瞳孔を検出し、瞳孔の中心を計算しようとしています。私のセットアップでは、赤外線に敏感なカメラを使用し、レンズに可視光フィルターを追加し、カメラの周りに 2 つの赤外線 LED を追加しました。ただし、得られた画像はぼやけています。これは、カメラの解像度が低く、最大で約 700x500 であることが原因である可能性があります。

処理では、最初にこの RGB イメージをグレー イメージに変換しましたが、結果はひどいものでした。結果には何もありませんでした。

int main()
{
    //load image
    cv::Mat src = cv::imread("11_13_2013_15_36_09.jpg");
    cvNamedWindow("original");
    cv::imshow("original", src);
    cv::waitKey(10);
    if (src.empty())
    {
        std::cout << "failed to find the image";
        return -1;
    }

    // Invert the source image and convert to graysacle
    cv::Mat gray;
    cv::cvtColor(~src, gray, CV_BGR2GRAY);
    cv::imshow("image1", gray);
    cv::waitKey(10);

    // Convert to binary image by thresholding it
    cv::threshold(gray, gray, 220, 255, cv::THRESH_BINARY);
    cv::imshow("image2", gray);
    cv::waitKey(10);

    // Find all contours
    std::vector<std::vector<cv::Point>>contours;
    cv::findContours(gray.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);

    // Fill holes in each contour
    cv::drawContours(gray, contours, -1, CV_RGB(255, 255, 255), -1);
    cv::imshow("image3", gray);
    cv::waitKey(10);
    for (int i = 0; i < contours.size(); i++)
    {
        double area = cv::contourArea(contours[i]);
        cv::Rect rect = cv::boundingRect(contours[i]);
        int radius = rect.width / 2;

        // If controu is big enough and has round shape
        // Then it is the pupil
        if (area >= 800 &&
            std::abs(1 - ((double)rect.width / (double)rect.height)) <= 0.3 &&
            std::abs(1 - (area / (CV_PI * std::pow(radius, 2)))) <= 0.3)
        {
            cv::circle(src, cv::Point(rect.x + radius, rect.y + radius), radius, CV_RGB(255, 0, 0), 2);
        }
    }
    cv::imshow("image", src);
    cvWaitKey(0);
}

元の画像が変換されたとき、灰色の画像がひどいのですが、これに対するより良い解決策を知っている人はいますか? 私はこれに完全に慣れていません。円を見つけるための残りのコードについて、コメントがあれば教えてください。また、元の画像に 2 つのグリント (光点) の位置を追加する必要があります。ありがとう。

4

1 に答える 1

0

しきい値を設定する前に、ソース画像のイコライズとフィルタリングを試してください;)

于 2014-01-23T04:36:40.867 に答える