forked from zakaria/chicken-counting-sukawarna-det
Create C++ version
This commit is contained in:
1 parent
1a3242f611
commit
f34eaa3af4
25 files changed
+3353
-24
No files matched your search
@@ -0,0 +1,22 @@
|
||||
#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
|
||||
Reference in new issue
Block a user