/** * writeOutput - write the processed result * */ void VideoProcessor::writeOutput() { cv::Mat input; // if no capture device has been set if (!isOpened() || !writer.isOpened()) return; // save the current position long pos = curPos; // jump to the first frame jumpTo(0); while (getNextFrame(input)) { // write output sequence if (outputFile.length()!=0) writeNextFrame(input); } // set the modify flag to false modify = false; // release the writer writer.release(); // jump back to the original position jumpTo(pos); }
void VideoProcessor::run(){ cv::Mat frame; cv::Mat output; if (!isOpened()) // if no capture device has been set return; stop= false; while (!isStopped()) { if (!readNextFrame(frame)) // read next frame if any break; if (windowNameInput.length()!=0) // display input frame cv::imshow(windowNameInput,frame); if (callIt) { // calling the process function or method if (process){ // process the frame process(frame, output); } else if (frameProcessor){ frameProcessor->process(frame,output); } fnumber++; // increment frame number } else { output= frame; } if (outputFile.length()!=0) writeNextFrame(output); if (windowNameOutput.length()!=0) // display output frame cv::imshow(windowNameOutput,output); if (delay>=0 && cv::waitKey(delay)>=0) // introduce a delay stopIt(); if (frameToStop>=0 && getFrameNumber()==frameToStop)// check if we should stop stopIt(); } }