This commit is contained in:
Jan Grewe 2024-03-12 16:40:24 +01:00
parent 5263d04cac
commit ec203ba1ad
6 changed files with 21 additions and 21 deletions

View File

@ -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})

View File

@ -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 {

View File

@ -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();
}

View File

@ -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();

View File

@ -67,7 +67,7 @@ private slots:
void displaySingleFrame();
void displayBufferPressure();
void displayActivity();
void writerDone(int cam);
void writerDone();
void selectStorageLocation();
void cameraConfigurationAccepted();
void cameraConfigurationAborted();

View File

@ -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;