bool SndFileSource::openNextFile() { if (mSoundFile) { sf_close(mSoundFile); mSoundFile = 0; } QString filename = getNextFilePath(); if (filename.isEmpty()) return false; SF_INFO fileInfo; memset(&fileInfo, 0, sizeof(fileInfo)); mSoundFile = sf_open(qPrintable(filename), SFM_READ, &fileInfo); if (!mSoundFile) return false; Q_ASSERT(fileInfo.samplerate); mAlsaFrame.setChannelsNo(fileInfo.channels); mAlsaFrame.setSampleTime(1.0/fileInfo.samplerate); mAlsaFrame.setFrameTime(AlsaFrame::DefaultFrameTime); mAlsaFrame.setSourceName(filename); return true; }
bool CTestMonitor::saveFrameToJpeg(cv::Mat frame) { if (m_isMonitorEnabled) { std::vector<int> qualityType; qualityType.push_back(CV_IMWRITE_JPEG_QUALITY); qualityType.push_back(90); deleteFileByNumberIfExists(m_nNextFile, m_sLogFolder); std::string sFilePath = getNextFilePath(m_sLogFolder); sFilePath += ".jpg"; cv::imwrite(sFilePath.c_str(), frame, qualityType); } }
void MatrixFileSource::process() { QString filename = getNextFilePath(); if (filename.isEmpty()) emit processingCompleted(); else { arma::mat frame; if (data::Load(filename.toStdString(), frame, true)) { mMatrixFrame = frame; emit framesReady(); } } }
bool CTestMonitor::enableVideoCollection(bool bEnable, int framesPerSec, unsigned int height, unsigned int width, int codec) { int nColor = 1; cv::Size mySize = cv::Size(width, height); std::string sFilePath = getNextFilePath(m_sLogVideoFolder); sFilePath += ".avi"; //make output video file m_outVideo.open(sFilePath, codec, framesPerSec, mySize, nColor); if (!m_outVideo.isOpened()) { return false; } return true; }