Ask Your Question

Revision history [back]

Why Canny can not detect connected contour of black square on a white background?

Simple code don't give connected contour. No top or bottom edge instead. Result printscreen is square-bug.png . The picture itself is square.png. Code is:

   void test(){
        UMat img = imread("./square.png", IMREAD_COLOR).getUMat(ACCESS_READ);
        UMat imgGray, imgGrayEdges3, imgGrayEdges5;
        cvtColor(img, imgGray, CV_BGR2GRAY);
        Canny(imgGray, imgGrayEdges3, 50, 150, 3);
        Canny(imgGray, imgGrayEdges5, 300, 2000, 5); // why so large thresholds?..
        cout << imgGray.getMat(ACCESS_READ) << "\n" << imgGrayEdges3.getMat(ACCESS_READ) << "\n" << imgGrayEdges5.getMat(ACCESS_READ) ;
        imshow("img", img);
        imshow("canny3", imgGrayEdges3);
        imshow("canny5", imgGrayEdges5);
        waitKey();
    }

Am I doing something wrong?

Why Canny can not detect connected contour of black square on a white background?

Simple code don't give connected contour. No top or bottom edge instead. Result printscreen is square-bug.png . The picture itself is square.png. Code is:

   void test(){
        UMat img = imread("./square.png", IMREAD_COLOR).getUMat(ACCESS_READ);
        UMat imgGray, imgGrayEdges3, imgGrayEdges5;
        cvtColor(img, imgGray, CV_BGR2GRAY);
        Canny(imgGray, imgGrayEdges3, 50, 150, 3);
        Canny(imgGray, imgGrayEdges5, 300, 2000, 5); // why so large thresholds?..
        cout << imgGray.getMat(ACCESS_READ) << "\n" << imgGrayEdges3.getMat(ACCESS_READ) << "\n" << imgGrayEdges5.getMat(ACCESS_READ) ;
        imshow("img", img);
        imshow("canny3", imgGrayEdges3);
        imshow("canny5", imgGrayEdges5);
        waitKey();
    }

Am I doing something wrong?

I use OpenCV3-beta in Eclipse under Win8.1 and have to build source from git. Due to http://code.opencv.org/issues/4087 I use 4 weeks old source, but last changes in canny.cpp was 7 weeks ago.

Why Canny can not detect connected contour of black square on a white background?

Simple code don't give for simple image result is not connected contour. No top contour as it is expected. Top or bottom edge instead. missed. Result printscreen is square-bug.png . The picture itself is square.png. Code is:

   void test(){
        UMat img = imread("./square.png", IMREAD_COLOR).getUMat(ACCESS_READ);
        UMat imgGray, imgGrayEdges3, imgGrayEdges5;
        cvtColor(img, imgGray, CV_BGR2GRAY);
        Canny(imgGray, imgGrayEdges3, 50, 150, 3);
        Canny(imgGray, imgGrayEdges5, 300, 2000, 5); // why so large thresholds?..
        cout << imgGray.getMat(ACCESS_READ) << "\n" << imgGrayEdges3.getMat(ACCESS_READ) << "\n" << imgGrayEdges5.getMat(ACCESS_READ) ;
        imshow("img", img);
        imshow("canny3", imgGrayEdges3);
        imshow("canny5", imgGrayEdges5);
        waitKey();
    }

Am I doing something wrong?

I use OpenCV3-beta in Eclipse under Win8.1 and have to build source from git. Due to http://code.opencv.org/issues/4087 I use 4 weeks old source, but last changes in canny.cpp was 7 weeks ago.

Why Canny can not detect connected contour of black square on a white background?

Simple code for simple image result is not connected contour as it is expected. Top or bottom edge missed. Result printscreen is square-bug.png . The picture itself is square.png. Code is:

   void test(){
        UMat img = imread("./square.png", IMREAD_COLOR).getUMat(ACCESS_READ);
        UMat imgGray, imgGrayEdges3, imgGrayEdges5;
        cvtColor(img, imgGray, CV_BGR2GRAY);
        Canny(imgGray, imgGrayEdges3, 50, 150, 3);
        Canny(imgGray, imgGrayEdges5, 300, 2000, 5); // why so large thresholds?..
        cout << imgGray.getMat(ACCESS_READ) << "\n" << imgGrayEdges3.getMat(ACCESS_READ) << "\n" << imgGrayEdges5.getMat(ACCESS_READ) ;
        imshow("img", img);
        imshow("canny3", imgGrayEdges3);
        imshow("canny5", imgGrayEdges5);
        waitKey();
    }

Am I doing something wrong?

I use OpenCV3-beta in Eclipse under Win8.1 and have to build source from git. Due to http://code.opencv.org/issues/4087 I use 4 weeks old source, but last changes in Source updated and compiled today (last canny.cpp change was 7 weeks ago.ago).

Why Canny (OCL) can not detect connected contour of black square on a white background?

Simple code for simple image result is not connected contour as it is expected. Top or bottom edge missed. Result printscreen is square-bug.png . The picture itself is square.png. Code is:

   void test(){
        UMat img = imread("./square.png", IMREAD_COLOR).getUMat(ACCESS_READ);
        UMat imgGray, imgGrayEdges3, imgGrayEdges5;
        cvtColor(img, imgGray, CV_BGR2GRAY);
        Canny(imgGray, imgGrayEdges3, 50, 150, 3);
        Canny(imgGray, imgGrayEdges5, 300, 2000, 5); // why so large thresholds?..
        cout << imgGray.getMat(ACCESS_READ) << "\n" << imgGrayEdges3.getMat(ACCESS_READ) << "\n" << imgGrayEdges5.getMat(ACCESS_READ) ;
        imshow("img", img);
        imshow("canny3", imgGrayEdges3);
        imshow("canny5", imgGrayEdges5);
        waitKey();
    }

Am I doing something wrong?

I use OpenCV3-beta in Eclipse under Win8.1 and have to build source from git. Source updated and compiled today (last canny.cpp change was 7 weeks ago).ago). I do have openCL so I guess UMat Canny function uses OCL_RUN version of function

Why Canny (OCL) (OCL, 3-beta) can not detect connected contour of black square on a white background?background.

Simple code for simple image result is not connected contour as it is expected. Top or bottom edge missed. Result printscreen is square-bug.png . The picture itself is square.png. Code is:

   void test(){
        UMat img = imread("./square.png", IMREAD_COLOR).getUMat(ACCESS_READ);
        UMat imgGray, imgGrayEdges3, imgGrayEdges5;
        cvtColor(img, imgGray, CV_BGR2GRAY);
        Canny(imgGray, imgGrayEdges3, 50, 150, 3);
        Canny(imgGray, imgGrayEdges5, 300, 2000, 5); // why so large thresholds?..
        cout << imgGray.getMat(ACCESS_READ) << "\n" << imgGrayEdges3.getMat(ACCESS_READ) << "\n" << imgGrayEdges5.getMat(ACCESS_READ) ;
        imshow("img", img);
        imshow("canny3", imgGrayEdges3);
        imshow("canny5", imgGrayEdges5);
        waitKey();
    }

Am I doing something wrong?

I use OpenCV3-beta in Eclipse under Win8.1 and have to build source from git. Source updated and compiled today (last canny.cpp change was 7 weeks ago). I do have openCL so I guess UMat Canny function uses OCL_RUN version of function

UPDATE: device and system info

  • Driver Packaging
  • Version 14.501.1003-141120a-178000C
  • Catalyst Version 14.12 AMD Catalyst
  • Omega Software 2D Driver
  • Version 8.01.01.1443 Direct3D
  • Version 9.14.10.01080 OpenGL
  • Version 6.14.10.13283 Mantle Driver
  • Version 9.1.

    • Graphics Chipset AMD Radeon HD 7900 Series
    • BIOS Version 015.012.000.004
    • BIOS Part Number 113-C3860100-100
    • BIOS Date 2011/12/07