| 89 | } |
| 90 | |
| 91 | std::tuple<std::unique_ptr<common::IFrameReader<cv::Mat>>, |
| 92 | std::unique_ptr<common::IFrameOutput<cv::Mat>>> |
| 93 | GetFrameSourceAndSink(const std::map<std::string, std::string>& options) { |
| 94 | |
| 95 | std::unique_ptr<common::IFrameReader<cv::Mat>> readerPtr; |
| 96 | |
| 97 | std::unique_ptr<common::CvVideoFrameReader> reader = std::make_unique<common::CvVideoFrameReader>(); |
| 98 | reader->Init(GetSpecifiedOption(options, VIDEO_FILE_PATH)); |
| 99 | |
| 100 | auto enc = reader->GetSourceEncodingInt(); |
| 101 | auto fps = reader->GetSourceFps(); |
| 102 | auto w = reader->GetSourceWidth(); |
| 103 | auto h = reader->GetSourceHeight(); |
| 104 | if (!reader->ConvertToRGB()) |
| 105 | { |
| 106 | readerPtr = std::move(std::make_unique<common::CvVideoFrameReaderRgbWrapper>(std::move(reader))); |
| 107 | } |
| 108 | else |
| 109 | { |
| 110 | readerPtr = std::move(reader); |
| 111 | } |
| 112 | |
| 113 | if(CheckOptionSpecified(options, OUTPUT_VIDEO_FILE_PATH)) |
| 114 | { |
| 115 | std::string outputVideo = GetSpecifiedOption(options, OUTPUT_VIDEO_FILE_PATH); |
| 116 | auto writer = std::make_unique<common::CvVideoFileWriter>(); |
| 117 | writer->Init(outputVideo, enc, fps, w, h); |
| 118 | |
| 119 | return std::make_tuple<>(std::move(readerPtr), std::move(writer)); |
| 120 | } |
| 121 | else |
| 122 | { |
| 123 | auto writer = std::make_unique<common::CvWindowOutput>(); |
| 124 | writer->Init("Processed Video"); |
| 125 | return std::make_tuple<>(std::move(readerPtr), std::move(writer)); |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | int main(int argc, char *argv[]) |
| 130 | { |
no test coverage detected