I am trying to Write a mp4 file with h264 after writing some text in video frame i have implemented the queue deque concept with boost thread i have tried in both windows and ubuntu. windows with thread in deque works some what fine but same code in Ubuntu based system throws segfault any help will be appreciated
void AddQueue(const Mat &image)
{
m_tempQueue.push(image);
}
void DeQue(string destFile,int width, int height, int fps) //called with thread
{
string szFuncName = "VideoOverlay::DeQue";
std::unique_lock<std::mutex> mlock(m_Img_Mutex);
try {
VideoWriter videocc(destFile, VideoWriter::fourcc('m', 'p', '4', 'v'), fps, cv::Size(width, height));
while (true)
{
if (!m_tempQueue.empty()) {
cv::Mat image(m_tempQueue.front());
videocc.write(image);
// CLog::AddLogDebug(str(boost::format("Pull : %1%") % m_tempQueue.size()));
if(!m_tempQueue.empty())
m_tempQueue.pop();
if (m_tempQueue.empty() && !m_ProcessQueue)
{
videocc.release();
break;
}
}
else if (!m_ProcessQueue)
{
if(videocc.isOpened())
videocc.release();
break;
}
//m_Img_Mutex.unlock();
}
}catch (...){
CLog::AddLogDebug(str(boost::format("Error caught at function: %1%")%szFuncName));
// m_statusCode= 300;
}
}
//Call method.....
m_thread = std::thread(&VideoOverlay::DeQue, this,destFile,width,height,fps);
//will be called before reading image
The deque thread will run until m_ProcessQueue or image is empty at m_tempQueue
I am looking for samples also
Aucun commentaire:
Enregistrer un commentaire