no message
parent
e0cf4f960f
commit
70d858299b
|
@ -84,7 +84,7 @@ void CameraVideoSink::OnFrame(const webrtc::VideoFrame& frame) {
|
||||||
int height = this->m_capability.height;
|
int height = this->m_capability.height;
|
||||||
|
|
||||||
uint8_t *data = new uint8_t[width * height*4];
|
uint8_t *data = new uint8_t[width * height*4];
|
||||||
// qDebug()<<width*height<<int(frameBuffer->GetI420()->type());
|
qDebug()<<width*height<<int(frameBuffer->GetI420()->type());
|
||||||
memcpy(data,frameBuffer->GetI420()->DataY(),width*height);
|
memcpy(data,frameBuffer->GetI420()->DataY(),width*height);
|
||||||
memcpy(data + width*height ,frameBuffer->GetI420()->DataU(),
|
memcpy(data + width*height ,frameBuffer->GetI420()->DataU(),
|
||||||
width*height/4);
|
width*height/4);
|
||||||
|
|
|
@ -214,58 +214,63 @@ B = Y + 1.772 (Cb-128)
|
||||||
*/
|
*/
|
||||||
void CPlayWidget::initializeGL()
|
void CPlayWidget::initializeGL()
|
||||||
{
|
{
|
||||||
initializeOpenGLFunctions();
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
m_pVSHader = new QOpenGLShader(QOpenGLShader::Vertex, this);
|
initializeOpenGLFunctions();
|
||||||
bool bCompile = m_pVSHader->compileSourceCode(vsrcyuv);
|
// glEnable(GL_DEPTH_TEST);
|
||||||
if(!bCompile)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
m_pVSHader = new QOpenGLShader(QOpenGLShader::Vertex, this);
|
||||||
m_pFSHader = new QOpenGLShader(QOpenGLShader::Fragment, this);
|
bool bCompile = m_pVSHader->compileSourceCode(vsrcyuv);
|
||||||
if(mType == TYPE_RGB32){
|
if(!bCompile)
|
||||||
bCompile = m_pFSHader->compileSourceCode(fsrcrgb);
|
{
|
||||||
}
|
|
||||||
if(mType == TYPE_YUV420P){
|
|
||||||
bCompile = m_pFSHader->compileSourceCode(fsrcyuv);
|
|
||||||
}
|
|
||||||
if(mType == TYPE_I420){
|
|
||||||
bCompile = m_pFSHader->compileSourceCode(kI420FragmentShaderSource);
|
|
||||||
}
|
|
||||||
if(!bCompile)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#define PROGRAM_VERTEX_ATTRIBUTE 0
|
m_pFSHader = new QOpenGLShader(QOpenGLShader::Fragment, this);
|
||||||
#define PROGRAM_TEXCOORD_ATTRIBUTE 1
|
if(mType == TYPE_RGB32){
|
||||||
m_pShaderProgram = new QOpenGLShaderProgram;
|
bCompile = m_pFSHader->compileSourceCode(fsrcrgb);
|
||||||
m_pShaderProgram->addShader(m_pFSHader);
|
}
|
||||||
m_pShaderProgram->addShader(m_pVSHader);
|
if(mType == TYPE_YUV420P){
|
||||||
m_pShaderProgram->bindAttributeLocation("vertexIn", ATTRIB_VERTEX);
|
bCompile = m_pFSHader->compileSourceCode(fsrcyuv);
|
||||||
m_pShaderProgram->bindAttributeLocation("textureIn", ATTRIB_TEXTURE);
|
}
|
||||||
m_pShaderProgram->link();
|
if(mType == TYPE_I420){
|
||||||
m_pShaderProgram->bind();
|
bCompile = m_pFSHader->compileSourceCode(kI420FragmentShaderSource);
|
||||||
if(this->mType == TYPE_YUV420P){
|
}
|
||||||
initShaderYuv();
|
if(!bCompile)
|
||||||
}
|
{
|
||||||
if(this->mType == TYPE_RGB32){
|
qDebug()<<"compile error";
|
||||||
initShaderRgb();
|
}else{
|
||||||
}
|
qDebug()<<"compile ok";
|
||||||
if(this->mType == TYPE_I420){
|
}
|
||||||
initShaderI420();
|
#define PROGRAM_VERTEX_ATTRIBUTE 0
|
||||||
}
|
#define PROGRAM_TEXCOORD_ATTRIBUTE 1
|
||||||
glClearColor(0.0,0.0,0.0,0.0);
|
m_pShaderProgram = new QOpenGLShaderProgram;
|
||||||
|
m_pShaderProgram->addShader(m_pFSHader);
|
||||||
|
m_pShaderProgram->addShader(m_pVSHader);
|
||||||
|
m_pShaderProgram->bindAttributeLocation("vertexIn", ATTRIB_VERTEX);
|
||||||
|
m_pShaderProgram->bindAttributeLocation("textureIn", ATTRIB_TEXTURE);
|
||||||
|
m_pShaderProgram->link();
|
||||||
|
m_pShaderProgram->bind();
|
||||||
|
if(this->mType == TYPE_YUV420P){
|
||||||
|
initShaderYuv();
|
||||||
|
}
|
||||||
|
if(this->mType == TYPE_RGB32){
|
||||||
|
initShaderRgb();
|
||||||
|
}
|
||||||
|
if(this->mType == TYPE_I420){
|
||||||
|
initShaderI420();
|
||||||
|
}
|
||||||
|
glClearColor(0.0,0.0,0.0,0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CPlayWidget::resizeGL(int w, int h)
|
void CPlayWidget::resizeGL(int w, int h)
|
||||||
{
|
{
|
||||||
if(h == 0)
|
if(this->m_nVideoH > 0){
|
||||||
{
|
if(h == 0)
|
||||||
h = 1;
|
{
|
||||||
|
h = 1;
|
||||||
|
}
|
||||||
|
glViewport(0,0, w,h);
|
||||||
}
|
}
|
||||||
glViewport(0,0, w,h);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayWidget::paintGL()
|
void CPlayWidget::paintGL()
|
||||||
|
@ -282,6 +287,7 @@ void CPlayWidget::paintGL()
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,10 +328,10 @@ void CPlayWidget::initShaderRgb()
|
||||||
{
|
{
|
||||||
textureUniformRGB = m_pShaderProgram->uniformLocation("rgbdata");
|
textureUniformRGB = m_pShaderProgram->uniformLocation("rgbdata");
|
||||||
static const GLfloat vertexVertices[] = {
|
static const GLfloat vertexVertices[] = {
|
||||||
-1.0f, -1.0f,
|
-1.0f, -1.0f,
|
||||||
1.0f, -1.0f,
|
1.0f, -1.0f,
|
||||||
-1.0f, 1.0f,
|
-1.0f, 1.0f,
|
||||||
1.0f, 1.0f,
|
1.0f, 1.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GLfloat textureVertices[] = {
|
static const GLfloat textureVertices[] = {
|
||||||
|
@ -350,16 +356,16 @@ void CPlayWidget::initShaderI420()
|
||||||
textureUniformU = m_pShaderProgram->uniformLocation("tex_u");
|
textureUniformU = m_pShaderProgram->uniformLocation("tex_u");
|
||||||
textureUniformV = m_pShaderProgram->uniformLocation("tex_v");
|
textureUniformV = m_pShaderProgram->uniformLocation("tex_v");
|
||||||
static const GLfloat vertexVertices[] = {
|
static const GLfloat vertexVertices[] = {
|
||||||
-1.0f, -1.0f,
|
-1.0f, -1.0f,
|
||||||
1.0f, -1.0f,
|
1.0f, -1.0f,
|
||||||
-1.0f, 1.0f,
|
-1.0f, 1.0f,
|
||||||
1.0f, 1.0f,
|
1.0f, 1.0f,
|
||||||
};
|
};
|
||||||
static const GLfloat textureVertices[] = {
|
static const GLfloat textureVertices[] = {
|
||||||
0.0f, 1.0f,
|
0.0f, 1.0f,
|
||||||
1.0f, 1.0f,
|
1.0f, 1.0f,
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
1.0f, 0.0f,
|
1.0f, 0.0f,
|
||||||
};
|
};
|
||||||
glVertexAttribPointer(ATTRIB_VERTEX, 2, GL_FLOAT, 0, 0, vertexVertices);
|
glVertexAttribPointer(ATTRIB_VERTEX, 2, GL_FLOAT, 0, 0, vertexVertices);
|
||||||
glVertexAttribPointer(ATTRIB_TEXTURE, 2, GL_FLOAT, 0, 0, textureVertices);
|
glVertexAttribPointer(ATTRIB_TEXTURE, 2, GL_FLOAT, 0, 0, textureVertices);
|
||||||
|
@ -436,6 +442,7 @@ int CPlayWidget::loadRtcI420Texture()
|
||||||
{
|
{
|
||||||
if(nullptr == m_buffer)
|
if(nullptr == m_buffer)
|
||||||
return 0;
|
return 0;
|
||||||
|
m_pShaderProgram->bind();
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, id_y);
|
glBindTexture(GL_TEXTURE_2D, id_y);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "video_source_impl.h"
|
#include "video_source_impl.h"
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include "cv_ssd.h"
|
#include "cv_ssd.h"
|
||||||
|
#include <QOffscreenSurface>
|
||||||
|
|
||||||
# pragma comment(lib, "secur32.lib")
|
# pragma comment(lib, "secur32.lib")
|
||||||
# pragma comment(lib, "winmm.lib")
|
# pragma comment(lib, "winmm.lib")
|
||||||
|
@ -69,11 +70,7 @@ void EnumCapture()
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int p[5] = {3,1,49,23,23};
|
|
||||||
BubbleSort(p,5);
|
|
||||||
for(int i = 0;i< 5;i++){
|
|
||||||
qDebug()<<p[i]<<" ";
|
|
||||||
}
|
|
||||||
qRegisterMetaType<rtc::scoped_refptr<webrtc::I420BufferInterface>>("rtc::scoped_refptr<webrtc::I420BufferInterface>");
|
qRegisterMetaType<rtc::scoped_refptr<webrtc::I420BufferInterface>>("rtc::scoped_refptr<webrtc::I420BufferInterface>");
|
||||||
qRegisterMetaType<rtc::scoped_refptr<webrtc::I420BufferInterface>>("rtc::scoped_refptr<webrtc::I420BufferInterface>&");
|
qRegisterMetaType<rtc::scoped_refptr<webrtc::I420BufferInterface>>("rtc::scoped_refptr<webrtc::I420BufferInterface>&");
|
||||||
|
|
||||||
|
@ -83,7 +80,6 @@ int main(int argc, char *argv[])
|
||||||
rtc::ThreadManager::Instance()->SetCurrentThread(&w32_thread);
|
rtc::ThreadManager::Instance()->SetCurrentThread(&w32_thread);
|
||||||
rtc::InitializeSSL();
|
rtc::InitializeSSL();
|
||||||
|
|
||||||
setbuf(stdout, NULL);
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include "Qss.h"
|
#include "Qss.h"
|
||||||
|
#include <QtPlatformHeaders/QWindowsWindowFunctions>
|
||||||
|
|
||||||
|
|
||||||
class ASyncDetectAndRenderThread :public QSSASyncProcess{
|
class ASyncDetectAndRenderThread :public QSSASyncProcess{
|
||||||
public:
|
public:
|
||||||
|
@ -66,7 +68,6 @@ public:
|
||||||
|
|
||||||
cv::cvtColor(*result, yuvData, cv::COLOR_BGR2YUV_I420);
|
cv::cvtColor(*result, yuvData, cv::COLOR_BGR2YUV_I420);
|
||||||
this->m_render->OnCameraData(yuvData.data);
|
this->m_render->OnCameraData(yuvData.data);
|
||||||
|
|
||||||
}
|
}
|
||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +115,7 @@ public:
|
||||||
qtimer->setSingleShot(false);
|
qtimer->setSingleShot(false);
|
||||||
|
|
||||||
QObject::connect(qtimer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
|
QObject::connect(qtimer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
|
||||||
qtimer->start(22);
|
qtimer->start(10);
|
||||||
|
|
||||||
while(state){
|
while(state){
|
||||||
if(mfbs ->Size() > 0){
|
if(mfbs ->Size() > 0){
|
||||||
|
@ -126,6 +127,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eventLoop.exec(); // 渲染一次
|
eventLoop.exec(); // 渲染一次
|
||||||
|
|
||||||
delete frame;
|
delete frame;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,7 +143,7 @@ AsyncRennder *gRender = nullptr;
|
||||||
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QssMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@ -185,17 +187,20 @@ void MainWindow::on_pushButton_clicked()
|
||||||
char ids[128];
|
char ids[128];
|
||||||
info->GetDeviceName(id,nullptr,0,ids,128,nullptr,0);
|
info->GetDeviceName(id,nullptr,0,ids,128,nullptr,0);
|
||||||
info->GetCapability(ids,id,p);
|
info->GetCapability(ids,id,p);
|
||||||
qDebug()<<QString::asprintf("GetCapability: %d %d %d %d",id,p.width,p.height,p.maxFPS);
|
qDebug()<<QString::asprintf("GetCapability: "
|
||||||
|
" %d %d %d %d %d %d",id,p.width,p.height,p.maxFPS,p.videoType,p.interlaced);
|
||||||
|
|
||||||
m_capturer.reset(CameraVideoSink::Create(p.width, p.height, 25, id));
|
m_capturer.reset(CameraVideoSink::Create(p.width, p.height, 25, id));
|
||||||
if (!m_capturer) {
|
if (!m_capturer) {
|
||||||
qDebug()<<"error";
|
qDebug()<<"error";
|
||||||
}
|
}
|
||||||
ui->openGLWidget->SetDataType(CPlayWidget::TYPE_YUV420P);
|
qDebug()<<"size is "<<m_capturer->Capability().width<<m_capturer->Capability().height;
|
||||||
ui->openGLWidget->SetImgSize(m_capturer->Capability().width,
|
ui->openGLWidget->SetImgSize(m_capturer->Capability().width,
|
||||||
m_capturer->Capability().height);
|
m_capturer->Capability().height);
|
||||||
|
ui->openGLWidget->SetDataType(CPlayWidget::TYPE_YUV420P);
|
||||||
|
|
||||||
ui->openGLWidget->StartRender();
|
ui->openGLWidget->StartRender();
|
||||||
// ui->openGLWidget->moveToThread(&gRender->Thread());
|
// ui->openGLWidget->moveToThread(&gRender->Thread());
|
||||||
if(gRender == nullptr){
|
if(gRender == nullptr){
|
||||||
gRender = new AsyncRennder(this,m_capturer->VideoBuffer(),ui->openGLWidget);
|
gRender = new AsyncRennder(this,m_capturer->VideoBuffer(),ui->openGLWidget);
|
||||||
gRender->Start(this);
|
gRender->Start(this);
|
||||||
|
@ -205,6 +210,8 @@ void MainWindow::on_pushButton_clicked()
|
||||||
mDetectResut->StartRender();
|
mDetectResut->StartRender();
|
||||||
|
|
||||||
ui->pushButton->setText(QString::asprintf("正在采集"));
|
ui->pushButton->setText(QString::asprintf("正在采集"));
|
||||||
|
|
||||||
|
qDebug()<<ui->openGLWidget->geometry();
|
||||||
}else{
|
}else{
|
||||||
ui->openGLWidget->StopRender();
|
ui->openGLWidget->StopRender();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class MainWindow : public QssMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1280</width>
|
<width>1297</width>
|
||||||
<height>800</height>
|
<height>842</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
|
|
Loading…
Reference in New Issue