| 58 | } |
| 59 | |
| 60 | bool utils::setInputStream(const utils::InputStream& source, const std::string& imagePath, const std::string& videoPath, const int& cameraID, |
| 61 | cv::VideoCapture& capture, int& totalBatches, int& delayTime, utils::InitParameter& param) |
| 62 | { |
| 63 | int total_frames = 0; |
| 64 | std::string img_format; |
| 65 | switch (source) |
| 66 | { |
| 67 | case utils::InputStream::IMAGE: |
| 68 | img_format = imagePath.substr(imagePath.size()-4, 4); |
| 69 | if (img_format == ".png" || img_format == ".PNG") |
| 70 | { |
| 71 | sample::gLogWarning << "+-----------------------------------------------------------+" << std::endl; |
| 72 | sample::gLogWarning << "| If you use PNG format pictures, the file name must be eg: |" << std::endl; |
| 73 | sample::gLogWarning << "| demo0.png, demo1.png, demo2.png ......, but not demo.png. |" << std::endl; |
| 74 | sample::gLogWarning << "| The above rules are determined by OpenCV. |" << std::endl; |
| 75 | sample::gLogWarning << "+-----------------------------------------------------------+" << std::endl; |
| 76 | } |
| 77 | capture.open(imagePath); //cv::CAP_IMAGES : !< OpenCV Image Sequence (e.g. img_%02d.jpg) |
| 78 | param.batch_size = 1; |
| 79 | total_frames = 1; |
| 80 | totalBatches = 1; |
| 81 | delayTime = 0; |
| 82 | break; |
| 83 | case utils::InputStream::VIDEO: |
| 84 | capture.open(videoPath); |
| 85 | total_frames = capture.get(cv::CAP_PROP_FRAME_COUNT); |
| 86 | totalBatches = (total_frames % param.batch_size == 0) ? |
| 87 | (total_frames / param.batch_size) : (total_frames / param.batch_size + 1); |
| 88 | break; |
| 89 | case utils::InputStream::CAMERA: |
| 90 | capture.open(cameraID); |
| 91 | total_frames = INT_MAX; |
| 92 | totalBatches = INT_MAX; |
| 93 | break; |
| 94 | default: |
| 95 | break; |
| 96 | } |
| 97 | param.src_h = capture.get(cv::CAP_PROP_FRAME_HEIGHT); |
| 98 | param.src_w = capture.get(cv::CAP_PROP_FRAME_WIDTH); |
| 99 | |
| 100 | return capture.isOpened(); |
| 101 | } |
| 102 | |
| 103 | void utils::setRenderWindow(InitParameter& param) |
| 104 | { |
nothing calls this directly
no outgoing calls
no test coverage detected