const static std::string TAG = "VideoReader";
-VideoReader* VideoReaderFactory::createVideoReader(VideoSrcType type, const std::string& url)
+VideoReaderPtr VideoReaderFactory::createVideoReader(VideoSrcType type, const std::string& url)
{
- VideoReader* v = nullptr;
+ VideoReaderPtr v;
switch(type){
case VideoSrcType::URL:
- v = new UrlReader(type, url);
+ v = std::make_shared<UrlReader>(type, url);
break;
case VideoSrcType::File:
- v = new FileReader(type, url);
+ v = std::make_shared<FileReader>(type, url);
break;
case VideoSrcType::USB:
- v = new UsbReader(type, url);
+ v = std::make_shared<UsbReader>(type, url);
break;
default:
break;
LOG_ERROR(TAG, "open video " + url);
throw std::runtime_error("Cannot open video url " + url);
}
- LOG_DEBUG(TAG, "reader video sourc succeed.");
+ LOG_DEBUG(TAG, "reader video sourc succeed. ");
}
UrlReader::~UrlReader()
{
+ 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)
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()
-//{
-//}