This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef FRAMESEXTRACTOR_H
#define FRAMESEXTRACTOR_H
#include "opencv2/video.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"
class FramesExtractor : public QThread
void set(QString video_path,
unsigned int frames_wanted,
this->video_path = video_path;
this->out_dir_path = out_dir_path;
this->frames_wanted = frames_wanted;
this->start_frame = start_frame;
this->end_frame = end_frame;
this->video_fps = video_fps;
bool set_video(QString file_path);
int get_video_frame_count();
void save_one_frame(double current_frame,
cv::VideoCapture *cap = nullptr;
unsigned int video_frame_count;
unsigned int frames_wanted;
const int max_frames_to_backtrack = 100;
void set_max(unsigned int max);
void set_value(unsigned int new_value,
#endif // FRAMESEXTRACTOR_H
/*
Copyright (C) 2022 Lari Varjonen <
[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef FRAMESEXTRACTOR_H
#define FRAMESEXTRACTOR_H
#include <QThread>
#include <QDialog>
#include <QString>
#include <QDebug>
#include <QTime>
#include "opencv2/video.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"
class FramesExtractor : public QThread
{
Q_OBJECT
public:
~FramesExtractor()
{
delete cap;
}
void set(QString video_path,
QString out_dir_path,
unsigned int frames_wanted,
double start_frame,
double end_frame,
double video_fps)
{
this->video_path = video_path;
this->out_dir_path = out_dir_path;
this->frames_wanted = frames_wanted;
this->start_frame = start_frame;
this->end_frame = end_frame;
this->video_fps = video_fps;
running = true;
};
void stop_work()
{
running = false;
};
void run() override;
bool set_video(QString file_path);
int get_video_frame_count();
double get_video_fps();
private:
void save_one_frame(double current_frame,
int frame_number);
cv::VideoCapture *cap = nullptr;
QString video_path;
QString out_dir_path;
unsigned int video_frame_count;
unsigned int frames_wanted;
double start_frame;
double end_frame;
double video_fps;
bool running;
const int max_frames_to_backtrack = 100;
signals:
void set_max(unsigned int max);
void set_value(unsigned int new_value,
double current_frame,
double end_frame);
void process_done();
};
#endif // FRAMESEXTRACTOR_H