VideoReaderPtr VideoReaderFactory::createVideoReader(VideoSrcType type, const std::string& url)
{
+ VideoReaderPtr v;
switch(type){
case VideoSrcType::URL:
- {
- VideoReaderPtr v (new UrlReader(type, url));
- return v;
- }
+ v = std::make_shared<UrlReader>(type, url);
+ break;
case VideoSrcType::File:
- {
- VideoReaderPtr v (new FileReader(type, url));
- return v;
- }
+ v = std::make_shared<FileReader>(type, url);
+ break;
case VideoSrcType::USB:
- {
- VideoReaderPtr v (new UsbReader(type, url));
- return v;
- }
+ v = std::make_shared<UsbReader>(type, url);
+ break;
default:
break;
}
- return nullptr;
+ return v;
}
VideoReader::~VideoReader()
vcap.release();
}
+static long count = 0;
+
+static void printImg(const cv::Mat& mat)
+{
+ std::cout << mat.at<int>(0,0) << std::endl;
+}
+
bool UrlReader::read(cv::Mat& mat)
{
bool ret = vcap.read(mat);
LOG_ERROR(TAG, "blank frame grabbed");
return false;
}
+ count++;
+ std::string name = "./temp/image_" + std::to_string(count) + ".png";
+ if ((count % 50 == 0)){
+ imwrite(name.c_str(), mat);
+ }
return ret;
}
-
-//
-//void UrlReader::read()
-//{
-//}
-//
-//void FileReader::read()
-//{
-//}
-//
-//void UsbReader::read()
-//{
-//}