forked from zakaria/chicken-counting-sukawarna-det
23 lines
471 B
C++
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
|