Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [vince@dozer harbour-advanced-camera]$ git diff
- diff --git a/harbour-advanced-camera.pro b/harbour-advanced-camera.pro
- index 536a25a..337222a 100644
- --- a/harbour-advanced-camera.pro
- +++ b/harbour-advanced-camera.pro
- @@ -25,7 +25,8 @@ SOURCES += src/harbour-advanced-camera.cpp \
- src/focusmodel.cpp \
- src/flashmodel.cpp \
- src/fsoperations.cpp \
- - src/resourcehandler.cpp
- + src/resourcehandler.cpp \
- + src/framegrabber.cpp
- DISTFILES += rpm/harbour-advanced-camera.changes.in \
- rpm/harbour-advanced-camera.changes.run.in \
- @@ -70,6 +71,7 @@ HEADERS += \
- src/focusmodel.h \
- src/flashmodel.h \
- src/fsoperations.h \
- - src/resourcehandler.h
- + src/resourcehandler.h \
- + src/framegrabber.h
- LIBS += -ldl
- diff --git a/qml/pages/VideoPlayer.qml b/qml/pages/VideoPlayer.qml
- index 9685679..10153d7 100644
- --- a/qml/pages/VideoPlayer.qml
- +++ b/qml/pages/VideoPlayer.qml
- @@ -36,12 +36,33 @@ Page {
- }
- }
- + FrameGrabber {
- + id: frameGrabber
- +
- + active: false
- +
- + onActiveChanged: {
- + console.log("FrameGrabber: onActiveChanged:", active);
- + }
- +
- + onFinished: {
- + console.log("FrameGrabber: finished!");
- + active = false;
- + animFlash.start();
- + var path = fsOperations.writableLocation("image") + "/AdvancedCam/PIC_" + Qt.formatDateTime(new Date(), "yyyyMMdd_hhmmss") + ".jpg"
- + result.saveToFile(path);
- + console.log("Snapshot taken:", path);
- + fileList.append({ filePath: path, isVideo: false });
- + }
- + }
- +
- VideoOutput {
- id: video
- anchors.fill: parent
- source: player
- fillMode: VideoOutput.PreserveAspectFit
- + filters: [ frameGrabber ]
- MouseArea {
- anchors.fill: parent
- @@ -51,6 +72,14 @@ Page {
- }
- }
- + Rectangle {
- + id: rectFlash
- + anchors.fill: parent
- + opacity: 0
- +
- + NumberAnimation on opacity {id:animFlash; from: 1.0; to: 0.0; duration: 200 }
- + }
- +
- Item {
- id: itemsControls
- anchors.fill: parent
- @@ -113,24 +142,11 @@ Page {
- }
- onClicked: {
- - video.grabToImage(function (image) {
- - animFlash.start();
- - var path = fsOperations.writableLocation("image") + "/AdvancedCam/PIC_" + Qt.formatDateTime(new Date(), "yyyyMMdd_hhmmss") + ".jpg"
- - image.saveToFile(path);
- - console.log("Snapshot taken:", path);
- - fileList.append({ filePath: path, isVideo: false });
- - });
- + console.log("Snapshot button clicked!");
- + frameGrabber.active = true;
- }
- }
- - Rectangle {
- - id: rectFlash
- - anchors.fill: parent
- - opacity: 0
- -
- - NumberAnimation on opacity {id:animFlash; from: 1.0; to: 0.0; duration: 200 }
- - }
- -
- Row {
- id: rowBottomVideo
- diff --git a/src/framegrabber.cpp b/src/framegrabber.cpp
- index adf8081..f20ac03 100644
- --- a/src/framegrabber.cpp
- +++ b/src/framegrabber.cpp
- @@ -1,6 +1,38 @@
- #include "framegrabber.h"
- +#include <QDebug>
- +#include <QImage>
- -FrameGrabber::FrameGrabber()
- +FrameGrabberRunnable::FrameGrabberRunnable(FrameGrabber *filter) :
- + m_filter(filter)
- {
- + qDebug() << "FrameGrabber constructor !";
- +}
- +
- +QVideoFilterRunnable *FrameGrabber::createFilterRunnable()
- +{
- + qDebug() << "FrameGrabber::createFilterRunnable() !!!";
- + return new FrameGrabberRunnable(this);
- +}
- +
- +QVideoFrame FrameGrabberRunnable::run(QVideoFrame *input, const QVideoSurfaceFormat &surface, RunFlags flags)
- +{
- + Q_UNUSED(surface);
- + Q_UNUSED(flags);
- +
- + qDebug() << "FrameGrabberRunnable::run() !!!";
- + if (!input->isValid() ||
- + (input->handleType() != QAbstractVideoBuffer::NoHandle && input->handleType() != QAbstractVideoBuffer::GLTextureHandle))
- + {
- + qWarning("Invalid input format");
- + return QVideoFrame();
- + }
- + QImage img;
- + QImage::Format format = QVideoFrame::imageFormatFromPixelFormat(input->pixelFormat());
- + if (format != QImage::Format_Invalid)
- + img = QImage(input->bits(), input->width(), input->height(), format);
- + else
- + img = QImage::fromData(input->bits(), input->mappedBytes());
- + emit m_filter->finished(new QImage(img));
- + return *input;
- }
- diff --git a/src/framegrabber.h b/src/framegrabber.h
- index 95399d3..044d9ee 100644
- --- a/src/framegrabber.h
- +++ b/src/framegrabber.h
- @@ -1,11 +1,29 @@
- #ifndef FRAMEGRABBER_H
- #define FRAMEGRABBER_H
- +#include <QAbstractVideoFilter>
- -class FrameGrabber
- +class FrameGrabber : public QAbstractVideoFilter
- {
- + Q_OBJECT
- public:
- - FrameGrabber();
- + QVideoFilterRunnable *createFilterRunnable() Q_DECL_OVERRIDE ;
- +
- +signals:
- + void finished(QImage *result);
- +
- +private:
- + friend class FrameGrabberRunnable;
- +};
- +
- +class FrameGrabberRunnable : public QVideoFilterRunnable
- +{
- +public:
- + FrameGrabberRunnable(FrameGrabber *filter);
- + QVideoFrame run(QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags) Q_DECL_OVERRIDE ;
- +
- +private:
- + FrameGrabber *m_filter;
- };
- -#endif // FRAMEGRABBER_H
- \ No newline at end of file
- +#endif // FRAMEGRABBER_H
- diff --git a/src/harbour-advanced-camera.cpp b/src/harbour-advanced-camera.cpp
- index d2b675a..0e52b33 100644
- --- a/src/harbour-advanced-camera.cpp
- +++ b/src/harbour-advanced-camera.cpp
- @@ -17,6 +17,7 @@
- #include "flashmodel.h"
- #include "fsoperations.h"
- #include "resourcehandler.h"
- +#include "framegrabber.h"
- int main(int argc, char *argv[])
- {
- @@ -40,6 +41,7 @@ int main(int argc, char *argv[])
- qmlRegisterType<FocusModel>("uk.co.piggz.harbour_advanced_camera", 1, 0, "FocusModel");
- qmlRegisterType<FlashModel>("uk.co.piggz.harbour_advanced_camera", 1, 0, "FlashModel");
- qmlRegisterType<FSOperations>("uk.co.piggz.harbour_advanced_camera", 1, 0, "FSOperations");
- + qmlRegisterType<FrameGrabber>("uk.co.piggz.harbour_advanced_camera", 1, 0, "FrameGrabber");
- ResolutionModel resolutionModel;
- QSortFilterProxyModel sortedResolutionModel;
- diff --git a/translations/harbour-advanced-camera-fr.ts b/translations/harbour-advanced-camera-fr.ts
- index a8ca50e..ce9332b 100644
- --- a/translations/harbour-advanced-camera-fr.ts
- +++ b/translations/harbour-advanced-camera-fr.ts
- @@ -296,7 +296,7 @@
- <context>
- <name>GalleryUI</name>
- <message>
- - <location filename="../qml/pages/GalleryUI.qml" line="79"/>
- + <location filename="../qml/pages/GalleryUI.qml" line="80"/>
- <source>Deleting %1</source>
- <translation type="unfinished"></translation>
- </message>
- [vince@dozer harbour-advanced-camera]$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement