Example #1
0
ResultLines lineDetection(Mat origin,int w1, int w2) {
    vector<Vec2f> lines;
    ResultLines resultlines;

    Mat canny;
    Mat test = origin.clone();

    Canny(origin,canny,100,500);
    HoughLines(canny, lines, 1, CV_PI / 180, w1, w2, 0);

    setLineSize(lines.size());

    for (size_t i = 0; i < lines.size(); i++) {
        float rho = lines[i][0], theta = lines[i][1];
        Point pt1, pt2;
        double a = cos(theta), b = sin(theta);
        double x0 = a * rho, y0 = b * rho;
        pt1.x = cvRound(x0 + 1000 * (-b));
        pt1.y = cvRound(y0 + 1000 * (a));
        pt2.x = cvRound(x0 - 1000 * (-b));
        pt2.y = cvRound(y0 - 1000 * (a));
        Vec4i vec4i = Vec4i(pt1.x,pt1.y,pt2.x,pt2.y);
        double degree = theta/CV_PI*180;
        line(test,pt1,pt2,Scalar(255,255,255),3);

        degreeChecking(degree,vec4i,pt1,pt2,&resultlines,origin);
        resultlines.allLines.push_back(vec4i);
    }
    return resultlines;
}
Example #2
0
EArrow::EArrow( QWidget *parent ) : QWidget( parent ) {
    setLineSize( 2 );
    setArrowSize(10);
    setLineColor(Qt::black);
    setBrushColor(Qt::gray);
    setArrowMode(RIGTH);
    setArrowDirection(HORIZONTAL);
}
Example #3
0
	FXGLCircleSource() : FXGLVertices(0,0,0, VERTICES_LINES|VERTICES_LOOPLINES|VERTICES_NODEPTHTEST), vertices(0)
	{
		static const FXuint no=128;
		FXERRHM(vertices=new FXVec3f[no]);
		for(FXuint n=0; n<no; n++)
			vertices[n]=FXVec3f(sin((float)PI*2/no*n), cos((float)PI*2/no*n), 0);
		setVertices(vertices, no);
		setLineSize(0.1f);
		setColor(FXGLColor(0,0,0));
	}
Example #4
0
rectangle::rectangle( QWidget *parent ) : QWidget( parent )
{
    m_value = 0;

    QSizePolicy policy( QSizePolicy::Expanding, QSizePolicy::Expanding);
    policy.setHeightForWidth( true );
    setSizePolicy( policy );
    setLineSize(1);
    setLineColor(Qt::black);
    writeFG(Qt::red);
    writeBG(Qt::gray);
}
Example #5
0
void RazorPanel::readSettings()
{
    // Read settings ......................................
    mSettings->beginGroup(CFG_PANEL_GROUP);

    // By default we are using size & count from theme.
    setLineSize(mSettings->value(CFG_KEY_LINESIZE, mLineSize).toInt());
    setLineCount(mSettings->value(CFG_KEY_LINECNT, mLineCount).toInt());

    setLength(mSettings->value(CFG_KEY_LENGTH, 100).toInt(),
              mSettings->value(CFG_KEY_PERCENT, true).toBool());

    setPosition(mSettings->value(CFG_KEY_SCREENNUM, QApplication::desktop()->primaryScreen()).toInt(),
                strToPosition(mSettings->value(CFG_KEY_POSITION).toString(), PositionBottom));

    setAlignment(RazorPanel::Alignment(mSettings->value(CFG_KEY_ALIGNMENT, mAlignment).toInt()));
    mSettings->endGroup();
}
Example #6
0
void caGraphics::paintEvent( QPaintEvent *event )
{
    Q_UNUSED(event);

    if(thisHide) return;

    int m_margin = 3;
    QPointF p1,p2;
    QPainter painter( this );
    painter.setRenderHint( QPainter::Antialiasing );

    int margin = thisLineSize/2;
    int w = width() - 2 * margin;
    int h = height() - 2 * margin;

// do not increase linesize beyond the canvas size
    if(w <= 0 || h <= 0) {
        setLineSize(thisLineSize-1);
    }
    margin = thisLineSize/2;
    w = width() - 2 * margin;
    h = height() - 2 * margin;
    int x = margin;
    int y = margin;

    if(thisLineStyle == Dash) {
        painter.setPen( QPen( getLineColor(), getLineSize(), Qt::DotLine, Qt::SquareCap) );
    } else if (thisLineStyle == BigDash) {
        painter.setPen( QPen( getLineColor(), getLineSize(), Qt::DashLine, Qt::SquareCap) );
    } else {
        painter.setPen( QPen( getLineColor(), getLineSize(), Qt::SolidLine, Qt::SquareCap) );
    }

    if(thisFillStyle == Filled) {
        painter.setBrush(getForeground());
    }

    if(getForm() == Rectangle) {
        QPolygonF rectangle;
        rectangle.append(QPointF(x,y));
        rectangle.append(QPointF(x+w,y));
        rectangle.append(QPointF(x+w,y+h));
        rectangle.append(QPointF(x,y+h));
        rectangle.append(QPointF(x,y));
        // rotate
        QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, rectangle);
        painter.drawPolygon(rotated);

    } else if(getForm() == Circle) {
        // rotate my calculated ellipse
        QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, drawCircle(x, x+w, y, y+h));
        painter.drawPolygon(rotated);

    } else if(getForm() == Triangle) {
        QPolygonF triangle;
        triangle.append(QPointF(x+w/2,0));
        triangle.append(QPointF(x,y+h));
        triangle.append(QPointF(x+w,y+h));
        triangle.append(QPointF(x+w/2,0));

        // rotate
        QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, triangle);
        painter.drawPolygon(rotated);

    } else if(getForm() == Arc) {
        if(thisFillStyle == Filled) {
            painter.drawPie (x, y, w, h, thisStartAngle * 16, thisSpanAngle * 16);
        } else {
            painter.drawArc (x, y, w, h, thisStartAngle * 16, thisSpanAngle * 16);
        }

    } else if(getForm() == Line) {
        QPolygonF line;
        line.append(QPointF(x,y+h/2));
        line.append(QPointF(x+w,y+h/2));

        // rotate
        QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, line);
        painter.drawPolygon(rotated);

    } else if(getForm() == Arrow) {
        QPolygonF lines;
        QPolygonF head1;
        QPolygonF head2;

        p1 = QPointF( m_margin, height()/2 );
        p2 = QPointF( width()-m_margin, height()/2 );
        lines.append(p1);
        lines.append(p2);

        head1 = getHead(p1,p2);
        if (getArrowMode() == Double) {
            head2 = getHead(p2,p1);
        }

        for(int i=0; i<head1.count(); i++) lines.append(head1.at(i));
        for(int i=0; i<head2.count(); i++) lines.append(head2.at(i));

        // rotate
        QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, lines);
        painter.drawPolygon(rotated);
    }

}