本文整理匯總了Java中org.opencv.videoio.VideoWriter類的典型用法代碼示例。如果您正苦於以下問題:Java VideoWriter類的具體用法?Java VideoWriter怎麽用?Java VideoWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
VideoWriter類屬於org.opencv.videoio包,在下文中一共展示了VideoWriter類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeFromCameraToFolder
import org.opencv.videoio.VideoWriter; //導入依賴的package包/類
/**
* @param folder
* @param amountOfFrames can be Float.POSITIVE_INFINITY in case of unknown writing time
* @param fps
*/
public void writeFromCameraToFolder(final String folder, final float amountOfFrames, final int fps) {
final String videoFileName = getVideoFileName(folder);
LOGGER.info("videoFileName: " + videoFileName);
writer = new VideoWriter(videoFileName, FOURCC_MJPG, fps, new Size(width, heigth), true);
if (!camera.isOpened()) {
System.out.println("Error");
} else {
int index = 0;
Mat frame = new Mat();
while (true) {
if (camera.read(frame)) {
LOGGER.info("Captured Frame Width " + frame.width() + " Height " + frame.height());
writer.write(frame);
currentFrame = frame;
try {
Thread.currentThread().sleep(66);
} catch (InterruptedException e) {
e.printStackTrace();
}
index++;
}
if (index > amountOfFrames) {
break;
}
frame.release();
}
}
releaseResources();
}