【解決方法】タスクサークルの検出と比較のために画像処理または機械学習を行うにはどうすればよいか


私は画像処理を行って画像から円を検出したいソフトウェアに取り組んでいます。検出したい円が 2 つあります。最初の円はオブジェクト (ダイヤモンドの粗い) 内にあり、2 番目の円は描画中です。画像またはビデオボックス。
これは、どのタイプの画像になるかについてのいくつかの画像です 画像1
画像2
画像3
画像4

上の画像の 1 つの赤い円は、いくつかのパラメーターを使用して描画しています。オブジェクト上の黒い円は、ビデオ ボックスに描画した円と比較または一致させるために検出したい円です。

検出が完了したら、描画中の円と画像処理から取得した円を比較または一致させたいと思います。

それで、2日間画像処理を試していますが、まだ期待する結果が得られません。
したがって、機械学習または AI について考えなければなりません
一致する円または一致しない円のデータセットを提供できれば、プロジェクトに AI または機械学習を使用できますか?
はいの場合、どのように使用できますか?また、これにはどれくらいの時間がかかりますか?

私が試したこと:

EmguCVライブラリを試して画像処理をしましたが、これはまだ正確ではありません、オブジェクト上の黒い円(粗いダイヤモンド)の検出だけで立ち往生しています

ここでemgucvを使用して画像処理を実行しましたが、必要な結果が得られませんでした
このコードを使用して得られた結果は次のとおりです。
画像1
画像2

注: すべての画像ではなく、一部の画像でも機能します。

C#
// Convert the image to grayscale
            Image<Gray, byte> grayImage = originalImage.Convert<Gray, byte>();
            pictureBox1.Image = grayImage.ToBitmap();


            // Apply Gaussian blur
            CvInvoke.GaussianBlur(grayImage, grayImage, new Size(5, 5), 0);
            pictureBox2.Image = grayImage.ToBitmap();

            // Threshold the grayscale image to isolate black circles
            double thresholdValue = 70; // Adjust this value based on the intensity of your black circles
            Image<Gray, byte> binaryImage = grayImage.ThresholdBinary(new Gray(thresholdValue), new Gray(255));
            pictureBox3.Image = binaryImage.ToBitmap();

            VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();
            Mat hierarchy = new Mat();

            CvInvoke.FindContours(binaryImage, contours, hierarchy, RetrType.List, ChainApproxMethod.ChainApproxSimple);

            // Loop through all detected contours
            for (int i = 0; i < contours.Size; i++)
            {
                using (VectorOfPoint contour = contours[i])
                {
                    double area = CvInvoke.ContourArea(contour);
                    double perimeter = CvInvoke.ArcLength(contour, true);

                    // Calculate circularity (4 * π * area / perimeter^2)
                    double circularity = (4 * Math.PI * area) / (perimeter * perimeter);

                    // Check if the contour is a perfect circle based on circularity
                    if (circularity > 0.8 && contour.Size > 150) // Adjust the circularity threshold and minimum number of vertices as needed
                    {
                        CircleF circle = CvInvoke.MinEnclosingCircle(contour);
                        originalImage.Draw(circle, new Bgr(Color.Red), 2); // You can change the color and thickness of the circle here
                    }
                }
            }

            pictureBox.Image = originalImage.ToBitmap();

解決策 1

こんにちは、
円を検出するには、Hough Circle Transform を探してください。

コメント

タイトルとURLをコピーしました