Skip to content
Snippets Groups Projects
Commit 1f3301d4 authored by l.dressen's avatar l.dressen
Browse files

removed recording button

parent 7ac5ecbb
No related branches found
No related tags found
1 merge request!399removed recording button
Subproject commit 606aa9e3200e39da5f0e7aa7a51d70d863dd5453
Subproject commit 77c27929d429ee7216760456cee8de96e4aa36e4
......@@ -11,9 +11,6 @@
# -DBUILD_BUNDLE=ON (default OFF) builds a MacOS Bundle for deployment
# -DFAIL_ON_WARNINGS=ON (default OFF) use Werror when building (for CI builds!)
#
# currently not supported:
# -DAVI=ON (default OFF)
#
################################################################################
# Project setup
################################################################################
......@@ -58,9 +55,6 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
option(STEREO "Use Point Grey's Triclops SDK and enable stereo support" OFF)
print_var(STEREO)
option(AVI "Use Avi File from Point Grey (only interal due to license)" OFF)
print_var(AVI)
option(BUILD_UNIT_TESTS "Build catch2 unit tests" OFF)
print_var(BUILD_UNIT_TESTS)
......@@ -106,11 +100,6 @@ if (USE_3RD_PARTY AND NOT (WIN32 AND MINGW))
yourself." )
endif()
# Check for currently unavailable options
#if (AVI)
# message(FATAL_ERROR "Currently the avi File from Point Grey needs to be disabled.")
#endif()
## Stero currently only allowed on windows
if (STEREO AND NOT WIN32)
message(FATAL_ERROR "Currently the stereo feature is only supported on windows.")
......@@ -277,16 +266,6 @@ target_link_libraries(petrack_core PUBLIC ezc3d)
# Handling of Options *
#*************************************************************
if(AVI)
target_compile_definitions(petrack_core PRIVATE AVI)
target_sources(petrack_core PUBLIC
"${CMAKE_SOURCE_DIR}/3rdparty/avifile/aviFile.h"
"${CMAKE_SOURCE_DIR}/3rdparty/avifile/aviFile.cpp"
)
target_include_directories(petrack_core PRIVATE 3rdparty/avifile)
target_link_libraries(petrack_core PUBLIC avifil32 msvfw32)
endif(AVI)
# WIN32 steht für Windows allgemein, nicht nur 32Bit
if(WIN32)
target_link_libraries(petrack_core PUBLIC psapi)
......
docs/source/user_interface/images/PlayerControl.png

26.2 KiB | W: | H:

docs/source/user_interface/images/PlayerControl.png

9.08 KiB | W: | H:

docs/source/user_interface/images/PlayerControl.png
docs/source/user_interface/images/PlayerControl.png
docs/source/user_interface/images/PlayerControl.png
docs/source/user_interface/images/PlayerControl.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -46,12 +46,6 @@ single frame forward
play
: Plays the video (forward direction)
record
: This button starts a recording.
:::{note}
We recommend using the `Export Video` or `Export Video View` options from the `File` menu in the menu bar instead of the recording button.
:::
Next to these buttons are the boxes labeled `In` and `Out`. If the video is longer than the experiment, one can use these to specify a different starting frame (`In`) or ending frame (`Out`) for PeTrack. PeTrack then treats the video as if all frames before `In` and after `Out` do not exist. The default values are 0 for `In` and the last frame of the video file for `Out`.
......
......@@ -21,8 +21,6 @@
<file alias="calibCam2New">calib/new/cam2_7280791.cal</file>
<file alias="arrowLeft">arrow_left.png</file>
<file alias="arrowRight">arrow_right.png</file>
<file>record.png</file>
<file>stop-record.png</file>
<file>petrack.icns</file>
</qresource>
</RCC>
icons/record.png

1.51 KiB

icons/stop-record.png

846 B

......@@ -15,13 +15,6 @@ target_sources(petrack_core PRIVATE
skeletonTreeFactory.h
)
if(NOT AVI)
target_sources(petrack_core PRIVATE
aviFileWriter.cpp
aviFileWriter.h
)
endif()
if(NOT STEREO)
target_sources(petrack_core PRIVATE
stereoAviFile.cpp
......
/*
* PeTrack - Software for tracking pedestrians movement in videos
* Copyright (C) 2024 Forschungszentrum Jülich GmbH, IAS-7
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "aviFileWriter.h"
#include "logger.h"
#include <cassert>
#include <cstdio>
#include <iostream>
#include <opencv2/videoio/videoio_c.h>
//
// Extra temp data bytes.
//
#define EXTRA_TEMP_SPACE 10000
AviFileWriter::AviFileWriter()
{
m_pTempBMPBuffer = nullptr;
m_pTempBuffer = nullptr;
m_iTimeIndex = 0;
m_iCols = 0;
m_iRows = 0;
m_iBPP = 0;
m_iSize = 0;
m_iRowInc = 0;
m_frameRate = 0.0;
m_bSizeLimited = false;
m_iSplitFile = 0;
m_isColor = true;
m_liBytesWritten = 0;
}
AviFileWriter::~AviFileWriter()
{
close();
if(m_pTempBuffer != nullptr)
{
delete[] m_pTempBuffer;
m_pTempBuffer = nullptr;
}
if(m_pTempBMPBuffer != nullptr)
{
delete[] m_pTempBMPBuffer;
m_pTempBMPBuffer = nullptr;
}
}
bool AviFileWriter::openSizeLimitedAVI(const char *pszFilename, int iCols, int iRows, int ibpp, double dFramerate)
{
std::string szAVIFile;
m_bSizeLimited = true;
m_iSplitFile = 0;
std::stringstream stringStream;
stringStream << pszFilename;
szAVIFile = stringStream.str();
// Remove any extensions.
size_t lastindex = szAVIFile.find_first_of('.');
szAVIFile = szAVIFile.substr(0, lastindex);
//
// Keep the basic avi file name in m_szAVIDestFile.
//
stringStream.str("");
stringStream << szAVIFile;
m_szAVIDestFile = stringStream.str();
//
// The avi file names will be in the form of ***_0000.avi, ***_0001.avi,
// ***_0002.avi...
// The size of each avi file is limited by AVI_FILE_SPLIT_SIZE bytes
//
stringStream.str("");
stringStream << m_szAVIDestFile << "_" << std::setfill('0') << std::setw(4) << m_iSplitFile << ".avi";
szAVIFile = stringStream.str();
return open(szAVIFile.c_str(), iCols, iRows, ibpp, dFramerate);
}
bool AviFileWriter::open(const char *pszFilename, int iCols, int iRows, int ibpp, double dFramerate)
{
//
// Initialize the library.
//
//::AVIFileInit();
if(!checkOpenCVVersion())
{
return false;
}
if(pszFilename == nullptr || iRows <= 0 || iCols <= 0 || dFramerate <= 0.0)
{
assert(false);
return false;
}
m_frameRate = dFramerate;
m_iTimeIndex = 0;
m_liBytesWritten = 0;
//
// If these parameters change, set them and allocate the buffers
//
if(m_iCols != iCols || m_iRows != iRows || m_iBPP != ibpp)
{
//
// Initialize members.
//
m_iCols = iCols;
m_iRows = iRows;
m_iBPP = ibpp;
m_iRowInc = m_iCols * (m_iBPP / 8);
m_iSize = m_iRows * m_iRowInc;
//
// Allocate temp image buffers.
//
if(m_pTempBMPBuffer != nullptr)
{
delete[] m_pTempBMPBuffer;
m_pTempBMPBuffer = nullptr;
}
m_pTempBMPBuffer = new unsigned char[m_iSize + EXTRA_TEMP_SPACE];
if(m_pTempBuffer != nullptr)
{
delete[] m_pTempBuffer;
m_pTempBuffer = nullptr;
}
m_pTempBuffer = new unsigned char[m_iSize];
}
if(m_pTempBMPBuffer == nullptr || m_pTempBuffer == nullptr)
{
return false;
}
//
// If this function is called from openSizeLimitedAVI(), pszFilename
// is the file to open. m_szAVIDestFile should not be changed because
// it is the base file name used in appendFrame() to generate the next
// split file name.
//
// If this function is called directly (not by openSizeLimitedAVI()),
// the AVI file can not be splited and m_szAVIDestFile is not used.
// So we do not need to save the file name to m_szAVIDestFile.
//
#if 0
sprintf(m_szAVIDestFile, "%s", pszFilename );
// Remove any extensions.
char* pcExt = strstr( m_szAVIDestFile, "." );
if( pcExt != NULL )
{
*( pcExt ) = 0x0;
}
// add an avi extension so that the file can be opened
char szAVIFile[ _MAX_PATH ];
sprintf(szAVIFile, "%s.avi", m_szAVIDestFile);
#endif
return m_vWriter.open(pszFilename, CV_FOURCC_DEFAULT /*PROMPT*/, dFramerate, cv::Size(iCols, iRows), m_isColor);
}
bool AviFileWriter::open(const char *pszFilename, int iCols, int iRows, int /*ibpp*/, int iFramerate)
{
return m_vWriter.open(pszFilename, CV_FOURCC_PROMPT, (double) iFramerate, cv::Size(iCols, iRows), m_isColor);
}
long int AviFileWriter::bytesWritten() const
{
return m_liBytesWritten;
}
bool AviFileWriter::appendFrame(const unsigned char *pBuffer, bool /*bInvert*/)
{
if(!m_vWriter.isOpened())
{
assert(false);
return false;
}
unsigned char *pWriteBuffer = (unsigned char *) pBuffer;
cv::Mat frame;
if((m_iRowInc / m_iCols) == 1)
{
frame = cv::Mat(m_iRows, m_iCols, CV_8UC1, pWriteBuffer, m_iRowInc); // = imread(pszFilename);
}
else if((m_iRowInc / m_iCols) == 3)
{
frame = cv::Mat(m_iRows, m_iCols, CV_8UC3, pWriteBuffer, m_iRowInc); // = imread(pszFilename);
}
else if((m_iRowInc / m_iCols) == 4)
{
frame = cv::Mat(m_iRows, m_iCols, CV_8UC4, pWriteBuffer, m_iRowInc); // = imread(pszFilename);
cv::cvtColor(frame, frame, cv::COLOR_RGBA2RGB); // need for right image interpretation
}
else
{
SPDLOG_ERROR("unknown video format.");
return false;
}
if(!frame.data)
{
SPDLOG_ERROR("saving video data failed.");
return false;
}
m_vWriter.write(frame);
/**
* ToDo: invertieren
*
*/
long lBytesWritten = 0;
//
// If the AVI file is opened with openSizeLimitedAVI(), split it if necessory.
//
if(m_bSizeLimited)
{
//
// Split the file if it is more than 'AVI_FILE_SPLIT_SIZE' bytes
//
// if(bytesWritten() >= (__int64)(AVI_FILE_SPLIT_SIZE))
if(bytesWritten() >= (long int) (AVI_FILE_SPLIT_SIZE))
{
std::string szAVIFile;
std::stringstream stringStream;
close();
m_iSplitFile++;
stringStream << m_szAVIDestFile << "_" << std::setfill('0') << std::setw(4) << m_iSplitFile << ".avi";
szAVIFile = stringStream.str();
if(!open(szAVIFile.c_str(), m_iCols, m_iRows, m_iBPP, m_frameRate))
{
return false;
}
}
}
m_liBytesWritten += lBytesWritten;
m_iTimeIndex++;
return true;
}
bool AviFileWriter::close()
{
m_vWriter.release();
return true;
}
bool AviFileWriter::appendBMP(const char *pszFilename)
{
cv::Mat bmpFrame = cv::imread(pszFilename);
m_vWriter.write(bmpFrame);
m_iTimeIndex++;
return true;
}
bool AviFileWriter::checkOpenCVVersion()
{
if constexpr(CV_MAJOR_VERSION < 3)
{
assert(false); // opencv version too old.
return false;
}
return true;
}
/*
* PeTrack - Software for tracking pedestrians movement in videos
* Copyright (C) 2024 Forschungszentrum Jülich GmbH, IAS-7
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#undef UNICODE
#ifndef AVIFILEWRITER_H
#define AVIFILEWRITER_H
#include <opencv2/opencv.hpp>
// Byte Number (nicht alle Zahlen gehen?: 2*1280*960*32*20) enstehen avi mit einem bild
// unter 2GB fuer reader und unter 4 GB fuer writer bleiben!!!
// 2*1280*960*32*20 = 1,5 GB = 40 Sekunden = 640 Bilder
inline constexpr int AVI_FILE_SPLIT_SIZE = ((2 * 1280 * 960 * 32 * 20));
/**
* A simple wrapper for an .AVI file .
*/
class AviFileWriter
{
public:
/** Default constructor. */
AviFileWriter();
/** Default destructor. */
virtual ~AviFileWriter();
/**
* Open an AVI for writing.
*
* @param iCols Width, in pixels, of each frame.
* @param iRows Hight, in pixels, of each frame.
* @param ibpp Bits per pixel -- 24 (BGR), 32 (BGRU). or 8 bit greyscale.
* @param dFramerate Framerate that the .avi will play back in.
*/
bool open(const char *pszFilename, int iCols, int iRows, int ibpp, double dFramerate);
/**
* Open an AVI for writing. Deprecated.
*
* @param iCols Width, in pixels, of each frame.
* @param iRows Hight, in pixels, of each frame.
* @param ibpp Bits per pixel -- 24 (BGR), 32 (BGRU). or 8 bit greyscale.
* @param iFramerate Framerate that the .avi will play back in.
*/
bool open(const char *pszFilename, int iCols, int iRows, int ibpp, int iFramerate);
/**
* Open an .avi for writing. The size of the avi file will be limited to SPLIT_SIZE bytes.
* The file is splited automatically.
*
* @param iCols Width, in pixels, of each frame.
* @param iRows Hight, in pixels, of each frame.
* @param ibpp Bits per pixel -- 24 (BGR), 32 (BGRU). or 8 bit greyscale.
* @param iFramerate Framerate that the .avi will play back in.
*/
bool openSizeLimitedAVI(const char *pszFilename, int iCols, int iRows, int ibpp, double iFramerate);
/** Get the the bytes written */
long int bytesWritten() const;
/**
* Load a bitmap from a file and append it to the current open .avi.
* Must be in the correct format.
*/
bool appendBMP(const char *pszFilename);
/**
* Add a frame (in the specified format) to the open .avi
*/
bool appendFrame(const unsigned char *pBuffer, bool bInvert = true);
/** Close the .avi file. This is also done by the destructor. */
bool close();
protected:
/** Height, in pixels, of each frame in the .avi. */
int m_iRows;
/** Width, in pixels, of each frame in the .avi. */
int m_iCols;
/** Bits per pixel of the .avi. */
int m_iBPP;
/** Row increment, in bytes. */
int m_iRowInc;
/** Image size in bytes. */
int m_iSize;
/** Frame rate */
double m_frameRate;
/** Time index for current frame. */
int m_iTimeIndex;
/** Temporary image buffer. */
unsigned char *m_pTempBuffer;
/** Temporary image buffer */
cv::Mat m_frame;
/** Temporary buffer for saving .bmps. */
unsigned char *m_pTempBMPBuffer;
/** Avi file counter. */
int m_iSplitFile;
/** Flag indicating if the size of the avi file is limited to AVI_FILE_SPLIT_SIZE bytes */
bool m_bSizeLimited;
/** Total bytes written. */
long int m_liBytesWritten;
/** avi file name */
std::string m_szAVIDestFile;
char *m_fourCC;
/** Defines is color avi */
bool m_isColor;
private:
/** Read and verify the OpenCV version. */
bool checkOpenCVVersion();
/** Read the opened AVI-File */
cv::VideoCapture m_vReader;
/** Writes to the opened AVI-File */
cv::VideoWriter m_vWriter;
};
#endif // #ifndef AVIFILEWRITER_H
......@@ -75,13 +75,6 @@ Player::Player(Animation *anim, QWidget *parent) : QWidget(parent)
mPauseButton->setIconSize(iconSize);
connect(mPauseButton, SIGNAL(clicked()), this, SLOT(pause()));
// rec button;
mRecButton = new QToolButton;
mRecButton->setIcon(QPixmap(":/record"));
mRecButton->setIconSize(iconSize);
connect(mRecButton, SIGNAL(clicked()), this, SLOT(recStream()));
mRec = false;
// slider
mSlider = new QSlider(Qt::Horizontal);
mSlider->setTickPosition(QSlider::TicksAbove);
......@@ -152,7 +145,6 @@ Player::Player(Animation *anim, QWidget *parent) : QWidget(parent)
mPlayerLayout->addWidget(mPauseButton);
mPlayerLayout->addWidget(mFrameForwardButton);
mPlayerLayout->addWidget(mPlayForwardButton);
mPlayerLayout->addWidget(mRecButton);
mPlayerLayout->addWidget(mSourceInLabel);
mPlayerLayout->addWidget(mFrameInNum);
mPlayerLayout->addWidget(mSourceOutLabel);
......@@ -258,10 +250,6 @@ bool Player::updateImage()
mMainWindow->updateImage(mImg);
if(mRec)
{
mAviFile.appendFrame((const unsigned char *) mImg.data, true);
}
mSlider->setValue(
mAnimation->getCurrentFrameNum()); //(1000*mAnimation->getCurrentFrameNum())/mAnimation->getNumFrames());
mFrameNum->setText(QString().number(mAnimation->getCurrentFrameNum()));
......@@ -454,101 +442,6 @@ void Player::togglePlayPause()
}
}
/**
* @brief Toggles recording and saving of recording
*
* If already recording, the method stops the recording and saves it to
* a user-given file. If recording hasn't started, this method starts it.
*
* Actual recording happens in Player::updateImage()
*/
void Player::recStream()
{
if(mAnimation->isCameraLiveStream() || mAnimation->isVideo() || mAnimation->isImageSequence() ||
mAnimation->isStereoVideo())
{
// video temp path/file name
QString videoTmp = QDir::tempPath() + "/petrack-video-record.avi";
if(mRec) // stop recording and save recorded stream to disk
{
mRec = false;
mRecButton->setIcon(QPixmap(":/record"));
mAviFile.close();
QString dest;
QFileDialog fileDialog(
this,
tr("Select file for saving video output"),
nullptr,
tr("Video (*.*);;AVI-File (*.avi);;All supported types (*.avi *.mp4);;All files (*.*)"));
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setDefaultSuffix("");
if(fileDialog.exec())
{
dest = fileDialog.selectedFiles().at(0);
}
if(dest == nullptr)
{
return;
}
if(QFile::exists(dest))
{
QFile::remove(dest);
}
QProgressDialog progress("Save Video File", nullptr, 0, 2, mMainWindow);
progress.setWindowTitle("Save Video File");
progress.setWindowModality(Qt::WindowModal);
progress.setVisible(true);
progress.setValue(0);
progress.setLabelText(QString("save video ..."));
qApp->processEvents();
progress.setValue(1);
if(!QFile(videoTmp).copy(dest))
{
PCritical(this, tr("PeTrack"), tr("Error: Could not save video file!"));
}
else
{
mMainWindow->statusBar()->showMessage(tr("Saved video file to %1.").arg(dest), 5000);
if(!QFile(videoTmp).remove())
{
SPDLOG_WARN("Could not remove tmp-file: {}", videoTmp);
}
progress.setValue(2);
}
}
else // open video writer
{
if(mAviFile.open(
videoTmp.toStdString().c_str(),
mImg.cols,
mImg.rows,
8 * mImg.channels(),
mAnimation->getPlaybackFPS()))
{
mRec = true;
mRecButton->setIcon(QPixmap(":/stop-record"));
}
else
{
SPDLOG_ERROR("could not open video output file!");
}
}
}
}
bool Player::skipToFrame(int f) // [0..mAnimation->getNumFrames()-1]
{
if(f == mAnimation->getCurrentFrameNum())
......
......@@ -21,13 +21,6 @@
#include <QTemporaryFile>
#include <QWidget>
#ifdef AVI
#include "aviFile.h"
#else
#include "aviFileWriter.h"
#endif
#include <opencv2/opencv.hpp>
class QLabel;
......@@ -70,7 +63,6 @@ public:
public slots:
bool frameForward();
bool frameBackward();
void recStream();
void pause();
void togglePlayPause();
bool skipToFrame(int f);
......@@ -104,18 +96,9 @@ private:
bool mPlayerSpeedLimited;
bool mPlayerSpeedFixed = false;
bool mLooping = false;
bool mRec;
#ifdef AVI
AviFile mAviFile;
#else
AviFileWriter mAviFile;
#endif
// GUI
QToolButton *mFrameForwardButton, *mFrameBackwardButton, *mPlayForwardButton, *mPlayBackwardButton, *mPauseButton;
QToolButton *mRecButton;
cv::Mat mImg;
QHBoxLayout *mPlayerLayout;
Petrack *mMainWindow;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment