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