no message

master
zcy 2023-10-28 01:27:20 +08:00
parent e0cf4f960f
commit 70d858299b
6 changed files with 81 additions and 71 deletions

View File

@ -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);

View File

@ -214,8 +214,9 @@ B = Y + 1.772 (Cb-128)
*/
void CPlayWidget::initializeGL()
{
initializeOpenGLFunctions();
glEnable(GL_DEPTH_TEST);
// glEnable(GL_DEPTH_TEST);
m_pVSHader = new QOpenGLShader(QOpenGLShader::Vertex, this);
bool bCompile = m_pVSHader->compileSourceCode(vsrcyuv);
@ -235,7 +236,9 @@ void CPlayWidget::initializeGL()
}
if(!bCompile)
{
qDebug()<<"compile error";
}else{
qDebug()<<"compile ok";
}
#define PROGRAM_VERTEX_ATTRIBUTE 0
#define PROGRAM_TEXCOORD_ATTRIBUTE 1
@ -261,12 +264,14 @@ void CPlayWidget::initializeGL()
void CPlayWidget::resizeGL(int w, int h)
{
if(this->m_nVideoH > 0){
if(h == 0)
{
h = 1;
}
glViewport(0,0, w,h);
}
}
void CPlayWidget::paintGL()
{
@ -282,6 +287,7 @@ void CPlayWidget::paintGL()
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
return;
}
@ -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);

View File

@ -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;

View File

@ -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,15 +187,18 @@ 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());
if(gRender == nullptr){
@ -205,6 +210,8 @@ void MainWindow::on_pushButton_clicked()
mDetectResut->StartRender();
ui->pushButton->setText(QString::asprintf("正在采集"));
qDebug()<<ui->openGLWidget->geometry();
}else{
ui->openGLWidget->StopRender();
}

View File

@ -10,7 +10,7 @@ QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QssMainWindow
class MainWindow : public QMainWindow
{
Q_OBJECT

View File

@ -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">