/
SM_DAMIR
/
limb
Обзор
Документация
Войти
/
SM_DAMIR
/
limb
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/processingworker.h
126 строк
4 KB
DamirSM
chore: init
16 июл 2026, 12:14
16 июл 2026, 12:14
bb10094
Код
Авторство
О чём код?
#ifndef PROCESSINGWORKER_H #define PROCESSINGWORKER_H #include <QObject> #include <QImage> #include <QString> #include <QElapsedTimer> #include <net.h> class ProcessingWorker : public QObject { Q_OBJECT public: explicit ProcessingWorker(QObject *parent = nullptr); ~ProcessingWorker(); public slots: void loadImage(const QString &filePath); void removeBackground(int objectType = 0); void blurBackground(int objectType = 0, int radius = 12); void colorBackground(int objectType = 0, int r = 0, int g = 0, int b = 0); void gradientBackground( int objectType = 0, int r1 = 30, int g1 = 30, int b1 = 80, int r2 = 200, int g2 = 100, int b2 = 200); void applyEnhancement(int brightness, int contrast, int whiteBalance); void applyZeroDCE(); void applyStyle(int styleIndex, int strength = 100); void detectObject(int objectType = 0); void resetToOriginal(); void cancelOperation(const QImage &baseImage, int brightness, int contrast, int whiteBalance, int styleIndex, int styleStrength, bool useZeroDCE); void restoreState(const QImage &baseImage, int brightness, int contrast, int whiteBalance, int styleIndex, int styleStrength, bool useZeroDCE); signals: void imageLoaded(const QImage &image); void processingFinished(const QImage &result, const QImage &base); void previewFinished(const QImage &preview); void processingProgress(int percent); void errorOccurred(const QString &message); void timingMeasured(const QString &stage, qint64 ms); private: bool loadModnetIfNeeded(); bool loadStyleIfNeeded(int styleIndex); bool loadZeroDCEIfNeeded(); QImage runModnet(const QImage &image); QImage runStyleTransfer(const QImage &image, int styleIndex, int strength); QImage runZeroDCE(const QImage &image); QImage applyMaskToBackground(const QImage &original, const QImage &mask, int mode, int r, int g, int b, int blurRadius); QImage applyGradientBackground(const QImage &original, const QImage &mask, int r1, int g1, int b1, int r2, int g2, int b2); QImage applyManualEnhancement(const QImage &image, int brightness, int contrast, int whiteBalance); QImage fastBoxBlur(const QImage &src, int radius); QImage drawSelectionContour(const QImage &original, const QImage &mask, int objectType); void updateEnhanced(); void updateCurrent(); QImage m_original; QImage m_base; QImage m_enhanced; QImage m_current; ncnn::Net m_modnet; ncnn::Net m_styleNet; ncnn::Net m_zeroDCE; bool m_modnetLoaded = false; int m_loadedStyleIndex = -1; bool m_zeroDCELoaded = false; bool m_useZeroDCE = false; int m_brightness = 0; int m_contrast = 0; int m_whiteBalance = 0; int m_styleIndex = -1; int m_styleStrength = 100; volatile bool m_cancelled = false; QString m_modelBasePath; static const int MAX_INPUT_SIZE = 512; static const int NET_W = 320; static const int NET_H = 320; }; #endif