Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I have problem with function Find Contours! what could be the problem?

I have very simple code. Upload an image and find a contour there. it should be so, but does not go

Code `

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include <iostream>
using namespace cv;
using namespace std;
        /// Global Variables
        Scalar color = Scalar(0,0,255);
int main(int argc, char** argv)
{
 Mat src;
src = imread("11.jpg");
 if(src.empty())
 {
        return -1;
 }
  Mat gray;
    cvtColor( src, gray, COLOR_BGR2GRAY );
    gray = gray > 127;
            // Find contours
            vector<vector<Point> > contours;
            vector<Point> contour;
            findContours( gray, contours, CV_RETR_TREE, CV_CHAIN_APPROX_NONE );
            for ( size_t i = 0; i < contours.size(); i++)
            {
            drawContours(src,contours,i,color);
            }
    imshow("gray", gray);
    imshow("src", src);
    waitKey(0);
    return 0;
}`

it showed me: http://www.pictureshack.ru/images/70238_12.jpg

but if I ignore the side with find contour, which is displayed as normal picture me.

I work with opencv3.0.0 and VS12.

what could be the problem?