Is there any opencv function like "cvHoughCircles ()" for square detection?

Is there any opencv function like cvHoughCircles () that can be used for square definition programming for a circle detection program that has CvSeq * circles = cvHoughCircles () , but I could not find it to determine the squares.

+5
source share
2 answers

You do not need any separate function for this. OpenCV comes with square detection (which actually defines rectangles, you can add a constraint so that all sides are equal in length to get a square).

Check out this link: squares.cpp

, SOF: javacv?

, .

enter image description here

+8

opencv- .

houghLines, , 90 .

, Java:

// returns cosine of angle between line segments 0 to 1, and 0 to 2.
// pt0 is the vertex / intersection
// angle of 90 degrees will have a cosine == 0

public static final double angleCosine(Point pt1, Point pt0, Point pt2) {
    double dx1 = pt1.x - pt0.x;
    double dy1 = pt1.y - pt0.y;
    double dx2 = pt2.x - pt0.x;
    double dy2 = pt2.y - pt0.y;
    return (dx1 * dx2 + dy1 * dy2) / Math.sqrt((dx1 * dx1 + dy1 * dy1) * (dx2 * dx2 + dy2 * dy2) + 1e-10);
}

houghLines:

http://docs.opencv.org/modules/imgproc/doc/feature_detection.html?highlight=houghlines#houghlines

+5

All Articles