You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Software_Architecture/mediamodule/example_viewer.cpp

39 lines
1.1 KiB

#include <QApplication>
#include <QLabel>
#include <QVBoxLayout>
#include <QHostAddress>
#include "camera_streamer.h"
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
// 主窗口
QWidget window;
window.setWindowTitle("Unitree Camera Viewer");
auto *layout = new QVBoxLayout(&window);
QLabel *label = new QLabel(&window);
label->setAlignment(Qt::AlignCenter);
layout->addWidget(label);
CameraStreamer streamer;
QObject::connect(&streamer, &CameraStreamer::newFrame, &window, [label](const QImage &img){
label->setPixmap(QPixmap::fromImage(img).scaled(label->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
});
// 根据实际情况修改远端用户名、IP、端口
QString remoteUser = "unitree";
QString remoteHost = "192.168.123.10"; // 狗端 IP
streamer.startStreaming(remoteUser, remoteHost);
window.resize(960, 540);
window.show();
int ret = app.exec();
streamer.stopStreaming();
return ret;
}