30 #ifndef ANALYSISCONTROLLER_H
31 #define ANALYSISCONTROLLER_H
42 #include "source/camera.h"
123 bool addSource(
const std::vector<std::string>& paths,
323 bool load(
const std::string& path =
"results.cpa");
360 bool save(
const std::string& path =
"results.cpa");
400 { highlight_color = color; }
429 const std::string& extension =
"avi");
563 bool start(
const std::vector<SourceID>& calc_sources,
564 const std::vector<cavapa::CameraSettings>& settings,
565 const std::vector<cavapa::CalibrationPoint>& points,
586 bool checkDiskSpace();
602 void checkRecordLimits();
612 inline std::string createRecordName(
SourceID id)
const;
620 cv::Mat drawExcludes(
SourceID id,
const cv::Mat& image);
627 static unsigned int getFreeDiskSpace(
const std::string& path);
636 inline std::shared_ptr<Source> getSource(
SourceID id)
const;
644 SourceID getSourceDevice(
int device)
const;
653 std::vector<FrameCapture> highlight(
654 const std::vector<FrameCapture>& captures,
655 const std::vector<cavapa::Sightings>& sightings)
const;
663 inline cv::Mat highlightFrame(
const cv::Mat& image,
664 const std::vector<cavapa::Sighting>& sightings)
const;
671 static inline bool isVideoFile(
const std::shared_ptr<Source>& src);
677 inline void playSelectedSources();
685 static cv::Mat printText(
const cv::Mat& image,
const std::string& text);
691 inline bool selectedAreVideos()
const;
697 inline bool selectedSourcesOpen()
const;
709 std::vector<cavapa::CameraSettings> setCalculationSettings(
710 const std::vector<SourceID>& calc_sources,
711 const std::vector<cavapa::CameraSettings>& settings);
719 void setLastError(
const std::string& desc) { last_error = desc; }
726 inline bool sourceExists(
SourceID id)
const;
733 inline bool sourceInSelection(
SourceID id)
const;
742 bool stepSource(
SourceID id,
int amount);
747 inline void stopSelectedSources();
756 static const unsigned int LAG_WARNING_CONCURRENT = 5;
759 static const unsigned int LAG_WARNING_INTERVAL = 5;
762 static const unsigned int MAXIMUM_FPS = 50.0;
766 std::unique_ptr<cavapa::CavapaDetector> detector =
nullptr;
767 std::map<SourceID, std::vector<cv::Rect>> exclude_rectangles;
768 std::string folder =
"";
769 cv::Scalar highlight_color = cv::Scalar(0, 0, 255);
770 bool highlight_sightings =
false;
772 unsigned int lag_warning_concurrent = 0;
773 std::string last_error =
"";
776 unsigned int max_record_length = 0;
779 bool recording =
false;
780 bool running =
false;
781 std::vector<SourceID> selected_sources;
782 std::vector<std::shared_ptr<Source>> sources;
783 double speed_ratio = 1.0;
785 std::string video_extension =
"avi";
788 int processed_frames = 0;
789 std::uint64_t total_process_time = 0;
790 #endif // _DEBUG_TIMERS
798 void updateSources();
835 void updated(
const std::vector<FrameCapture>& frames,
836 const FrameStats& statistics);
840 #endif // ANALYSISCONTROLLER_H
bool canPause() const
Indicates if the running calculation can be paused.
Definition: analysiscontroller.cpp:201
bool isPaused() const
Retrieves the current pause status.
Definition: analysiscontroller.h:304
SourceType getSourceType(SourceID id) const
Returns the type of the selected source.
Definition: analysiscontroller.cpp:435
bool removeSource(SourceID id)
Removes the source.
Definition: analysiscontroller.cpp:604
std::vector< FrameStats > getStatistics(FrameTime start, FrameTime stop, int points) const
Returns the calculation statistics from the given period.
Definition: results.cpp:334
bool sourceStepForward(SourceID id)
Steps the source one frame forward.
Definition: analysiscontroller.h:541
FrameTime getVideoLength(SourceID id) const
Retrieves the length of the video source.
Definition: analysiscontroller.cpp:441
bool exportToCSV(const ExportOptions &options) const
Exports the results to the CSV file.
Definition: results.cpp:124
unsigned int SourceID
Used to indicate unique source ID-numbers.
Definition: common.h:229
const SourceID UNDEFINED_SOURCE
Used to indicate unknown sources.
Definition: common.h:234
bool isRunning() const
Retrieves the current status of the calculation.
Definition: analysiscontroller.h:310
void setWorkDirectory(const std::string &path)
Sets the path for the calculation directory.
Definition: analysiscontroller.cpp:857
void setRecordTimeLimit(unsigned int length)
Sets the maximum length of one recording.
Definition: analysiscontroller.h:435
void setHighlightColor(const cv::Scalar &color)
Sets the sighting's highlighting color.
Definition: analysiscontroller.h:399
bool sourceStepBackward(SourceID id)
Steps the source one frame back.
Definition: analysiscontroller.h:531
int countAvailableCameras() const
Counts the available connected hardware cameras.
Definition: analysiscontroller.cpp:280
bool canChangeSourceResolution(SourceID id) const
Checks if the source resolution can be changed.
Definition: analysiscontroller.cpp:194
void setSourceExcludes(SourceID id, const std::vector< cv::Rect > &rects)
Sets the excluded rectangles for a source.
bool setCameraFPS(double fps)
Sets the default FPS for camera sources.
Definition: analysiscontroller.cpp:760
bool save(const std::string &path="results.cpa")
Saves the calculation results and sightings.
Definition: analysiscontroller.cpp:659
bool sourceStop(SourceID id)
Stops playing the video source.
Definition: analysiscontroller.cpp:950
The structure to hold statistics about the source performance.
Definition: common.h:327
void error(const std::string &message, ErrorLevel level)
Signals that something went wrong during the calculation.
bool setVideoSpeed(double ratio=1.0)
Sets the video source speed.
Definition: analysiscontroller.cpp:846
bool load(const std::string &path="results.cpa")
Loads the calculation results and recorded file information.
Definition: analysiscontroller.cpp:549
std::vector< FrameStats > getResults(FrameTime start, FrameTime stop, int points) const
Returns calculation results from a given period.
Definition: analysiscontroller.h:196
std::vector< std::string > getSourceFilenames(SourceID id) const
Returns the list of the files associated with the source.
Definition: analysiscontroller.cpp:388
bool sourcePlay(SourceID id)
Starts playing a video source.
Definition: analysiscontroller.cpp:902
cv::Size getSourceResolution(SourceID id) const
Retrieves the source's frame resolution.
Definition: analysiscontroller.cpp:423
bool setSourceBarrelCorrection(SourceID id, double amount)
Sets the barrel correction on a source.
Definition: analysiscontroller.cpp:813
Base class of the CAVAPA calculations.
Definition: analysiscontroller.h:70
bool pause()
Pauses or unpauses the calculation.
Definition: analysiscontroller.cpp:559
SourceID addSource(const std::string &path, SourceID id=UNDEFINED_SOURCE, FrameTime start_point=0)
Adds a custom video source.
Definition: analysiscontroller.cpp:98
int getSourceCount() const
Retrieves the total count of sources.
Definition: analysiscontroller.h:208
int initCameras(int max_loops=10)
Initializes the hardware cameras.
Definition: analysiscontroller.cpp:509
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
DISALLOW_COPY_AND_ASSIGN(AnalysisController)
Copy and assign of the class is not allowed.
bool setSourceResolution(SourceID id, const cv::Size &new_size)
Sets the source resolution.
Definition: analysiscontroller.cpp:829
SourceStats getSourceStats(SourceID id) const
Retrieves the source's current statistics.
Definition: analysiscontroller.cpp:429
void calculationComplete()
Signals that calculation has ended.
bool reset()
Resets the calculation results.
Definition: analysiscontroller.cpp:628
void updated(const std::vector< FrameCapture > &frames, const FrameStats &statistics)
It signals frame updates or calculation updates.
std::uint64_t FrameTime
Used to store milliseconds interval in frame times.
Definition: common.h:138
void setHighlight(bool highlight)
Sets the individual sighting rectangle highlights.
Definition: analysiscontroller.h:390
std::vector< cv::Rect > getSourceExcludes(SourceID id) const
Returns the currently excluded rectangles from the source.
The structure holds CSV export options.
Definition: common.h:183
std::vector< SourceID > getSourceListing() const
Returns a list of all sources in the class.
Definition: analysiscontroller.cpp:405
bool exportResults(const ExportOptions &options) const
Exports the current Results to the CSV File.
Definition: analysiscontroller.h:158
FrameTime getSourcePosition(SourceID id) const
Retrieves the current time position of a source.
Definition: analysiscontroller.cpp:417
bool start(const std::vector< SourceID > &calc_sources, const std::vector< cavapa::CameraSettings > &settings, const std::vector< cavapa::CalibrationPoint > &points, bool record=false, int calc_time=0)
Starts the CAVAPA calculation.
Definition: analysiscontroller.cpp:971
double getCalculationFPS() const
Retrieves the calculation framerate.
Definition: analysiscontroller.h:169
AnalysisController()
Creates the CAVAPA object.
Definition: analysiscontroller.cpp:87
void stop()
Stops the current CAVAPA calculation.
Definition: analysiscontroller.cpp:1101
bool setPosition(FrameTime pos)
Sets the current time position of all the sources.
Definition: analysiscontroller.cpp:781
std::string getLastError() const
Retrieves the last error that occured.
Definition: analysiscontroller.h:180
ErrorLevel
Error level indicator.
Definition: common.h:77
std::string getSourceDescription(SourceID id) const
Returns the description of the source.
Definition: analysiscontroller.cpp:366
bool sourceSeek(SourceID id, FrameTime position)
Seeks the video source to a specific time.
Definition: analysiscontroller.cpp:924
static double getDefaultFPS()
Retrieves the default framerate that has been set.
Definition: camera.h:114
bool setRecorderCodec(const std::string &codec, const std::string &extension="avi")
Sets the default camera recorder codec.
Definition: analysiscontroller.cpp:806
bool sourceCanRecord(SourceID id) const
Checks if the source is capable of recording.
Definition: analysiscontroller.cpp:875