ToolX 1.11.1 [e3f477f]
A GUI debug tool chain for diagnosing GVA systems
Loading...
Searching...
No Matches
gige_player.h
Go to the documentation of this file.
1//
2// Copyright (c) 2026, Astute Systems PTY LTD
3//
4// This file is part of the VivoeX project developed by Astute Systems.
5//
6// License. See the LICENSE file in the project root for full license details.
7//
12
13#ifndef STREAMS_GIGE_PLAYER_H
14#define STREAMS_GIGE_PLAYER_H
15
16#include <atomic>
17#include <memory>
18#include <mutex>
19#include <thread>
20#include <vector>
21
22#include <QDialog>
23#include <QElapsedTimer>
24#include <QGraphicsPixmapItem>
25#include <QGraphicsScene>
26#include <QGraphicsView>
27#include <QLabel>
28#include <QObject>
29#include <QPixmap>
30#include <QPointer>
31#include <QStatusBar>
32#include <QString>
33#include <QTimer>
34
35#include "mediax/gev/gev.h"
36
42class GigEPlayer : public QObject
43{
44 Q_OBJECT
45
46public:
52 explicit GigEPlayer(QWidget *parent = nullptr);
53
57 ~GigEPlayer() final;
58
64 static int activeCount();
65public slots:
72 void play(const QString name, const QString ip_address);
73
77 void renderFrame();
78
82 void noFrame();
83
84protected:
86 bool eventFilter(QObject *obj, QEvent *event) override;
87
88private:
90 void connectionResult(bool success, const QString &message);
92 void onFrame(::mediax::gev::Frame &&frame);
94 void shutdown();
95
97 QPointer<QDialog> m_dialog;
99 QGraphicsScene *m_scene = nullptr;
101 QGraphicsView *m_view = nullptr;
103 QGraphicsPixmapItem *m_pixmapItem = nullptr;
105 QPixmap m_pixmap;
107 QStatusBar *m_status_bar = nullptr;
109 QLabel *m_stream_label = nullptr;
111 QLabel *m_format_label = nullptr;
113 QLabel *m_frame_label = nullptr;
118
120 std::unique_ptr<::mediax::gev::Camera> m_camera;
122 std::thread m_connect_thread;
124 std::atomic<bool> m_closing{ false };
126 std::atomic<bool> m_connected{ false };
127
129 std::mutex m_frame_mutex;
131 ::mediax::gev::Frame m_pending_frame;
133 bool m_frame_pending = false;
135 std::atomic<uint64_t> m_frame_count{ 0 };
137 std::vector<uint8_t> m_convert_buffer;
138};
139
140#endif // STREAMS_GIGE_PLAYER_H
std::atomic< bool > m_connected
The connection succeeded, the camera can be read from the GUI thread.
Definition gige_player.h:126
std::atomic< uint64_t > m_frame_count
Frames received.
Definition gige_player.h:135
QGraphicsPixmapItem * m_pixmapItem
The pixmap item, kept to avoid flicker.
Definition gige_player.h:103
std::unique_ptr<::mediax::gev::Camera > m_camera
The device, set by the connection thread. Acquisition runs while it is held.
Definition gige_player.h:120
QLabel * m_stream_label
Device address label.
Definition gige_player.h:109
QPointer< QDialog > m_dialog
The player dialog.
Definition gige_player.h:97
GigEPlayer(QWidget *parent=nullptr)
Construct a new GigE player and show the window.
Definition gige_player.cpp:37
QGraphicsScene * m_scene
The scene.
Definition gige_player.h:99
std::atomic< bool > m_closing
Set when the player is being destroyed.
Definition gige_player.h:124
void renderFrame()
Render the latest received frame at the display rate.
Definition gige_player.cpp:174
QLabel * m_format_label
Resolution and pixel format label.
Definition gige_player.h:111
std::vector< uint8_t > m_convert_buffer
Conversion buffer (RGB24).
Definition gige_player.h:137
void connectionResult(bool success, const QString &message)
Called on the GUI thread when the connection attempt completes.
Definition gige_player.cpp:151
std::thread m_connect_thread
Connects and starts acquisition without blocking the GUI.
Definition gige_player.h:122
QTimer m_render_timer
Display refresh timer.
Definition gige_player.h:115
QTimer m_blank_timer
No-frame blanking timer.
Definition gige_player.h:117
void onFrame(::mediax::gev::Frame &&frame)
Frame callback, runs on the receive thread.
Definition gige_player.cpp:164
::mediax::gev::Frame m_pending_frame
The latest frame from the receive thread.
Definition gige_player.h:131
void noFrame()
Blank the display when no frames are arriving.
Definition gige_player.cpp:217
QLabel * m_frame_label
Frame counter label.
Definition gige_player.h:113
QPixmap m_pixmap
The displayed image.
Definition gige_player.h:105
~GigEPlayer() final
Stop the acquisition and close the window.
Definition gige_player.cpp:85
QStatusBar * m_status_bar
The status bar.
Definition gige_player.h:107
static int activeCount()
The number of open GigE player windows.
Definition gige_player.cpp:92
void shutdown()
Stop the connection thread and the camera.
Definition gige_player.cpp:97
bool eventFilter(QObject *obj, QEvent *event) override
Event filter to keep the image fitted to the dialog on resize.
Definition gige_player.cpp:223
QGraphicsView * m_view
The view.
Definition gige_player.h:101
bool m_frame_pending
A new frame is waiting to be rendered.
Definition gige_player.h:133
std::mutex m_frame_mutex
Guards the pending frame.
Definition gige_player.h:129
void play(const QString name, const QString ip_address)
Connect to a device and start acquisition.
Definition gige_player.cpp:113