dmig2006
14th March 2016, 12:32
Hello,
I have a videocamera whose generated video to in h264. Picture to be drawn over the video. With this problem.
Я имею видеокамеру, ÐºÐ¾Ñ‚Ð¾Ñ€Ð°Ñ Ð³ÐµÐ½ÐµÑ€Ð¸Ñ€ÑƒÐµÑ‚ видеопоток в h264. Картинка должна риÑоватьÑÑ Ð¿Ð¾Ð²ÐµÑ€Ñ… видео. С Ñтим проблемма.
test.h
#ifndef TEST_H
#define TEST_H
#include <QWidget>
#include <QPainter>
#include <QPicture>
#include <QVideoWidget>
#include <QImage>
namespace Ui {
class Test;
}
struct Graphics {
QImage pixmapLogo;
};
class Test : public QVideoWidget
{
Q_OBJECT
Ui::Test *ui;
QPixmap mPixmap;
QImage pixmapL;
Graphics mGraphics;
protected:
void paintEvent(QPaintEvent *);
public:
Test(QWidget *parent = 0);
~Test();
};
#endif // TEST_H
test.cpp
#include "test.h"
#include "ui_test.h"
Test::Test(QWidget *parent) :
QVideoWidget(parent), ui(new Ui::Test)
{
ui->setupUi(this);
QPixmap p("://logo.png");
QLabel *label = new QLabel(parent);
label -> resize(150,34);
label -> setPixmap(p);
label -> move(610,14);
}
Test::~Test()
{
delete ui;
}
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QMediaPlayer>
#include <QVideoWidget>
#include <QDataStream>
#include "test.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
Test *pTest;
QMediaPlayer *player;
#endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
player = new QMediaPlayer(this);//, QMediaPlayer::StreamPlayback);
pTest = new Test(this);
pTest -> setGeometry(5,35,1385,1040);
pTest -> setOptWidget(mOptWidget);
pTest -> hide();
player -> setVideoOutput(pTest);
}
Here the picture is displayed as it should
Картинка выводитÑÑ Ð¿Ð¾Ð²ÐµÑ€Ñ… видео
if you write the following test.cpp
ЕÑли test.cpp напиÑать Ñледующим образом
test.cpp
#include "test.h"
#include "ui_test.h"
Test::Test(QWidget *parent) :
QVideoWidget(parent), ui(new Ui::Test)
{
ui->setupUi(this);
mGraphicsBlack.pixmapLogo.load(":/logo.png");
mGraphics = mGraphicsBlack;
pixmapL = mGraphics.pixmapLogo;
}
Test::~Test()
{
delete ui;
}
void Test::paintEvent(QPaintEvent *event)
{
QVideoWidget::paintEvent(event);
QPainter painter(this);
painter.drawImage(1010, 14, pixmapL);
painter.end();
}
Pictures do not have top stream. Why QPixmap it displays picture, QPaint it not dispalys picture?
Картинка не риÑуетÑÑ Ð¿Ð¾Ð²ÐµÑ€Ñ… видео. Почему QPixmap риÑует картинку поверх видео а QPaint нет?
Как Ñделать чтобы QPaint риÑовал картинку поверх видео? Чтобы и видео, и картинка отображалиÑÑŒ .
Get out of line in mainwindow.cpp :
player -> setVideoOutput(pTest);
Here the picture is displays, with the help QPaint.
При убирании Ñтрочки в mainwindow.cpp:
player -> setVideoOutput(pTest);
Картинка риÑуетÑÑ Ð¿Ñ€Ð¸ помощи QPaint.
Why is there so? How to make the output video image over using QPaint? How to make a video stream is excreted in the picture?
Почему так? Как Ñделать чтобы отображалоÑÑŒ видео в h264 и риÑовалаÑÑŒ картинка через QPaint? Как Ñделать чтобы и видео и картинка риÑовалиÑÑŒ?
I have a videocamera whose generated video to in h264. Picture to be drawn over the video. With this problem.
Я имею видеокамеру, ÐºÐ¾Ñ‚Ð¾Ñ€Ð°Ñ Ð³ÐµÐ½ÐµÑ€Ð¸Ñ€ÑƒÐµÑ‚ видеопоток в h264. Картинка должна риÑоватьÑÑ Ð¿Ð¾Ð²ÐµÑ€Ñ… видео. С Ñтим проблемма.
test.h
#ifndef TEST_H
#define TEST_H
#include <QWidget>
#include <QPainter>
#include <QPicture>
#include <QVideoWidget>
#include <QImage>
namespace Ui {
class Test;
}
struct Graphics {
QImage pixmapLogo;
};
class Test : public QVideoWidget
{
Q_OBJECT
Ui::Test *ui;
QPixmap mPixmap;
QImage pixmapL;
Graphics mGraphics;
protected:
void paintEvent(QPaintEvent *);
public:
Test(QWidget *parent = 0);
~Test();
};
#endif // TEST_H
test.cpp
#include "test.h"
#include "ui_test.h"
Test::Test(QWidget *parent) :
QVideoWidget(parent), ui(new Ui::Test)
{
ui->setupUi(this);
QPixmap p("://logo.png");
QLabel *label = new QLabel(parent);
label -> resize(150,34);
label -> setPixmap(p);
label -> move(610,14);
}
Test::~Test()
{
delete ui;
}
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QMediaPlayer>
#include <QVideoWidget>
#include <QDataStream>
#include "test.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
Test *pTest;
QMediaPlayer *player;
#endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
player = new QMediaPlayer(this);//, QMediaPlayer::StreamPlayback);
pTest = new Test(this);
pTest -> setGeometry(5,35,1385,1040);
pTest -> setOptWidget(mOptWidget);
pTest -> hide();
player -> setVideoOutput(pTest);
}
Here the picture is displayed as it should
Картинка выводитÑÑ Ð¿Ð¾Ð²ÐµÑ€Ñ… видео
if you write the following test.cpp
ЕÑли test.cpp напиÑать Ñледующим образом
test.cpp
#include "test.h"
#include "ui_test.h"
Test::Test(QWidget *parent) :
QVideoWidget(parent), ui(new Ui::Test)
{
ui->setupUi(this);
mGraphicsBlack.pixmapLogo.load(":/logo.png");
mGraphics = mGraphicsBlack;
pixmapL = mGraphics.pixmapLogo;
}
Test::~Test()
{
delete ui;
}
void Test::paintEvent(QPaintEvent *event)
{
QVideoWidget::paintEvent(event);
QPainter painter(this);
painter.drawImage(1010, 14, pixmapL);
painter.end();
}
Pictures do not have top stream. Why QPixmap it displays picture, QPaint it not dispalys picture?
Картинка не риÑуетÑÑ Ð¿Ð¾Ð²ÐµÑ€Ñ… видео. Почему QPixmap риÑует картинку поверх видео а QPaint нет?
Как Ñделать чтобы QPaint риÑовал картинку поверх видео? Чтобы и видео, и картинка отображалиÑÑŒ .
Get out of line in mainwindow.cpp :
player -> setVideoOutput(pTest);
Here the picture is displays, with the help QPaint.
При убирании Ñтрочки в mainwindow.cpp:
player -> setVideoOutput(pTest);
Картинка риÑуетÑÑ Ð¿Ñ€Ð¸ помощи QPaint.
Why is there so? How to make the output video image over using QPaint? How to make a video stream is excreted in the picture?
Почему так? Как Ñделать чтобы отображалоÑÑŒ видео в h264 и риÑовалаÑÑŒ картинка через QPaint? Как Ñделать чтобы и видео и картинка риÑовалиÑÑŒ?