mirror of
https://gitlab.com/eql/lqml.git
synced 2026-03-12 09:41:29 -07:00
example 'camera': fix orientation of both video and saved images
This commit is contained in:
parent
5ca13c542b
commit
c18b2c13e9
11 changed files with 142 additions and 9 deletions
33
examples/camera/cpp/qt.cpp
Normal file
33
examples/camera/cpp/qt.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "qt.h"
|
||||
#include <QImage>
|
||||
#include <QtDebug>
|
||||
|
||||
#ifdef PLUGIN
|
||||
#include <ecl_fun_plugin.h>
|
||||
#else
|
||||
#include <ecl_fun.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QObject* ini() {
|
||||
static QObject* qt = nullptr;
|
||||
if (qt == nullptr) {
|
||||
qt = new QT;
|
||||
#ifdef PLUGIN
|
||||
ini_lisp();
|
||||
#endif
|
||||
}
|
||||
return qt;
|
||||
}
|
||||
|
||||
QVariant QT::rotateImage(const QVariant& imagePath, const QVariant& angle) {
|
||||
// rotates image, replacing it; must be called from the UI thread, see QRUN*
|
||||
QString path(imagePath.toString());
|
||||
QImage img(path);
|
||||
QImage rotated = img.transformed(QTransform().rotate(angle.toReal()));
|
||||
rotated.save(path);
|
||||
return imagePath;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
22
examples/camera/cpp/qt.h
Normal file
22
examples/camera/cpp/qt.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
#ifdef Q_CC_MSVC
|
||||
#define LIB_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define LIB_EXPORT
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
extern "C" { LIB_EXPORT QObject* ini(); }
|
||||
|
||||
class QT : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_INVOKABLE QVariant rotateImage(const QVariant&, const QVariant&);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
27
examples/camera/cpp/qt.pro
Normal file
27
examples/camera/cpp/qt.pro
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
QT += gui
|
||||
TEMPLATE = lib
|
||||
CONFIG += c++17 plugin release no_keywords
|
||||
DEFINES += PLUGIN
|
||||
INCLUDEPATH = /usr/local/include ../../../src/cpp
|
||||
LIBS = -L/usr/local/lib -lecl
|
||||
DESTDIR = ./
|
||||
TARGET = qt
|
||||
OBJECTS_DIR = ./tmp/
|
||||
MOC_DIR = ./tmp/
|
||||
|
||||
HEADERS += qt.h
|
||||
SOURCES += qt.cpp
|
||||
|
||||
linux {
|
||||
LIBS += -L../../../platforms/linux/lib
|
||||
}
|
||||
|
||||
macx {
|
||||
LIBS += -L../../../platforms/macos/lib
|
||||
}
|
||||
|
||||
win32 {
|
||||
include(../../../src/windows.pri)
|
||||
|
||||
LIBS += -L../../../platforms/windows/lib
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue