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/camera_streamer.h

35 lines
1.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include <QObject>
#include <QProcess>
#include <atomic>
#include <thread>
#include <opencv2/opencv.hpp>
class CameraStreamer : public QObject
{
Q_OBJECT
public:
explicit CameraStreamer(QObject *parent = nullptr);
~CameraStreamer();
// remoteUser@remoteHost 远程 ssh 登录信息remoteCommand 为远端启动摄像头流的命令
// localPort 本机接收 UDP 端口SDK 默认 9201
bool startStreaming(const QString &remoteUser,
const QString &remoteHost,
const QString &remoteCommand = "cd ~/UnitreecameraSDK && ./bins/example_putImagetrans",
int localPort = 9201);
void stopStreaming();
signals:
// 每当收到一帧图像时发射,供 Qt 前端显示
void newFrame(const QImage &image);
private:
void captureLoop(int localPort);
QProcess *m_sshProcess {nullptr};
std::thread m_captureThread;
std::atomic<bool> m_running {false};
};