| 74 | } |
| 75 | |
| 76 | opcv::ImageHandle ImageFromMat(const cv::Mat &image) { |
| 77 | opcv::ImageHandle handle; |
| 78 | if (image.empty()) { |
| 79 | return handle; |
| 80 | } |
| 81 | |
| 82 | handle.width = image.cols; |
| 83 | handle.height = image.rows; |
| 84 | handle.channels = image.channels(); |
| 85 | handle.bytes.assign(image.data, image.data + static_cast<size_t>(image.total() * image.elemSize())); |
| 86 | return handle; |
| 87 | } |
| 88 | |
| 89 | long long MeasureMilliseconds(const std::function<bool()> &operation, bool &ok) { |
| 90 | const auto start = std::chrono::steady_clock::now(); |