parent
ed54e9fbd9
commit
93873316c1
20 changed files with 329 additions and 82 deletions
@ -0,0 +1,21 @@ |
||||
Import('qt_env', 'ui_libs', 'qt_libs', 'qt_ui', 'replay_lib', 'asset_obj', 'arch', 'common', 'messaging', 'visionipc', 'cereal') |
||||
|
||||
clip_env = qt_env.Clone() |
||||
clip_env['CCFLAGS'] += ['-Wno-deprecated-declarations'] |
||||
|
||||
base_frameworks = clip_env["FRAMEWORKS"] |
||||
base_libs = clip_env["LIBS"] |
||||
|
||||
if arch == "Darwin": |
||||
base_frameworks.append('OpenCL') |
||||
else: |
||||
base_libs.append('OpenCL') |
||||
|
||||
if arch == 'larch64': |
||||
base_libs.append('EGL') |
||||
|
||||
clip_lib_src = ["application.cc", "recorder/ffmpeg.cc", "recorder/widget.cc"] |
||||
clip_lib = clip_env.Library("clip", clip_lib_src, LIBS=base_libs, FRAMEWORKS=base_frameworks) |
||||
Export('clip_lib') |
||||
clip_libs = [clip_lib, replay_lib, cereal, 'bz2', 'zstd', 'curl', 'yuv', 'ncurses'] + base_libs + qt_libs + ui_libs + qt_ui |
||||
clip_env.Program("clip", ["main.cc", asset_obj], LIBS=clip_libs, FRAMEWORKS=base_frameworks) |
@ -0,0 +1,56 @@ |
||||
#include "tools/clip/application.h" |
||||
|
||||
#include <QApplication> |
||||
#include <QTranslator> |
||||
#include <selfdrive/ui/qt/util.h> |
||||
#include <selfdrive/ui/qt/window.h> |
||||
|
||||
#include "recorder/widget.h" |
||||
|
||||
Application::Application(int argc, char *argv[]) { |
||||
initApp(argc, argv); |
||||
|
||||
app = new QApplication(argc, argv); |
||||
|
||||
QString outputFile = "/Users/trey/Desktop/out.mp4"; |
||||
|
||||
QTranslator translator; |
||||
QString translation_file = QString::fromStdString(Params().get("LanguageSetting")); |
||||
if (!translator.load(QString(":/%1").arg(translation_file)) && translation_file.length()) { |
||||
qCritical() << "Failed to load translation file:" << translation_file; |
||||
} |
||||
|
||||
app->installTranslator(&translator); |
||||
|
||||
window = new OnroadWindow(); |
||||
|
||||
recorderThread = new QThread; |
||||
recorder = new Recorder; |
||||
recorder->moveToThread(recorderThread); |
||||
QObject::connect(recorderThread, &QThread::finished, recorder, &QObject::deleteLater); |
||||
recorderThread->start(); |
||||
QObject::connect(window, &OnroadWindow::drewOnroadFrame, recorder, &Recorder::saveFrame, Qt::QueuedConnection); |
||||
|
||||
window->setAttribute(Qt::WA_DontShowOnScreen); |
||||
window->setAttribute(Qt::WA_Mapped); |
||||
window->setAttribute(Qt::WA_NoSystemBackground); |
||||
} |
||||
|
||||
void Application::close() const { |
||||
recorderThread->quit(); |
||||
app->quit(); |
||||
} |
||||
|
||||
Application::~Application() { |
||||
delete recorder; |
||||
delete recorderThread; |
||||
delete window; |
||||
delete app; |
||||
} |
||||
|
||||
int Application::exec() const { |
||||
setMainWindow(window); |
||||
return app->exec(); |
||||
} |
||||
|
||||
|
@ -0,0 +1,18 @@ |
||||
#pragma once |
||||
#include <selfdrive/ui/qt/onroad/onroad_home.h> |
||||
|
||||
#include "recorder/widget.h" |
||||
|
||||
|
||||
class Application { |
||||
public: |
||||
Application(int argc, char* argv[]); |
||||
~Application(); |
||||
int exec() const; |
||||
void close() const; |
||||
private: |
||||
QApplication *app; |
||||
QThread *recorderThread = nullptr; |
||||
Recorder *recorder = nullptr; |
||||
OnroadWindow *window; |
||||
}; |
Binary file not shown.
@ -0,0 +1,42 @@ |
||||
#include <iostream> |
||||
#include <selfdrive/ui/ui.h> |
||||
|
||||
#include "application.h" |
||||
#include "tools/replay/replay.h" |
||||
|
||||
void startReplayThread() { |
||||
std::vector<std::string> allow = (std::vector<std::string>{ |
||||
"modelV2", "controlsState", "liveCalibration", "radarState", "deviceState", |
||||
"pandaStates", "carParams", "driverMonitoringState", "carState", "driverStateV2", |
||||
"wideRoadCameraState", "managerState", "selfdriveState", "longitudinalPlan", |
||||
}); |
||||
|
||||
std::vector<std::string> block; |
||||
Replay replay("a2a0ccea32023010|2023-07-27--13-01-19", allow, block); |
||||
|
||||
if (!replay.load()) { |
||||
return; |
||||
} |
||||
|
||||
std::cout << "Replay started." << std::endl; |
||||
replay.setEndSeconds(66); |
||||
replay.start(60); |
||||
replay.waitUntilEnd(); |
||||
std::cout << "Replay ended." << std::endl; |
||||
raise(SIGINT); |
||||
} |
||||
|
||||
int main(int argc, char *argv[]) { |
||||
Application a(argc, argv); |
||||
|
||||
std::thread thread(startReplayThread); |
||||
std::this_thread::sleep_for(std::chrono::milliseconds(2000)); |
||||
|
||||
if (a.exec()) { |
||||
std::cerr << "Failed to start app." << std::endl; |
||||
} |
||||
|
||||
thread.join(); |
||||
a.close(); |
||||
return 0; |
||||
} |
@ -0,0 +1,125 @@ |
||||
/****************************************************************************
|
||||
** Meta object code from reading C++ file 'widget.h' |
||||
** |
||||
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.15.16) |
||||
** |
||||
** WARNING! All changes made in this file will be lost! |
||||
*****************************************************************************/ |
||||
|
||||
#include <memory> |
||||
#include "widget.h" |
||||
#include <QtCore/qbytearray.h> |
||||
#include <QtCore/qmetatype.h> |
||||
#if !defined(Q_MOC_OUTPUT_REVISION) |
||||
#error "The header file 'widget.h' doesn't include <QObject>." |
||||
#elif Q_MOC_OUTPUT_REVISION != 67 |
||||
#error "This file was generated using the moc from 5.15.16. It" |
||||
#error "cannot be used with the include files from this version of Qt." |
||||
#error "(The moc has changed too much.)" |
||||
#endif |
||||
|
||||
QT_BEGIN_MOC_NAMESPACE |
||||
QT_WARNING_PUSH |
||||
QT_WARNING_DISABLE_DEPRECATED |
||||
struct qt_meta_stringdata_Recorder_t { |
||||
QByteArrayData data[6]; |
||||
char stringdata0[39]; |
||||
}; |
||||
#define QT_MOC_LITERAL(idx, ofs, len) \ |
||||
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
|
||||
qptrdiff(offsetof(qt_meta_stringdata_Recorder_t, stringdata0) + ofs \
|
||||
- idx * sizeof(QByteArrayData)) \
|
||||
) |
||||
static const qt_meta_stringdata_Recorder_t qt_meta_stringdata_Recorder = { |
||||
{ |
||||
QT_MOC_LITERAL(0, 0, 8), // "Recorder"
|
||||
QT_MOC_LITERAL(1, 9, 9), // "saveFrame"
|
||||
QT_MOC_LITERAL(2, 19, 0), // ""
|
||||
QT_MOC_LITERAL(3, 20, 7), // "QImage*"
|
||||
QT_MOC_LITERAL(4, 28, 5), // "frame"
|
||||
QT_MOC_LITERAL(5, 34, 4) // "stop"
|
||||
|
||||
}, |
||||
"Recorder\0saveFrame\0\0QImage*\0frame\0" |
||||
"stop" |
||||
}; |
||||
#undef QT_MOC_LITERAL |
||||
|
||||
static const uint qt_meta_data_Recorder[] = { |
||||
|
||||
// content:
|
||||
8, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
2, 14, // methods
|
||||
0, 0, // properties
|
||||
0, 0, // enums/sets
|
||||
0, 0, // constructors
|
||||
0, // flags
|
||||
0, // signalCount
|
||||
|
||||
// slots: name, argc, parameters, tag, flags
|
||||
1, 1, 24, 2, 0x0a /* Public */, |
||||
5, 0, 27, 2, 0x0a /* Public */, |
||||
|
||||
// slots: parameters
|
||||
QMetaType::Void, 0x80000000 | 3, 4, |
||||
QMetaType::Void, |
||||
|
||||
0 // eod
|
||||
}; |
||||
|
||||
void Recorder::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) |
||||
{ |
||||
if (_c == QMetaObject::InvokeMetaMethod) { |
||||
auto *_t = static_cast<Recorder *>(_o); |
||||
(void)_t; |
||||
switch (_id) { |
||||
case 0: _t->saveFrame((*reinterpret_cast< QImage*(*)>(_a[1]))); break; |
||||
case 1: _t->stop(); break; |
||||
default: ; |
||||
} |
||||
} |
||||
} |
||||
|
||||
QT_INIT_METAOBJECT const QMetaObject Recorder::staticMetaObject = { { |
||||
QMetaObject::SuperData::link<QObject::staticMetaObject>(), |
||||
qt_meta_stringdata_Recorder.data, |
||||
qt_meta_data_Recorder, |
||||
qt_static_metacall, |
||||
nullptr, |
||||
nullptr |
||||
} }; |
||||
|
||||
|
||||
const QMetaObject *Recorder::metaObject() const |
||||
{ |
||||
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; |
||||
} |
||||
|
||||
void *Recorder::qt_metacast(const char *_clname) |
||||
{ |
||||
if (!_clname) return nullptr; |
||||
if (!strcmp(_clname, qt_meta_stringdata_Recorder.stringdata0)) |
||||
return static_cast<void*>(this); |
||||
return QObject::qt_metacast(_clname); |
||||
} |
||||
|
||||
int Recorder::qt_metacall(QMetaObject::Call _c, int _id, void **_a) |
||||
{ |
||||
_id = QObject::qt_metacall(_c, _id, _a); |
||||
if (_id < 0) |
||||
return _id; |
||||
if (_c == QMetaObject::InvokeMetaMethod) { |
||||
if (_id < 2) |
||||
qt_static_metacall(this, _c, _id, _a); |
||||
_id -= 2; |
||||
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { |
||||
if (_id < 2) |
||||
*reinterpret_cast<int*>(_a[0]) = -1; |
||||
_id -= 2; |
||||
} |
||||
return _id; |
||||
} |
||||
QT_WARNING_POP |
||||
QT_END_MOC_NAMESPACE |
@ -1,51 +0,0 @@ |
||||
#include "tools/replay/clip/application.h" |
||||
|
||||
#include <QApplication> |
||||
#include <QTranslator> |
||||
#include <selfdrive/ui/qt/util.h> |
||||
#include <selfdrive/ui/qt/window.h> |
||||
|
||||
#include "recorder/widget.h" |
||||
|
||||
Application::Application() { |
||||
|
||||
} |
||||
|
||||
Application::~Application() { |
||||
|
||||
} |
||||
|
||||
int Application::exec(int argc, char *argv[]) { |
||||
initApp(argc, argv); |
||||
|
||||
QApplication a(argc, argv); |
||||
|
||||
QString outputFile = "/Users/trey/Desktop/out.mp4"; |
||||
|
||||
QTranslator translator; |
||||
QString translation_file = QString::fromStdString(Params().get("LanguageSetting")); |
||||
if (!translator.load(QString(":/%1").arg(translation_file)) && translation_file.length()) { |
||||
qCritical() << "Failed to load translation file:" << translation_file; |
||||
} |
||||
|
||||
a.installTranslator(&translator); |
||||
|
||||
OnroadWindow w; |
||||
|
||||
QThread recorderThread; |
||||
Recorder recorder; |
||||
recorder.moveToThread(&recorderThread); |
||||
QObject::connect(&recorderThread, &QThread::finished, &recorder, &QObject::deleteLater); |
||||
QObject::connect(&w, &OnroadWindow::drewOnroadFrame, &recorder, &Recorder::saveFrame, Qt::QueuedConnection); |
||||
recorderThread.start(); |
||||
|
||||
w.setAttribute(Qt::WA_DontShowOnScreen); |
||||
w.setAttribute(Qt::WA_Mapped); |
||||
w.setAttribute(Qt::WA_NoSystemBackground); |
||||
w.resize(DEVICE_SCREEN_SIZE); |
||||
setMainWindow(&w); |
||||
|
||||
return a.exec(); |
||||
} |
||||
|
||||
|
@ -1,9 +0,0 @@ |
||||
#pragma once |
||||
|
||||
|
||||
class Application { |
||||
public: |
||||
Application(); |
||||
~Application(); |
||||
int exec(int argc, char* argv[]); |
||||
}; |
Loading…
Reference in new issue