1
私はOpenBV 3.1を使用してSimpleBlobDetectorを使っていくつかのブロブ検出を行っていますが、私は運が無く、これを解決することはできません。私の環境はx64のXCodeです。opencvのSimpleBlobDetectorは何も検出しません
最後に、私は、バイナリイメージにそれを回すと、この上のブロブ検出を行います。
「iostream」と「opencv2/opencv.hpp」が含まれています。
using namespace cv;
using namespace std;
Mat img_rgb;
Mat img_gray;
Mat img_keypoints;
Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create();
vector<KeyPoint> keypoints;
img_rgb = imread("summertriangle.jpg");
//Convert to greyscale
cvtColor(img_rgb, img_gray, CV_RGB2GRAY);
imshow("Grey Scale", img_gray);
// Start by creating the matrix that will allocate the new image
Mat img_bw(img_gray.size(), img_gray.type());
// Apply threshhold to convert into binary image and save to new matrix
threshold(img_gray, img_bw, 100, 255, THRESH_BINARY);
// Extract cordinates of blobs at their centroids, save to keypoints variable.
detector->detect(img_bw, keypoints);
cout << "The size of keypoints vector is: " << keypoints.size();
キーポイントベクトルは常に空です。私が試したことは何もありません。
あなたのコードは 'SimpleBlobDetector'をまったく設定しません。デフォルト設定( 'minArea'、' maxArea'など)が処理している画像の種類には不適切である可能性があります。 – Dai
OpenCVのGithubのblob-detectorサンプルは、最初に 'pDefaultBLOB'パラメータオブジェクトを設定する方法を見てください:https://github.com/Itseez/opencv/blob/2f4e38c8313ff313de7c41141d56d945d91f47cf/samples/cpp/detect_blob.cpp – Dai
ありがとうDai - 私はいくつかのパラメータを設定しようとしました。私は 'minArea'を使って1に、' maxArea'を1000に設定しました。 –