diff --git a/grabber.cpp b/grabber.cpp index e12759c..4c00e02 100644 --- a/grabber.cpp +++ b/grabber.cpp @@ -10,7 +10,7 @@ void Grabber::run() { Pylon::CInstantCamera *cam = camera->getCamera(); cam->StartGrabbing(); while (!stop_request) { - camera->frameRate(25); + camera->frameRate(50); MyImage img; cam->RetrieveResult( 5000, frame, Pylon::TimeoutHandling_ThrowException); img.setFrame(frame); diff --git a/pylonrecorder.cpp b/pylonrecorder.cpp index 29db7e4..f10d8c4 100644 --- a/pylonrecorder.cpp +++ b/pylonrecorder.cpp @@ -41,8 +41,9 @@ PylonRecorder::PylonRecorder(QWidget *parent) scrollArea->setVisible(false); setCentralWidget(scrollArea); pylon = new PylonWrapper(); - buffer = new ImageBuffer(); + buffer = new ImageBuffer(1000); grabber = new Grabber(pylon, buffer); + writer = new Writer(buffer); createActions(); updateActions(); @@ -69,6 +70,7 @@ PylonRecorder::~PylonRecorder(){ delete pylon; delete buffer; delete grabber; + delete writer; } bool PylonRecorder::loadFile(const QString &fileName) { @@ -384,17 +386,32 @@ void PylonRecorder::disconnectCamera() { } void PylonRecorder::startRecording() { + VideoSpecs specs; + specs.fps = 25; + specs.filename = "Test.mp4"; + ImageSettings settings = pylon->getImageSettings(); + specs.width = static_cast(settings.width); + specs.height= static_cast(settings.height); + specs.pixelType = settings.pixelType; + specs.orientation = settings.orientation; + specs.quality = 95; + writer->setVideoSpecs(specs); buffer->clear(); grabber->start(); + writer->start(); grabbing = true; + + preassureTimer->start(50); + frameTimer->start(50); updateActions(); - preassureTimer->start(25); - frameTimer->start(100); + } void PylonRecorder::stopRecording() { grabber->requestStop(); + writer->requestStop(); grabber->wait(10000); + writer->wait(10000); grabbing = false; frameTimer->stop(); preassureTimer->stop(); diff --git a/pylonrecorder.h b/pylonrecorder.h index 04d9739..cf049fa 100644 --- a/pylonrecorder.h +++ b/pylonrecorder.h @@ -6,6 +6,7 @@ #include "pylonwrapper.h" #include "imagebuffer.h" #include "grabber.h" +#include "writer.h" #include #if defined(QT_PRINTSUPPORT_LIB) @@ -78,6 +79,7 @@ private: PylonWrapper *pylon; ImageBuffer *buffer; Grabber *grabber; + Writer *writer; bool grabbing; QPalette progressPalette; diff --git a/pylonwrapper.cpp b/pylonwrapper.cpp index f12684a..d9c80e4 100644 --- a/pylonwrapper.cpp +++ b/pylonwrapper.cpp @@ -65,8 +65,11 @@ ImageSettings PylonWrapper::getImageSettings() { Pylon::CIntegerParameter width( camera->GetNodeMap(), "Width"); Pylon::CIntegerParameter height( camera->GetNodeMap(), "Height"); Pylon::CEnumParameter pixelFormat( camera->GetNodeMap(), "PixelFormat"); + Pylon::CPixelTypeMapper pixelTypeMapper(&pixelFormat); + settings.pixelType = pixelTypeMapper.GetPylonPixelTypeFromNodeValue(pixelFormat.GetIntValue()); settings.width = width.GetValue(); settings.height = height.GetValue(); + settings.orientation = Pylon::EImageOrientation::ImageOrientation_TopDown; } return settings; } diff --git a/pylonwrapper.h b/pylonwrapper.h index 096bbd2..66f14d1 100644 --- a/pylonwrapper.h +++ b/pylonwrapper.h @@ -8,6 +8,8 @@ struct ImageSettings { int64_t width = 0; int64_t height = 0; + Pylon::EPixelType pixelType; + Pylon::EImageOrientation orientation; }; class PylonWrapper diff --git a/recorder.pro b/recorder.pro index 480b17f..a7f160c 100644 --- a/recorder.pro +++ b/recorder.pro @@ -7,14 +7,16 @@ HEADERS = \ imagebuffer.h \ myimage.h \ pylonrecorder.h \ - pylonwrapper.h + pylonwrapper.h \ + writer.h SOURCES = \ grabber.cpp \ imagebuffer.cpp \ myimage.cpp \ pylonrecorder.cpp \ pylonwrapper.cpp \ - main.cpp + main.cpp \ + writer.cpp # install target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/imageviewer