Ask Your Question

Ruby_Sheng's profile - activity

2016-12-17 21:02:35 -0600 commented answer I want to get the bright area of my picture(opencv3 Blob Detection)

I paste my code on the question :) thanks a lot

2016-12-17 20:58:06 -0600 commented answer I want to get the bright area of my picture(opencv3 Blob Detection)
  • the Scalar is really cool

    • however the image seems has no difference:( .......

    • maybe there's sth wrong with my blob code

2016-12-17 08:41:13 -0600 commented answer I want to get the bright area of my picture(opencv3 Blob Detection)

well... - palette is underlined by red line...

2016-12-17 02:20:47 -0600 asked a question I want to get the bright area of my picture(opencv3 Blob Detection)
  • I am using opencv3,
  • and I want to "circle" the bright area of the picture I read by using
  • Blob Detection

Be more specific, I want to "circle" the biggest red area.

image description

  • I checked this document

http://docs.opencv.org/master/d0/d7a/...

  • But I really don't know how to write the code...

Thank you very much.

  • this is my code
 #include <opencv2\opencv.hpp>
    #include <iostream>
        using namespace cv;
        using namespace std;


    int main()
    {
        Mat image = imread("reid.jpg");

        namedWindow("img");

        imshow("img", image);

        Mat dstImage;
        threshold(image, dstImage, 200, 255, 3);

        Mat element = getStructuringElement(MORPH_RECT, Size(15, 15));
        Mat out;
        erode(dstImage, out, element);

        Ptr<cv::SimpleBlobDetector> detector = cv::SimpleBlobDetector::create();
        std::vector<KeyPoint> keyImg;
        detector->detect(out, keyImg);

        Mat result;
        drawKeypoints(out, keyImg, result);

        int i = 0;
        for (vector<KeyPoint>::iterator k = keyImg.begin(); k != keyImg.end(); ++k, ++i)
            circle(result, k->pt, (int)k->size, Scalar(0,0,0)[i % 65536]);

        namedWindow("pic", WINDOW_AUTOSIZE);
        imshow("pic", result);

        waitKey(0);
    }
2016-12-05 01:33:43 -0600 commented answer questions in GMM...

Yeah~~~the problem is solved thanks a lot

2016-12-04 06:36:19 -0600 commented question questions in GMM...

-the background is in cv::Mat background;

  • the error is:
    • An unhandled exception (in GMM2.exe) at 0x00007FF7CACE282F: 0xC0000005: An access violation occurs when the location 0x0000000000000000 is read.
  • thanks
2016-12-03 18:27:36 -0600 asked a question questions in GMM...

Can anybody figure out what's going on with the code? I am using opencv310

 #include <opencv2\opencv.hpp>
#include <iostream>  
#include <string>  
using namespace cv;


int main(int argc, char** argv)
{
    std::string videoFile = "1.avi";

    VideoCapture capture;
    capture.open(videoFile);

    if (!capture.isOpened())
    {
        std::cout << "read video failure" << std::endl;
        return -1;
    }


   Ptr<BackgroundSubtractorMOG2> subtractor;

    cv::Mat foreground;
    cv::Mat background;

    cv::Mat frame;
    long frameNo = 0;
    while (capture.read(frame))
    {
        ++frameNo;

        std::cout << frameNo << std::endl;

        // 运动前景检测,并更新背景  
        subtractor->apply(frame, foreground, 0.001);

        // 腐蚀  
        cv::erode(foreground, foreground, cv::Mat());

        // 膨胀  
        cv::dilate(foreground, foreground, cv::Mat());



        cv::imshow("video", foreground);
        cv::imshow("background", background);


        if (cv::waitKey(25) > 0)
        {
            break;
        }
    }



    return 0;
}
2016-12-03 06:37:41 -0600 asked a question Debug Assertion failed in GMM

Thank you so much Derek~~

But as I run the project which I has posted before, It said

image description

the code

#include <opencv2\opencv.hpp>
using namespace cv;


int main(){
    VideoCapture video(0);
    Mat frame, mask, thresholdImage, output;
    Ptr<BackgroundSubtractorMOG2> subtractor = cv::createBackgroundSubtractorMOG2(20, 16, true);
    namedWindow("background");
    while (true){
        video >> frame;
        subtractor->apply(frame, mask, 0.001);
        imshow("background", mask);
        char c = (char)waitKey(20);
        if (c == 27)
            break;
    }
    return 0;
}
2016-12-03 05:47:24 -0600 commented question I have some problem with GMM

hello, I've changed it. And there are 2 errors.

  1. C2064
  2. IntelliSense: Calls a class type object without the appropriate operator () or converts the function to a type that points to a function
2016-12-03 05:47:04 -0600 received badge  Editor (source)
2016-12-03 04:45:06 -0600 asked a question I have some problem with GMM

this is my code

#include <opencv2\opencv.hpp>
using namespace cv;
int main(){
VideoCapture video(0);
Mat frame, mask, thresholdImage, output;
Ptr<BackgroundSubtractorMOG2> subtractor = cv::createBackgroundSubtractorMOG2(20, 16, true);
namedWindow("background");
while (true){
    video >> frame;
    subtractor(frame, mask, 0.001);
    imshow("background", mask);
    char c = (char)waitKey(20);
    if (c == 27)
        break;
}
return 0;
}

There's something wrong with "substractor". I really don't know what's going on with the "subtractor"...

thanks

p.s. I am using opencv310, maybe sth about the version?

2016-12-03 04:26:40 -0600 commented answer I tried to use function BackgroundSubstractorMOG2, but it didn't work

Thank you very much~

2016-12-03 03:45:52 -0600 commented question I tried to use function BackgroundSubstractorMOG2, but it didn't work

it's opencv310

2016-12-03 03:25:01 -0600 asked a question I tried to use function BackgroundSubstractorMOG2, but it didn't work

this is my code:

 Ptr<BackgroundSubtractorMOG2>cv::createBackgroundSubtractorMOG2
  (int history = 500, double varThreshold=16, bool detectShadows=true);

but the system showed that

 error C2572: “cv::createBackgroundSubtractorMOG2”:

I don't know how to fix it

thanks