| 127 | } |
| 128 | |
| 129 | int main(int argc, char *argv[]) |
| 130 | { |
| 131 | std::map<std::string, std::string> options; |
| 132 | |
| 133 | int result = ParseOptions(options, CMD_OPTIONS, argv, argc); |
| 134 | if (result != 0) |
| 135 | { |
| 136 | return result; |
| 137 | } |
| 138 | |
| 139 | // Create the network options |
| 140 | common::PipelineOptions pipelineOptions; |
| 141 | pipelineOptions.m_ModelFilePath = GetSpecifiedOption(options, MODEL_FILE_PATH); |
| 142 | pipelineOptions.m_ModelName = GetSpecifiedOption(options, MODEL_NAME); |
| 143 | |
| 144 | if (CheckOptionSpecified(options, PROFILING_ENABLED)) |
| 145 | { |
| 146 | pipelineOptions.m_ProfilingEnabled = GetSpecifiedOption(options, PROFILING_ENABLED) == "true"; |
| 147 | } |
| 148 | if(CheckOptionSpecified(options, PREFERRED_BACKENDS)) |
| 149 | { |
| 150 | pipelineOptions.m_backends = GetPreferredBackendList((GetSpecifiedOption(options, PREFERRED_BACKENDS))); |
| 151 | } |
| 152 | else |
| 153 | { |
| 154 | pipelineOptions.m_backends = {"CpuAcc", "CpuRef"}; |
| 155 | } |
| 156 | |
| 157 | auto labels = AssignColourToLabel(GetSpecifiedOption(options, LABEL_PATH)); |
| 158 | |
| 159 | common::Profiling profiling(pipelineOptions.m_ProfilingEnabled); |
| 160 | profiling.ProfilingStart(); |
| 161 | od::IPipelinePtr objectDetectionPipeline = od::CreatePipeline(pipelineOptions); |
| 162 | |
| 163 | auto inputAndOutput = GetFrameSourceAndSink(options); |
| 164 | std::unique_ptr<common::IFrameReader<cv::Mat>> reader = std::move(std::get<0>(inputAndOutput)); |
| 165 | std::unique_ptr<common::IFrameOutput<cv::Mat>> sink = std::move(std::get<1>(inputAndOutput)); |
| 166 | |
| 167 | if (!sink->IsReady()) |
| 168 | { |
| 169 | std::cerr << "Failed to open video writer."; |
| 170 | return 1; |
| 171 | } |
| 172 | |
| 173 | common::InferenceResults<float> results; |
| 174 | |
| 175 | std::shared_ptr<cv::Mat> frame = reader->ReadFrame(); |
| 176 | |
| 177 | //pre-allocate frames |
| 178 | cv::Mat processed; |
| 179 | |
| 180 | while(!reader->IsExhausted(frame)) |
| 181 | { |
| 182 | objectDetectionPipeline->PreProcessing(*frame, processed); |
| 183 | objectDetectionPipeline->Inference(processed, results); |
| 184 | objectDetectionPipeline->PostProcessing(results, |
| 185 | [&frame, &labels](od::DetectedObjects detects) -> void { |
| 186 | AddInferenceOutputToFrame(detects, *frame, labels); |
nothing calls this directly
no test coverage detected