#include "StdAfx.h" #include "ImageMatQueue.h" #include "PublicFunc.h" ImageMatQueue::ImageMatQueue(void) { pixType=-1; /*if(!bRun) { m_threadProc = boost::thread(&ImageMatQueue::proc, this); bRun = true; }*/ } void ImageMatQueue::run() { if(!bRun) { m_threadProc = boost::thread(&ImageMatQueue::proc, this); bRun = true; } } ImageMatQueue::~ImageMatQueue(void) { bRun = false; Sleep(100); } void ImageMatQueue::pushMat(JpegBuffer& data) { boost::lock_guard lck(m_mtxJB); m_pImages.push(data); } cv::Mat ImageMatQueue::popMat() { boost::lock_guard lck(m_Locker); return _popMat(); } bool ImageMatQueue::valid() { boost::lock_guard lck(m_mtxJB); return !m_images.empty(); } void ImageMatQueue::clear() { boost::lock_guard lck(m_mtxJB); //for (int i=0;i(); m_pImages = std::queue(); } void ImageMatQueue::setlist(std::vector> list) { //m_iaList.clear(); m_iaList=list; } cv::Mat ImageMatQueue::_popMat() { cv::Mat image = m_images.front(); m_images.pop(); return image; } bool ImageMatQueue::empty() { boost::lock_guard lck(m_mtxJB); return m_images.empty() && m_pImages.empty(); } void ImageMatQueue::proc() { while(bRun) { Sleep(5); { boost::lock_guard lck(m_mtxJB); if(m_images.empty() && !m_pImages.empty()) { if (pixType!=-1) { cv::Mat image = m_pImages.front().getMat(pixType); int side=m_pImages.front().getSide(); for (int i=0;iapply(image,side); } m_pImages.pop(); if (!image.empty()) { m_images.push(image); } } } } } }