示例#1
0
sf::Sprite BackgroundImage::getGameOver()
{
	if (!this->background.loadFromFile(gameOverImagePath))
	{
		std::cout<<"Error to load gameOverImage"<<std::endl;
	}
	sf::Sprite bg1(this->background);
	this->bg = bg1;
	return this->bg;
}
示例#2
0
void UIVMPreviewWindow::repaintBGImages()
{
    /* Delete the old images: */
    if (m_pbgImage)
    {
        delete m_pbgImage;
        m_pbgImage = 0;
    }
    if (m_pGlossyImg)
    {
        delete m_pGlossyImg;
        m_pGlossyImg = 0;
    }

    /* Check that there is enough room for our fancy stuff.
     * If not we just draw nothing (the border and the blur radius). */
    QRect cr = contentsRect();
    if (cr.width()  < 41 || cr.height() < 41)
        return;

    QPalette pal = palette();
    m_wRect = cr.adjusted(10, 10, -10, -10);
    m_vRect = m_wRect.adjusted(m_vMargin, m_vMargin, -m_vMargin, -m_vMargin).adjusted(-3, -3, 3, 3);

    /* First draw the shadow. Its a rounded rectangle which get blurred: */
    QImage imageW(cr.size(), QImage::Format_ARGB32);
    QColor bg = pal.color(QPalette::Base);
    bg.setAlpha(0); /* We want blur to transparent _and_ whatever the base color is. */
    imageW.fill(bg.rgba());
    QPainter pW(&imageW);
    pW.setBrush(QColor(30, 30, 30)); /* Dark gray */
    pW.setPen(Qt::NoPen);
    pW.drawRoundedRect(QRect(QPoint(0, 0), cr.size()).adjusted(10, 10, -10, -10), m_vMargin, m_vMargin);
    pW.end();
    /* Blur the rectangle */
    QImage imageO(cr.size(), QImage::Format_ARGB32);
    blurImage(imageW, imageO, 10);
    QPainter pO(&imageO);

    /* Now paint the border with a gradient to get a look of a monitor: */
    QRect rr = QRect(QPoint(0, 0), cr.size()).adjusted(10, 10, -10, -10);
    QLinearGradient lg(0, rr.y(), 0, rr.height());
    QColor base(200, 200, 200); /* light variant */
    // QColor base(80, 80, 80); /* Dark variant */
    lg.setColorAt(0, base);
    lg.setColorAt(0.4, base.darker(300));
    lg.setColorAt(0.5, base.darker(400));
    lg.setColorAt(0.7, base.darker(300));
    lg.setColorAt(1, base);
    pO.setBrush(lg);
    pO.setPen(QPen(base.darker(150), 1));
    pO.drawRoundedRect(rr, m_vMargin, m_vMargin);
    pO.end();

    /* Make a copy of the new bg image: */
    m_pbgImage = new QImage(imageO);

    /* Now the glossy overlay has to be created.
     * Start with defining a nice looking painter path. */
    QRect gRect = QRect(QPoint(0, 0), m_vRect.size());
    QPainterPath glossyPath(QPointF(gRect.x(), gRect.y()));
    glossyPath.lineTo(gRect.x() + gRect.width(), gRect.y());
    glossyPath.lineTo(gRect.x() + gRect.width(), gRect.y() + gRect.height() * 1.0/3.0);
    glossyPath.cubicTo(gRect.x() + gRect.width() / 2.0, gRect.y() + gRect.height() * 1.0/3.0,
                       gRect.x() + gRect.width() / 2.0, gRect.y() + gRect.height() * 2.0/3.0,
                       gRect.x(), gRect.y() + gRect.height() * 2.0/3.0);
    glossyPath.closeSubpath();

    /* Paint the glossy path on a QImage: */
    QImage image(m_vRect.size(), QImage::Format_ARGB32);
    QColor bg1(Qt::white); /* We want blur to transparent _and_ white. */
    bg1.setAlpha(0);
    image.fill(bg1.rgba());
    QPainter painter(&image);
    painter.fillPath(glossyPath, QColor(255, 255, 255, 80));
    painter.end();
    /* Blur the image to get a much more smooth feeling */
    QImage image1(m_vRect.size(), QImage::Format_ARGB32);
    blurImage(image, image1, 7);
    m_pGlossyImg = new QImage(image1);

    /* Repaint: */
    update();
}
示例#3
0
void Triangulation::calculateBackground() {

    //Calculation and testing background

    if (stereoImages.size() <= 0) {
        return;
    }

    qDebug() << "start calc bg";

    vector < Mat > pics1;
    vector < Mat > pics2;

    for (int i = 0; i < stereoImages.size(); i++) {
        Mat grey1, grey2;
        cvtColor(stereoImages[i]->getLeft(), grey1, CV_BGR2GRAY);
        cvtColor(stereoImages[i]->getRight(), grey2, CV_BGR2GRAY);
        pics1.push_back(grey1);
        pics2.push_back(grey2);

        qDebug() << i;
    }

    qDebug() << "added imgs";

    Q_ASSERT(pics1.size() == pics2.size());

    int w = pics1[0].cols;
    int h = pics1[0].rows;

    Mat bg1(h, w, CV_8UC1);
    Mat bg2(h, w, CV_8UC1);

    qDebug() << "bg1.cols: " << bg1.cols;
    qDebug() << "bg1.rows: " << bg1.rows;
    qDebug() << "pics1[0].cols: " << pics1[0].cols;
    qDebug() << "pics1[0].rows: " << pics1[0].rows;

    for (int i = 0; i < h; i++) { //rows
        for (int j = 0; j < w; j++) { //cols
            long long int s1 = 1; //0
            long long int s2 = 1; //0

            QVector < int > m1;
            QVector < int > m2;
            for (int k = 0; k < pics1.size(); k++) {
                s1 *= pics1[k].at<uchar>(i, j);
                s2 *= pics2[k].at<uchar>(i, j);

                m1.push_back(pics1[k].at<uchar>(i, j));
                m2.push_back(pics2[k].at<uchar>(i, j));
                //qDebug() << "pics1[k].at<uchar>(i, j): " << pics1[k].at<uchar>(i, j);
            }

            qSort(m1);
            qSort(m2);

            bg1.at<uchar>(i, j) = m1[m1.size() / 2];
            bg2.at<uchar>(i, j) = m2[m2.size() / 2];
        }
    }

    qDebug() << "calced";

    background->setImages(bg1, bg2);
}
示例#4
0
void Triangulation::calculateLocalBackground() {
    // local calc BG
    //Calculation and testing background

    qDebug() << "start calc bg";

    vector < Mat > pics1;
    vector < Mat > pics2;

    for (int i = 1; i <= 4; i++) {
        Mat grey1, grey2;
        string s = QString::number(i).toUtf8().constData();
        Mat img1 = imread("image1150330fish" + s + ".jpg");
        Mat img2 = imread("image2150330fish" + s + ".jpg");
        cvtColor(img1, grey1, CV_BGR2GRAY);
        cvtColor(img2, grey2, CV_BGR2GRAY);
        pics1.push_back(grey1);
        pics2.push_back(grey2);
    }

    qDebug() << "added imgs";

    Q_ASSERT(pics1.size() == pics2.size());

    int w = 1600;
    int h = 1200;

    Mat bg1(h, w, CV_8UC1);
    Mat bg2(h, w, CV_8UC1);

    qDebug() << "bg1.cols: " << bg1.cols;
    qDebug() << "bg1.rows: " << bg1.rows;
    qDebug() << "pics1[0].cols: " << pics1[0].cols;
    qDebug() << "pics1[0].rows: " << pics1[0].rows;

    for (int i = 0; i < h; i++) { //rows
        for (int j = 0; j < w; j++) { //cols
            long long int s1 = 1; //0
            long long int s2 = 1; //0

            QVector < int > m1;
            QVector < int > m2;
            for (int k = 0; k < pics1.size(); k++) {
                s1 *= pics1[k].at<uchar>(i, j);
                s2 *= pics2[k].at<uchar>(i, j);

                m1.push_back(pics1[k].at<uchar>(i, j));
                m2.push_back(pics2[k].at<uchar>(i, j));
                //qDebug() << "pics1[k].at<uchar>(i, j): " << pics1[k].at<uchar>(i, j);
            }

            qSort(m1);
            qSort(m2);

            bg1.at<uchar>(i, j) = m1[m1.size() / 2];
            bg2.at<uchar>(i, j) = m2[m2.size() / 2];
        }
    }

    background->setImages(bg1, bg2);

    isBackgroundCalculated = true;

    qDebug() << "calced";
}
示例#5
0
void ScopePanel::drawPanelContents() {
    
    if (scopeMode == SCOPE_MODE_Y) {
        bgPanel.setFillColor(ThemeMgr::mgr.currentTheme->scopeBackground, ThemeMgr::mgr.currentTheme->scopeBackground * 2.0);
        bgPanel.calcTransform(transform);
        bgPanel.draw();
        glLineWidth(1.0);
        glEnable(GL_LINE_SMOOTH);
        glLoadMatrixf(transform.to_ptr());
        glColor3f(ThemeMgr::mgr.currentTheme->scopeLine.r * 0.35, ThemeMgr::mgr.currentTheme->scopeLine.g * 0.35,
                  ThemeMgr::mgr.currentTheme->scopeLine.b * 0.35);
        glBegin (GL_LINES);
        glVertex2f(-1.0, 0.0);
        glVertex2f(1.0, 0.0);
        glEnd();
    } else if (scopeMode == SCOPE_MODE_2Y)  {
        bgPanelStereo[0].setFillColor(ThemeMgr::mgr.currentTheme->scopeBackground, ThemeMgr::mgr.currentTheme->scopeBackground * 2.0);
        bgPanelStereo[1].setFillColor(ThemeMgr::mgr.currentTheme->scopeBackground, ThemeMgr::mgr.currentTheme->scopeBackground * 2.0);

        bgPanelStereo[0].calcTransform(transform);
        bgPanelStereo[0].draw();
        bgPanelStereo[1].calcTransform(transform);
        bgPanelStereo[1].draw();

        glLineWidth(1.0);
        glLoadMatrixf(transform.to_ptr());
        glColor3f(ThemeMgr::mgr.currentTheme->scopeLine.r, ThemeMgr::mgr.currentTheme->scopeLine.g, ThemeMgr::mgr.currentTheme->scopeLine.b);
        glEnable(GL_LINE_SMOOTH);
        glBegin (GL_LINES);
        glVertex2f(-1.0, 0.0);
        glVertex2f(1.0, 0.0);
        glColor3f(ThemeMgr::mgr.currentTheme->scopeLine.r * 0.35, ThemeMgr::mgr.currentTheme->scopeLine.g * 0.35,
                  ThemeMgr::mgr.currentTheme->scopeLine.b * 0.35);
        glVertex2f(-1.0, 0.5);
        glVertex2f(1.0, 0.5);
        glVertex2f(-1.0, -0.5);
        glVertex2f(1.0, -0.5);
        glEnd();

    } else if (scopeMode == SCOPE_MODE_XY) {
        RGBA4f bg1(ThemeMgr::mgr.currentTheme->scopeBackground), bg2(ThemeMgr::mgr.currentTheme->scopeBackground * 2.0);
        bg1.a = 0.05f;
        bg2.a = 0.05f;
        bgPanel.setFillColor(bg1, bg2);
        bgPanel.calcTransform(transform);
        bgPanel.draw();
        glLineWidth(1.0);
        glEnable(GL_POINT_SMOOTH);
        glPointSize(1.0);
        glLoadMatrixf(transform.to_ptr());
        glColor3f(ThemeMgr::mgr.currentTheme->scopeLine.r * 0.15, ThemeMgr::mgr.currentTheme->scopeLine.g * 0.15,
                  ThemeMgr::mgr.currentTheme->scopeLine.b * 0.15);
    }
    
    if (points.size()) {
        glEnable (GL_BLEND);
        glEnable (GL_LINE_SMOOTH);
        glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
        if (scopeMode == SCOPE_MODE_XY) {
            glBlendFunc(GL_ONE, GL_ONE);
        } else {
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        }
        glColor4f(ThemeMgr::mgr.currentTheme->scopeLine.r, ThemeMgr::mgr.currentTheme->scopeLine.g, ThemeMgr::mgr.currentTheme->scopeLine.b, 1.0);
        glEnableClientState (GL_VERTEX_ARRAY);
        glVertexPointer(2, GL_FLOAT, 0, &points[0]);
        glLineWidth(1.5);
        if (scopeMode == SCOPE_MODE_Y) {
            glLoadMatrixf(bgPanel.transform.to_ptr());
            glDrawArrays(GL_LINE_STRIP, 0, points.size() / 2);
        } else if (scopeMode == SCOPE_MODE_2Y)  {
            glLoadMatrixf(bgPanelStereo[0].transform.to_ptr());
            glDrawArrays(GL_LINE_STRIP, 0, points.size() / 4);

            glLoadMatrixf(bgPanelStereo[1].transform.to_ptr());
            glDrawArrays(GL_LINE_STRIP, points.size() / 4, points.size() / 4);
        } else if (scopeMode == SCOPE_MODE_XY) {
            glLoadMatrixf(bgPanel.transform.to_ptr());
            glDrawArrays(GL_POINTS, 0, points.size() / 2);
        }
        glLineWidth(1.0);
        glDisableClientState(GL_VERTEX_ARRAY);
        glDisable(GL_BLEND);
    }
}