X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=src%2FVideoReader.cpp;h=cfba7337a73088ac052e12e00193efffe625d929;hb=81741fb5b3fe86bf29a130f367ea102e3aa99b0b;hp=90e3d8a999354256dd4e3e96f5a9c2b4b240ef64;hpb=b3feccd1ee1186c37b39844dc566d39aedaa54ed;p=trackerpp.git diff --git a/src/VideoReader.cpp b/src/VideoReader.cpp index 90e3d8a..cfba733 100644 --- a/src/VideoReader.cpp +++ b/src/VideoReader.cpp @@ -6,18 +6,18 @@ using namespace cv; 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(type, url); break; case VideoSrcType::File: - v = new FileReader(type, url); + v = std::make_shared(type, url); break; case VideoSrcType::USB: - v = new UsbReader(type, url); + v = std::make_shared(type, url); break; default: break; @@ -39,11 +39,19 @@ UrlReader::UrlReader(VideoSrcType type, const std::string& url) : VideoReader(ty 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(0,0) << std::endl; } bool UrlReader::read(cv::Mat& mat) @@ -53,18 +61,10 @@ 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() -//{ -//}