#include "writer.h" void Writer::setVideoSpecs(VideoSpecs specs) { videoSpecs = specs; valid = true; } void Writer::run() { if (valid) { stop_request = false; Pylon::CVideoWriter videoWriter; videoWriter.SetParameter(videoSpecs.width, videoSpecs.height, videoSpecs.pixelType, videoSpecs.fps, videoSpecs.quality); videoWriter.Open(videoSpecs.filename.c_str()); MyImage img; int64_t count = 0; while (!stop_request || buffer->bufferLoad() > 0) { std::cerr << "running!\n"; if (buffer->bufferLoad() > 0 ) { bool valid = buffer->pop(img); if (valid) { count ++; Pylon::CPylonImage pyImage; try { pyImage.AttachUserBuffer(img.data(), videoSpecs.width * videoSpecs.height, videoSpecs.pixelType, videoSpecs.width, videoSpecs.height, 0, videoSpecs.orientation); videoWriter.Add( pyImage ); } catch (const Pylon::GenericException &e) { std::cerr << "An exception occurred." << std::endl << e.GetDescription() << std::endl; } } } else { while (buffer->bufferLoad() < 5 && !stop_request) { msleep(10); std::cerr << "waiting.." << buffer->bufferLoad() << std::endl; } } } videoWriter.Close(); std::cerr << "writer terminated: " << count << std::endl; } else { std::cerr << "Got no video specifications, not writing!" << std::endl; } }