30 #include <opencv2/highgui/highgui.hpp>
47 bool ok()
const override {
return !m_images.empty(); }
54 std::vector<cv::Mat> m_images;
55 size_t m_currentImage = 0;
60 ImageSourcePtr openImageFileSequence(std::string
const &dir) {
61 auto ret = ImageSourcePtr{
new FakeImageSource{dir}};
68 FakeImageSource::FakeImageSource(std::string
const &imagesDir) {
71 for (
int imageNum = 1;; ++imageNum) {
72 std::ostringstream fileName;
73 fileName << imagesDir <<
"/";
74 fileName << std::setfill(
'0') << std::setw(4) << imageNum;
77 std::cout <<
"Trying to read image from " << fileName.str()
79 image = cv::imread(fileName.str(), CV_LOAD_IMAGE_COLOR);
83 m_images.push_back(image);
87 std::this_thread::sleep_for(std::chrono::milliseconds(10));
88 m_timestamp = m_timestamp + std::chrono::milliseconds(10);
89 m_currentImage = (m_currentImage + 1) % m_images.size();
96 m_images[m_currentImage].copyTo(color);
97 timestamp = m_timestamp;
101 return m_images.front().size();
cv::Size resolution() const override
Get resolution of the images from this source.
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
void retrieveColor(cv::Mat &color, osvr::util::time::TimeValue ×tamp) override