diff --git a/CMakeLists.txt b/CMakeLists.txt index 3180efd..c8bcff6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,10 +42,11 @@ find_package (NIX REQUIRED) include_directories (AFTER ${NIX_INCLUDE_DIR}) # ####################################### -# # OPENCV -# find_package(OpenCV REQUIRED opencv_highgui opencv_core) -# include_directories(AFTER ${OpenCV_INCLUDE_DIRS} ) -# set(LINK_LIBS ${LINK_LIBS} ${OpenCV_LIBRARIES}) +# OPENCV +message ("=> finding opencv ...") +find_package(OpenCV REQUIRED opencv_highgui opencv_core) +include_directories(AFTER ${OpenCV_INCLUDE_DIRS} ) +set(LINK_LIBS ${LINK_LIBS} ${OpenCV_LIBRARIES}) ####################################### # Pylon @@ -57,5 +58,5 @@ file (GLOB RECORDER_SOURCES *.cpp) file (GLOB RECORDER_INCLUDES *.hpp) add_executable ( recorder ${RECORDER_SOURCES} ${RECORDER_INCLUDES} ${RECORDER_RES_SOURCES} ) target_include_directories ( recorder PUBLIC "${PROJECT_BINARY_DIR}" ) -target_link_libraries ( recorder Qt5::PrintSupport Qt5::Core Qt5::Widgets Qt5::Gui ${NIX_LIBRARIES} pylon::pylon) +target_link_libraries ( recorder Qt5::PrintSupport Qt5::Core Qt5::Widgets Qt5::Gui ${NIX_LIBRARIES} pylon::pylon ${OpenCV_LIBRARIES}) # ${PYLON_LIBRARIES} ${OpenCV_LIBRARIES}) \ No newline at end of file diff --git a/dualcamwrapper.cpp b/dualcamwrapper.cpp index dd67936..0af1e9c 100644 --- a/dualcamwrapper.cpp +++ b/dualcamwrapper.cpp @@ -159,7 +159,6 @@ ImageSettings DualcamWrapper::getImageSettings(int camindex) { Pylon::CIntegerParameter width( nodemap, "Width" ); Pylon::CIntegerParameter height( nodemap, "Height" ); settings.pixelType = pixelType; - std::cerr << "GetImageSettings pixelType: " << pixelType << std::endl; settings.width = (uint32_t)width.GetValue(); settings.height = (uint32_t)height.GetValue(); settings.orientation = Pylon::EImageOrientation::ImageOrientation_TopDown; @@ -214,7 +213,6 @@ void DualcamWrapper::resetCamera(int camindex) { bool DualcamWrapper::openCameras(std::string &message) { qDebug() << "opening cameras"; - bool valid = true; Pylon::CTlFactory& tlFactory = Pylon::CTlFactory::GetInstance(); cameras.Initialize(2); try { diff --git a/imagebuffer.cpp b/imagebuffer.cpp index 4f7cc1d..34cd3d1 100644 --- a/imagebuffer.cpp +++ b/imagebuffer.cpp @@ -72,7 +72,6 @@ void ImageBuffer::push(MyImage *img) { buffer[head_idx] = img; framecounts[head_idx] = framecount; load = load < buffer_size ? load +=1 : buffer_size; - mutex.unlock(); } @@ -111,6 +110,6 @@ MyImage* ImageBuffer::readLast(size_t &framecount) { } ImageBuffer::~ImageBuffer(){ - std::cerr << "Image buffer destructor" << std::endl; + qDebug() << "Image buffer destructor"; clear(); } \ No newline at end of file diff --git a/pylonrecorder.cpp b/pylonrecorder.cpp index 1d2bfaf..d0c7107 100644 --- a/pylonrecorder.cpp +++ b/pylonrecorder.cpp @@ -606,7 +606,6 @@ void PylonRecorder::cameraConfigurationAborted() { void PylonRecorder::connectCamera() { this->layout = CameraLayout(); - std::cerr << this->layout.rois.size() << " " << this->layout.devices.size() << std::endl; qDebug() << "connecting camera(s)"; if (deviceList.size() == 0) { detectCameras(); @@ -644,10 +643,8 @@ void PylonRecorder::connectCamera() { updateActions(); } if (layout.mode == CameraMode::dual && layout.devices.size() == 2) { - std::cerr << "Dual MODE" << std::endl; qDebug() << "dual camera mode"; std::string message; - qDebug() << "creating dual cam wrapper"; dualcam = new DualcamWrapper(layout); bool success = dualcam->openCameras(message); if (success) { @@ -754,7 +751,7 @@ void PylonRecorder::startSinglecamRecording() { writer = nullptr; } writer = new Writer(buffer, 0); - connect(writer, SLOT(writingDone( int)), this, SLOT(writerDone( int ))); + connect(writer, SLOT(writingDone()), this, SLOT(writerDone())); writer->setVideoSpecs(specs); QSettings s; @@ -777,16 +774,14 @@ void PylonRecorder::startDualcamRecording() { qDebug() << "start dual-camera recording!"; std::string filename = createFilename("", ".mp4"); fileLabel->setText(QString::fromStdString(filename)); - qDebug() << "storing to files " << filename.c_str(); + qDebug() << "storing to file " << filename.c_str(); ImageSettings settings = dualcam->getImageSettings(0); //FIXME! qDebug() << "got image settings"; - VideoSpecs specs = getVideoSpecs(settings); specs.filename = filename; specs.format = VideoFormat::mp4; qDebug() << "got video specifications"; - if (buffer != nullptr) { buffer->clear(); delete buffer; @@ -819,7 +814,7 @@ void PylonRecorder::startDualcamRecording() { writer = nullptr; } writer = new Writer(buffer, 0); - connect(writer, SIGNAL(writingDone(int)), this, SLOT(writerDone( int ))); + connect(writer, SIGNAL(writingDone()), this, SLOT(writerDone())); writer->setVideoSpecs(specs); qDebug() << "push metadata to writer"; @@ -876,14 +871,15 @@ void PylonRecorder::stopRecording() { qDebug() << "StopRecording: clear buffer!"; if(buffer != nullptr) { buffer->clear(); - // writerDone( 0 ); // Needed? or even dangerous? + if (dryRun) + writerDone(); } } qDebug() << "StopRecording done!"; } -void PylonRecorder::writerDone(int cam) { +void PylonRecorder::writerDone() { pressureTimer->stop(); pressureBar->reset(); loadBar->reset(); diff --git a/pylonrecorder.h b/pylonrecorder.h index fa2022c..4f81c87 100644 --- a/pylonrecorder.h +++ b/pylonrecorder.h @@ -67,7 +67,7 @@ private slots: void displaySingleFrame(); void displayBufferPressure(); void displayActivity(); - void writerDone(int cam); + void writerDone(); void selectStorageLocation(); void cameraConfigurationAccepted(); void cameraConfigurationAborted(); diff --git a/writer.cpp b/writer.cpp index fe89a7d..b732b47 100644 --- a/writer.cpp +++ b/writer.cpp @@ -27,6 +27,7 @@ void Writer::writeMetadata(nix::Section &s){ } void Writer::run() { + qDebug() << "writer running!"; size_t count = 0; size_t chunksize = 256; // size_t framecount = 0; @@ -39,6 +40,8 @@ void Writer::run() { emit writingDone(this->cam_number); return; } + qDebug() << "checks done!"; + Pylon::CVideoWriter videoWriter; if (specs_valid) { stop_request = false; @@ -48,7 +51,8 @@ void Writer::run() { myFile.write((char*)&videoSpecs.width, 4); myFile.write((char*)&videoSpecs.height, 4); } else { - videoWriter.SetParameter(videoSpecs.width, videoSpecs.height, videoSpecs.pixelType, videoSpecs.fps, videoSpecs.quality); + qDebug() << "setting parameters for video"; + videoWriter.SetParameter((uint32_t)videoSpecs.width, (uint32_t)videoSpecs.height, videoSpecs.pixelType, (double)videoSpecs.fps, videoSpecs.quality); videoWriter.Open(videoSpecs.filename.c_str()); } @@ -91,6 +95,8 @@ void Writer::run() { nix::NDSize offset(1, 0); nix::NDSize current_shape(initial_shape); nix::NDSize chunk_shape(1, chunksize); + + qDebug() << "preparations done, starting loop!"; while ((!stop_request || buffer->bufferLoad() > 0) && !stopNow) { if (buffer->bufferLoad() > 0 ) { size_t framecount = 0;