Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Solid Fill Rectangle

Hi Folks,

When creating shapes with OpenCV, can someone tell me what the "LineType" parameter is? From the definition of the various shapes, it appears that linetype has a default value of 8. What is curious though, is when I use the code below to create a solid fill rectangle, the code produces a run time error whenever I use values of [2,3,5,6,7] for the LineType along with a value of -1 for the thickness (to produce a solid fill rectangle). However, when I change the thickness value to 6 and leave the linetype = 2, the code runs fine. Why is this??

Error: Assertion failed (connectivity == 8 || connectivity == 4) in LineIterator

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

//solid fill rectangle example
    int main()
    {
        Mat image(200, 200, CV_8UC3, Scalar(255,0,0));

        Point start = Point (50,50);
        Point end = Point (150,150);
        int thickness = -1;
        int linetype =2; //error

        rectangle (image, start, end, Scalar(0,255,0), thickness, linetype);

        namedWindow("Image");
        imshow("Image", image);

    waitKey(0);
    }

Solid Fill RectangleRectangle Error [LineType Parameter?]

Hi Folks,

When creating shapes with OpenCV, can someone tell me what the "LineType" parameter is? From the definition of the various shapes, it appears that linetype has a default value of 8. What is curious though, is when I use the code below to create a solid fill rectangle, the code produces a run time error whenever I use values of [2,3,5,6,7] for the LineType along with a value of -1 for the thickness (to produce a solid fill rectangle). However, when I change the thickness value to 6 and leave the linetype = 2, the code runs fine. Why is this??

Error: Assertion failed (connectivity == 8 || connectivity == 4) in LineIterator

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

//solid fill rectangle example
    int main()
    {
        Mat image(200, 200, CV_8UC3, Scalar(255,0,0));

        Point start = Point (50,50);
        Point end = Point (150,150);
        int thickness = -1;
        int linetype =2; //error

        rectangle (image, start, end, Scalar(0,255,0), thickness, linetype);

        namedWindow("Image");
        imshow("Image", image);

    waitKey(0);
    }