Ask Your Question

how to add open cv blobs library in Visual studio 2013.

asked 2015-03-23 08:20:06 -0500

Dp gravatar image

updated 2015-03-23 11:59:30 -0500

theodore gravatar image

I am not able to add open cv blobs library with visual studio 2013, i need to calculate contourArea which needs blobs library ,how can i add those libraries. EDIT:-I had used all the instructions given below my contourArea() is still showing undefined,please help?

    #include <opencv2/opencv.hpp>


    using namespace std;
    using namespace cv;

   int main()
        // open the image   
        cv::Mat &image= cv::imread("cancer.jpg");
        vector<vector<Point> > contours;
        cv::Canny(image, // gray-level image
            contours, // output contours
            125, // low threshold

        for(unsigned int i=0;i<contours.size(),i++)
         cout << "# of contour points: " << contours[i].size() << endl ;

         for(unsigned int j=0;j<contours[i].size(),j++)
             cout << "Point(x,y)=" << contours[i][j] << endl;

         cout << " Area: " << contourArea(contours[i]) << endl;//its contourArea() is undefined

edit retag flag offensive close merge delete


you don't need that lib, since contourArea is already builtin in the imgproc module

berak gravatar imageberak ( 2015-03-23 08:42:23 -0500 )edit

i had already included that header file still its showing "contourArea() is undefined" Is function contourArea() declaration is wrong? if yes, how we need to declare that?

Dp gravatar imageDp ( 2015-03-23 08:51:17 -0500 )edit

cv::contourArea() ? include opencv2/imgproc/imgproc.hpp

you probably need to show your code, if we have to look for errors.

berak gravatar imageberak ( 2015-03-23 08:55:56 -0500 )edit

hey,Berak thanks for the reply i added the code above please check what exactly the problem is.

Dp gravatar imageDp ( 2015-03-23 09:12:21 -0500 )edit

looks like a namespace problem.

either do: using namespace cv; or use: cv::contourArea();

berak gravatar imageberak ( 2015-03-23 09:23:15 -0500 )edit

also: #include <opencv2/imgproc/imgproc.hpp>

berak gravatar imageberak ( 2015-03-23 09:24:29 -0500 )edit

That i had done,its some other issues please check?

Dp gravatar imageDp ( 2015-03-23 09:24:53 -0500 )edit

i don't know, what other issues you got.

berak gravatar imageberak ( 2015-03-23 09:30:40 -0500 )edit

Its still showing contourArea(),"identifier not found" what you said i had included? There is some packages problems or libraries is missing ? I am using open cv 2.4.10 with visual studio 2013.

Dp gravatar imageDp ( 2015-03-23 09:31:32 -0500 )edit

@Dp have you set the path where visual studio should find the opencv libraries?

theodore gravatar imagetheodore ( 2015-03-23 10:29:07 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-03-23 15:44:52 -0500

matman gravatar image

updated 2015-03-23 17:16:23 -0500

You can't use cv::contourArea with cv::Canny because you need a set of contour coordinates (X, Y). Canny will give you edge values (binary image). It will also rewrite your vector<vector<Point>> to cv::Mat inside the Canny function (InputArray), outside it can still look like a vector.

You have to use cv::findContours for that. Look here: Canny, here: Canny tutorial and here: findContours tutorial

Edit: I have answered your question here so why do you start a new question. And as I see, my crystal ball was right when it says that "you try to make contourArea() on your whole image"

edit flag offensive delete link more


thanks matman its working, thanks people you all helped me alot!

Dp gravatar imageDp ( 2015-03-25 04:55:35 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-03-23 08:20:06 -0500

Seen: 272 times

Last updated: Mar 23 '15