35 #include "opencvcapture.h"
68 bool canRecord() const override final {
return false; }
78 {
return source ? source->getBarrelCorrection() : 0.0; }
93 {
return {source->getPath()}; }
96 {
return source ? source->getFramerate() : 0.0; }
109 {
return source ? source->getResolution() : cv::Size(0, 0); }
112 {
return SourceType::VIDEO; }
123 {
return source ? source->hasNew() :
false; }
143 virtual bool open(
const std::string& filename,
bool get_first,
161 const std::string& codec =
"") override final
162 { Q_UNUSED(filename); Q_UNUSED(codec);
return false; }
178 virtual void release() {
if (source) source->release(); }
204 { source->setBarrelCorrection(amount); }
222 { Q_UNUSED(new_size);
return false; }
271 {
return std::floor(static_cast<double>(time) / getFrameDifference()); }
279 {
return static_cast<FrameTime>(getFrameDifference() * frame); }
321 double getFrameDifference()
const
331 std::unique_ptr<OpenCVCapture> source =
nullptr;
335 #endif // VIDEOFILE_H
int getCurrentFrame() const
Returns the current frame of the video shown.
Definition: videofile.h:84
virtual void play() override
Starts frame updates on the file.
Definition: videofile.h:151
virtual bool isPlaying() const override
Checks whether the source is playing or not.
Definition: videofile.h:127
virtual FrameTime getPosition() const overridefinal
Retrieves the current time position of the source.
Definition: videofile.h:105
virtual SourceType getSourceType() const override
Returns the type of the source.
Definition: videofile.h:111
FrameTime video_time
The current time of the video file.
Definition: videofile.h:314
virtual double getBarrelCorrection() override
Returns the barrel correction applied to the source frames.
Definition: videofile.h:77
virtual std::vector< std::string > getFilenames() const
Returns the filenames of the source.
Definition: videofile.h:92
FrameTime frameTimeFromFrame(int frame) const
Returns the expected frame time of the given frame.
Definition: videofile.h:278
unsigned int SourceID
Used to indicate unique source ID-numbers.
Definition: common.h:229
static void setSpeed(double multiplier)
Sets playing speed of the video file.
Definition: videofile.h:229
bool record(const std::string &filename, const std::string &codec="") overridefinal
Starts the recording of the source to the file.
Definition: videofile.h:160
The class for the video file source.
Definition: videofile.h:51
virtual void stop() override
Will stop the file from playing.
Definition: videofile.h:244
const SourceID UNDEFINED_SOURCE
Used to indicate unknown sources.
Definition: common.h:234
virtual void fetchFirstFrame()
Seeks the startup point of the video and the first frame.
Definition: videofile.cpp:38
int total_frames
The total frames in the video file.
Definition: videofile.h:309
void setCurrentAsStartPoint()
Sets the current video time as the seeking start point.
Definition: videofile.h:211
virtual bool open(const std::string &filename, bool get_first, FrameTime start_point)
Opens a video file.
Definition: videofile.cpp:122
bool setResolution(const cv::Size &new_size) overridefinal
Should change resolution, but does not have an effect on video files.
Definition: videofile.h:221
virtual FrameTime getLength() const final
Retrieves the video file length.
Definition: videofile.h:102
virtual FrameTime startPoint() const final
Returns the start point of the video file.
Definition: videofile.h:236
virtual bool isOpen() const override
Checks whether the source has been initialized or not.
Definition: videofile.h:125
virtual double getFramerate() const override
Retrieves the framerate.
Definition: videofile.h:95
The structure to hold statistics about the source performance.
Definition: common.h:327
FrameTime currentFrameTime() const
Returns the time of the currently buffered frame.
Definition: videofile.h:259
virtual void setBarrelCorrection(double amount) override
Sets the new barrel correction value.
Definition: videofile.h:203
The camera and video file source base class.
Definition: source.h:51
virtual cv::Size getResolution() const override
Retrieves the resolution of the source.
Definition: videofile.h:108
SourceType
Available source types are the following ones: CAMERA = hardware or network camera, NOTHING = not a working source, STREAM = network stream, VIDEO = video file and VIDEOSET = set of multiple files.
Definition: common.h:68
virtual SourceStats getStats() override
Retrieves the source statistical information.
Definition: videofile.cpp:110
static double speed_ratio
The multiplier of the video file playing speed.
Definition: videofile.h:304
virtual void release()
Forces the release of the worker thread.
Definition: videofile.h:178
VideoFile(SourceID desired_id=UNDEFINED_SOURCE)
Creates a new source.
Definition: videofile.h:62
bool canRecord() const overridefinal
Returns information on the source recording abilities.
Definition: videofile.h:68
std::uint64_t FrameTime
Used to store milliseconds interval in frame times.
Definition: common.h:138
The structure is used for storing a single source frame.
Definition: common.h:241
int totalFrames() const
Returns the total count of the frames in the video file.
Definition: videofile.h:252
int frameFromFrameTime(FrameTime time) const
Returns the expected frame number from the frame time.
Definition: videofile.h:270
bool opened
The open status of the video file.
Definition: videofile.h:294
FrameTime initial_position
The initial position of the video file.
Definition: videofile.h:289
virtual std::string getDescription() const override
Retrieves the description of the source.
Definition: videofile.cpp:105
virtual bool skipFrame(int step)
Skips the specific amount of frames on the video.
Definition: videofile.cpp:165
int current_frame
The number of the currently buffered frame.
Definition: videofile.h:284
virtual bool hasNew() override
Checks whether the device has a new image to be retrieved or not.
Definition: videofile.h:122
bool playing
The flag indicates if the video file is playing or not.
Definition: videofile.h:299
bool seekTime(FrameTime pos)
Seeks a specific position of the video frame.
Definition: videofile.cpp:155