Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem using SimpleBlobDetector::detect

Hi there, I've got a function which takes two Mat as parameters, const imgIn and ImgOut. ImgIn is a thresholded binary (either 0xffffffff or 0xff000000) image with two with blobs in them (I threshold two neon green balls that I use as markers). I want to use SimpleBlobDetector as demonstrated there : https://www.learnopencv.com/blob-detection-using-opencv-python-c/ . The img_with_keypoints being my imgOut so I can display in other part of my program. No matter what I tried so far, I keep running into an unhandled exception at function call myDetector->detect(imgIn, keypoints) even if both parameters seems valid when debugging. The imgIn comes from my webcam and start as a QImage (AARRGGBB). I successfully translate it in Mat and use it in cv::erode function... Does anyone have any clue on what could cause that?

Here is my code, which is mainly copied from the tutorial.

    // Setup SimpleBlobDetector parameters.
    SimpleBlobDetector::Params params;

    params.filterByArea = true;
    params.minArea = 100;
    params.maxArea = 1000;
    params.filterByColor = true;
    params.blobColor = 255;

#if CV_MAJOR_VERSION < 3   // If you are using OpenCV 2

    // Set up detector with params
    SimpleBlobDetector detector(params);

    // You can use the detector this way
    // detector.detect( im, keypoints);

#else

    // Set up detector with params
    Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);

    // SimpleBlobDetector::create creates a smart pointer. 
    // So you need to use arrow ( ->) instead of dot ( . )
    // detector->detect( im, keypoints);

#endif
    std::vector<cv::KeyPoint> keypoints;

    detector->detect(imgIn, keypoints);

    // Draw detected blobs as red circles.
    // DrawMatchesFlags::DRAW_RICH_KEYPOINTS flag ensures the size of the circle corresponds to the size of blob
    Mat im_with_keypoints;
    drawKeypoints(imgIn, keypoints, im_with_keypoints, Scalar(0, 0, 255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
    imgOut = im_with_keypoints;

thank you for your time.

Problem using SimpleBlobDetector::detect

Hi there, I've got a function which takes two Mat as parameters, const imgIn and ImgOut. ImgIn is a thresholded binary (either 0xffffffff or 0xff000000) image with two with blobs in them (I threshold two neon green balls that I use as markers). I want to use SimpleBlobDetector as demonstrated there : https://www.learnopencv.com/blob-detection-using-opencv-python-c/ . The img_with_keypoints being my imgOut so I can display in other part of my program. No matter what I tried so far, I keep running into an unhandled exception at function call myDetector->detect(imgIn, keypoints) even if both parameters seems valid when debugging. The imgIn comes from my webcam and start as a QImage (AARRGGBB). I successfully translate it in Mat and use it in cv::erode function... Does anyone have any clue on what could cause that?

Here is my code, which is mainly copied from the tutorial.

void VR_BlobProcess::process(const Mat & imgIn, Mat & imgOut) { // Setup SimpleBlobDetector parameters. SimpleBlobDetector::Params params; params;

 params.filterByArea = true;
params.minArea = 100;
params.maxArea = 1000;
params.filterByColor = true;
params.blobColor = 255;
#if CV_MAJOR_VERSION < 3 // If you are using OpenCV 2
// Set up detector with params
SimpleBlobDetector detector(params);
// You can use the detector this way
// detector.detect( im, keypoints);
#else
// Set up detector with params
Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);
// SimpleBlobDetector::create creates a smart pointer.
// So you need to use arrow ( ->) instead of dot ( . )
// detector->detect( im, keypoints);
#endif
std::vector<cv::KeyPoint> keypoints;
detector->detect(imgIn, keypoints);
// Draw detected blobs as red circles.
// DrawMatchesFlags::DRAW_RICH_KEYPOINTS flag ensures the size of the circle corresponds to the size of blob
Mat im_with_keypoints;
drawKeypoints(imgIn, keypoints, im_with_keypoints, Scalar(0, 0, 255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
imgOut = im_with_keypoints;

} thank you for your time. time.

Problem using SimpleBlobDetector::detect

Hi there, I've got a function which takes two Mat as parameters, const imgIn and ImgOut. ImgIn is a thresholded binary (either 0xffffffff or 0xff000000) image with two with blobs in them (I threshold two neon green balls that I use as markers). I want to use SimpleBlobDetector as demonstrated there : https://www.learnopencv.com/blob-detection-using-opencv-python-c/ . The img_with_keypoints being my imgOut so I can display in other part of my program. No matter what I tried so far, I keep running into an unhandled exception at function call myDetector->detect(imgIn, keypoints) even if both parameters seems valid when debugging. The imgIn comes from my webcam and start as a QImage (AARRGGBB). I successfully translate it in Mat and use it in cv::erode function... Does anyone have any clue on what could cause that?

Here is my code, which is mainly copied from the tutorial.

void VR_BlobProcess::process(const Mat & imgIn, Mat & imgOut)
{
 // Setup SimpleBlobDetector parameters.
 SimpleBlobDetector::Params params;

params;
 params.filterByArea = true;
params.minArea = 100;
params.maxArea = 1000;
params.filterByColor = true;
params.blobColor = 255;
#if CV_MAJOR_VERSION < 3 // If you are using OpenCV 2
// Set up detector with params
SimpleBlobDetector detector(params);
// You can use the detector this way
// detector.detect( im, keypoints);
#else
// Set up detector with params
Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);
// SimpleBlobDetector::create creates a smart pointer.
// So you need to use arrow ( ->) instead of dot ( . )
// detector->detect( im, keypoints);
#endif
std::vector<cv::KeyPoint> keypoints;
detector->detect(imgIn, keypoints);
// Draw detected blobs as red circles.
// DrawMatchesFlags::DRAW_RICH_KEYPOINTS flag ensures the size of the circle corresponds to the size of blob
Mat im_with_keypoints;
drawKeypoints(imgIn, keypoints, im_with_keypoints, Scalar(0, 0, 255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
imgOut = im_with_keypoints;
}

} thank you for your time.

Problem using SimpleBlobDetector::detect

Hi there, I've got a function which takes two Mat as parameters, const imgIn and ImgOut. ImgIn is a thresholded binary (either 0xffffffff or 0xff000000) image with two with blobs in them (I threshold two neon green balls that I use as markers). I want to use SimpleBlobDetector as demonstrated there : https://www.learnopencv.com/blob-detection-using-opencv-python-c/ . The img_with_keypoints being my imgOut so I can display in other part of my program. No matter what I tried so far, I keep running into an unhandled exception at function call myDetector->detect(imgIn, keypoints) even if both parameters seems valid when debugging. The imgIn comes from my webcam and start as a QImage (AARRGGBB). I successfully translate it in Mat and use it in cv::erode function... Does anyone have any clue on what could cause that?

Here is my code, which is mainly copied from the tutorial.

void VR_BlobProcess::process(const Mat & imgIn, Mat & imgOut)
{
    // Setup SimpleBlobDetector parameters.
    SimpleBlobDetector::Params params;

    params.filterByArea = true;
    params.minArea = 100;
    params.maxArea = 1000;
    params.filterByColor = true;
    params.blobColor = 255;

#if CV_MAJOR_VERSION < 3   // If you are using OpenCV 2

    // Set up detector with params
    SimpleBlobDetector detector(params);

    // You can use the detector this way
    // detector.detect( im, keypoints);

#else

    // Set up detector with params
    Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);

    // SimpleBlobDetector::create creates a smart pointer. 
    // So you need to use arrow ( ->) instead of dot ( . )
    // detector->detect( im, keypoints);

#endif
    std::vector<cv::KeyPoint> keypoints;

    detector->detect(imgIn, keypoints);

    // Draw detected blobs as red circles.
    // DrawMatchesFlags::DRAW_RICH_KEYPOINTS flag ensures the size of the circle corresponds to the size of blob
    Mat im_with_keypoints;
    drawKeypoints(imgIn, keypoints, im_with_keypoints, Scalar(0, 0, 255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
    imgOut = im_with_keypoints;
}

EDIT: as asked, here is also the function used to convert QImage to Mat:

void VR_FrameGrabberProcess::process(const Mat &imgIn, Mat &imgOut)
{
    imgOut = qimage_to_mat_ref(currentFrame, QImage::Format_ARGB32);
}

// Pris sur http://qtandopencv.blogspot.ca/2013/08/how-to-convert-between-cvmat-and-qimage.html
Mat VR_FrameGrabberProcess::qimage_to_mat_ref(QImage &img, int format)
{
    return cv::Mat(img.height(), img.width(),format, img.bits(), img.bytesPerLine());
}

thank you for your time.