#include "mainwindow.h" #include "ui_mainwindow.h" #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); const std::string stream_url = "http://localhost:8080/?action=stream"; cv::VideoCapture cap(stream_url); if (!cap.isOpened()) { qDebug() << "Failed to open MJPEG Streamer video capture"; return; } QTimer* timer = new QTimer(this); connect(timer, &QTimer::timeout, [=]() { cv::Mat frame; cap.read(frame); if (frame.empty()) { qDebug() << "Failed to capture MJPEG Streamer video frame"; return; } QImage qimg((uchar*)frame.data, frame.cols, frame.rows, frame.step, QImage::Format_RGB888); ui->label->setPixmap(QPixmap::fromImage(qimg)); }); timer->start(33); } MainWindow::~MainWindow() { delete ui; }