Files
chicken-counting-sukawarna-det/cpp/include/chicken_counter/capture.hpp
T
2026-07-22 00:03:02 +07:00

23 lines
471 B
C++

#pragma once
#include <stdexcept>
#include <string>
#include <opencv2/videoio.hpp>
namespace cc {
inline cv::VideoCapture open_capture(const std::string& source) {
cv::VideoCapture cap;
if (source.size() == 1 && std::isdigit(source[0])) {
cap.open(std::stoi(source));
} else {
cap.open(source);
}
if (!cap.isOpened())
throw std::runtime_error("Unable to open video source: " + source);
return cap;
}
} // namespace cc