cleanup
This commit is contained in:
parent
5263d04cac
commit
ec203ba1ad
@ -42,10 +42,11 @@ find_package (NIX REQUIRED)
|
|||||||
include_directories (AFTER ${NIX_INCLUDE_DIR})
|
include_directories (AFTER ${NIX_INCLUDE_DIR})
|
||||||
|
|
||||||
# #######################################
|
# #######################################
|
||||||
# # OPENCV
|
# OPENCV
|
||||||
# find_package(OpenCV REQUIRED opencv_highgui opencv_core)
|
message ("=> finding opencv ...")
|
||||||
# include_directories(AFTER ${OpenCV_INCLUDE_DIRS} )
|
find_package(OpenCV REQUIRED opencv_highgui opencv_core)
|
||||||
# set(LINK_LIBS ${LINK_LIBS} ${OpenCV_LIBRARIES})
|
include_directories(AFTER ${OpenCV_INCLUDE_DIRS} )
|
||||||
|
set(LINK_LIBS ${LINK_LIBS} ${OpenCV_LIBRARIES})
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Pylon
|
# Pylon
|
||||||
@ -57,5 +58,5 @@ file (GLOB RECORDER_SOURCES *.cpp)
|
|||||||
file (GLOB RECORDER_INCLUDES *.hpp)
|
file (GLOB RECORDER_INCLUDES *.hpp)
|
||||||
add_executable ( recorder ${RECORDER_SOURCES} ${RECORDER_INCLUDES} ${RECORDER_RES_SOURCES} )
|
add_executable ( recorder ${RECORDER_SOURCES} ${RECORDER_INCLUDES} ${RECORDER_RES_SOURCES} )
|
||||||
target_include_directories ( recorder PUBLIC "${PROJECT_BINARY_DIR}" )
|
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})
|
# ${PYLON_LIBRARIES} ${OpenCV_LIBRARIES})
|
@ -159,7 +159,6 @@ ImageSettings DualcamWrapper::getImageSettings(int camindex) {
|
|||||||
Pylon::CIntegerParameter width( nodemap, "Width" );
|
Pylon::CIntegerParameter width( nodemap, "Width" );
|
||||||
Pylon::CIntegerParameter height( nodemap, "Height" );
|
Pylon::CIntegerParameter height( nodemap, "Height" );
|
||||||
settings.pixelType = pixelType;
|
settings.pixelType = pixelType;
|
||||||
std::cerr << "GetImageSettings pixelType: " << pixelType << std::endl;
|
|
||||||
settings.width = (uint32_t)width.GetValue();
|
settings.width = (uint32_t)width.GetValue();
|
||||||
settings.height = (uint32_t)height.GetValue();
|
settings.height = (uint32_t)height.GetValue();
|
||||||
settings.orientation = Pylon::EImageOrientation::ImageOrientation_TopDown;
|
settings.orientation = Pylon::EImageOrientation::ImageOrientation_TopDown;
|
||||||
@ -214,7 +213,6 @@ void DualcamWrapper::resetCamera(int camindex) {
|
|||||||
|
|
||||||
bool DualcamWrapper::openCameras(std::string &message) {
|
bool DualcamWrapper::openCameras(std::string &message) {
|
||||||
qDebug() << "opening cameras";
|
qDebug() << "opening cameras";
|
||||||
bool valid = true;
|
|
||||||
Pylon::CTlFactory& tlFactory = Pylon::CTlFactory::GetInstance();
|
Pylon::CTlFactory& tlFactory = Pylon::CTlFactory::GetInstance();
|
||||||
cameras.Initialize(2);
|
cameras.Initialize(2);
|
||||||
try {
|
try {
|
||||||
|
@ -72,7 +72,6 @@ void ImageBuffer::push(MyImage *img) {
|
|||||||
buffer[head_idx] = img;
|
buffer[head_idx] = img;
|
||||||
framecounts[head_idx] = framecount;
|
framecounts[head_idx] = framecount;
|
||||||
load = load < buffer_size ? load +=1 : buffer_size;
|
load = load < buffer_size ? load +=1 : buffer_size;
|
||||||
|
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,6 +110,6 @@ MyImage* ImageBuffer::readLast(size_t &framecount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImageBuffer::~ImageBuffer(){
|
ImageBuffer::~ImageBuffer(){
|
||||||
std::cerr << "Image buffer destructor" << std::endl;
|
qDebug() << "Image buffer destructor";
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
@ -606,7 +606,6 @@ void PylonRecorder::cameraConfigurationAborted() {
|
|||||||
|
|
||||||
void PylonRecorder::connectCamera() {
|
void PylonRecorder::connectCamera() {
|
||||||
this->layout = CameraLayout();
|
this->layout = CameraLayout();
|
||||||
std::cerr << this->layout.rois.size() << " " << this->layout.devices.size() << std::endl;
|
|
||||||
qDebug() << "connecting camera(s)";
|
qDebug() << "connecting camera(s)";
|
||||||
if (deviceList.size() == 0) {
|
if (deviceList.size() == 0) {
|
||||||
detectCameras();
|
detectCameras();
|
||||||
@ -644,10 +643,8 @@ void PylonRecorder::connectCamera() {
|
|||||||
updateActions();
|
updateActions();
|
||||||
}
|
}
|
||||||
if (layout.mode == CameraMode::dual && layout.devices.size() == 2) {
|
if (layout.mode == CameraMode::dual && layout.devices.size() == 2) {
|
||||||
std::cerr << "Dual MODE" << std::endl;
|
|
||||||
qDebug() << "dual camera mode";
|
qDebug() << "dual camera mode";
|
||||||
std::string message;
|
std::string message;
|
||||||
qDebug() << "creating dual cam wrapper";
|
|
||||||
dualcam = new DualcamWrapper(layout);
|
dualcam = new DualcamWrapper(layout);
|
||||||
bool success = dualcam->openCameras(message);
|
bool success = dualcam->openCameras(message);
|
||||||
if (success) {
|
if (success) {
|
||||||
@ -754,7 +751,7 @@ void PylonRecorder::startSinglecamRecording() {
|
|||||||
writer = nullptr;
|
writer = nullptr;
|
||||||
}
|
}
|
||||||
writer = new Writer(buffer, 0);
|
writer = new Writer(buffer, 0);
|
||||||
connect(writer, SLOT(writingDone( int)), this, SLOT(writerDone( int )));
|
connect(writer, SLOT(writingDone()), this, SLOT(writerDone()));
|
||||||
writer->setVideoSpecs(specs);
|
writer->setVideoSpecs(specs);
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
@ -777,16 +774,14 @@ void PylonRecorder::startDualcamRecording() {
|
|||||||
qDebug() << "start dual-camera recording!";
|
qDebug() << "start dual-camera recording!";
|
||||||
std::string filename = createFilename("", ".mp4");
|
std::string filename = createFilename("", ".mp4");
|
||||||
fileLabel->setText(QString::fromStdString(filename));
|
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!
|
ImageSettings settings = dualcam->getImageSettings(0); //FIXME!
|
||||||
qDebug() << "got image settings";
|
qDebug() << "got image settings";
|
||||||
|
|
||||||
VideoSpecs specs = getVideoSpecs(settings);
|
VideoSpecs specs = getVideoSpecs(settings);
|
||||||
specs.filename = filename;
|
specs.filename = filename;
|
||||||
specs.format = VideoFormat::mp4;
|
specs.format = VideoFormat::mp4;
|
||||||
qDebug() << "got video specifications";
|
qDebug() << "got video specifications";
|
||||||
|
|
||||||
if (buffer != nullptr) {
|
if (buffer != nullptr) {
|
||||||
buffer->clear();
|
buffer->clear();
|
||||||
delete buffer;
|
delete buffer;
|
||||||
@ -819,7 +814,7 @@ void PylonRecorder::startDualcamRecording() {
|
|||||||
writer = nullptr;
|
writer = nullptr;
|
||||||
}
|
}
|
||||||
writer = new Writer(buffer, 0);
|
writer = new Writer(buffer, 0);
|
||||||
connect(writer, SIGNAL(writingDone(int)), this, SLOT(writerDone( int )));
|
connect(writer, SIGNAL(writingDone()), this, SLOT(writerDone()));
|
||||||
writer->setVideoSpecs(specs);
|
writer->setVideoSpecs(specs);
|
||||||
|
|
||||||
qDebug() << "push metadata to writer";
|
qDebug() << "push metadata to writer";
|
||||||
@ -876,14 +871,15 @@ void PylonRecorder::stopRecording() {
|
|||||||
qDebug() << "StopRecording: clear buffer!";
|
qDebug() << "StopRecording: clear buffer!";
|
||||||
if(buffer != nullptr) {
|
if(buffer != nullptr) {
|
||||||
buffer->clear();
|
buffer->clear();
|
||||||
// writerDone( 0 ); // Needed? or even dangerous?
|
if (dryRun)
|
||||||
|
writerDone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug() << "StopRecording done!";
|
qDebug() << "StopRecording done!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PylonRecorder::writerDone(int cam) {
|
void PylonRecorder::writerDone() {
|
||||||
pressureTimer->stop();
|
pressureTimer->stop();
|
||||||
pressureBar->reset();
|
pressureBar->reset();
|
||||||
loadBar->reset();
|
loadBar->reset();
|
||||||
|
@ -67,7 +67,7 @@ private slots:
|
|||||||
void displaySingleFrame();
|
void displaySingleFrame();
|
||||||
void displayBufferPressure();
|
void displayBufferPressure();
|
||||||
void displayActivity();
|
void displayActivity();
|
||||||
void writerDone(int cam);
|
void writerDone();
|
||||||
void selectStorageLocation();
|
void selectStorageLocation();
|
||||||
void cameraConfigurationAccepted();
|
void cameraConfigurationAccepted();
|
||||||
void cameraConfigurationAborted();
|
void cameraConfigurationAborted();
|
||||||
|
@ -27,6 +27,7 @@ void Writer::writeMetadata(nix::Section &s){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Writer::run() {
|
void Writer::run() {
|
||||||
|
qDebug() << "writer running!";
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
size_t chunksize = 256;
|
size_t chunksize = 256;
|
||||||
// size_t framecount = 0;
|
// size_t framecount = 0;
|
||||||
@ -39,6 +40,8 @@ void Writer::run() {
|
|||||||
emit writingDone(this->cam_number);
|
emit writingDone(this->cam_number);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
qDebug() << "checks done!";
|
||||||
|
|
||||||
Pylon::CVideoWriter videoWriter;
|
Pylon::CVideoWriter videoWriter;
|
||||||
if (specs_valid) {
|
if (specs_valid) {
|
||||||
stop_request = false;
|
stop_request = false;
|
||||||
@ -48,7 +51,8 @@ void Writer::run() {
|
|||||||
myFile.write((char*)&videoSpecs.width, 4);
|
myFile.write((char*)&videoSpecs.width, 4);
|
||||||
myFile.write((char*)&videoSpecs.height, 4);
|
myFile.write((char*)&videoSpecs.height, 4);
|
||||||
} else {
|
} 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());
|
videoWriter.Open(videoSpecs.filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +95,8 @@ void Writer::run() {
|
|||||||
nix::NDSize offset(1, 0);
|
nix::NDSize offset(1, 0);
|
||||||
nix::NDSize current_shape(initial_shape);
|
nix::NDSize current_shape(initial_shape);
|
||||||
nix::NDSize chunk_shape(1, chunksize);
|
nix::NDSize chunk_shape(1, chunksize);
|
||||||
|
|
||||||
|
qDebug() << "preparations done, starting loop!";
|
||||||
while ((!stop_request || buffer->bufferLoad() > 0) && !stopNow) {
|
while ((!stop_request || buffer->bufferLoad() > 0) && !stopNow) {
|
||||||
if (buffer->bufferLoad() > 0 ) {
|
if (buffer->bufferLoad() > 0 ) {
|
||||||
size_t framecount = 0;
|
size_t framecount = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user