Skip to content

Instantly share code, notes, and snippets.

@berak
Created August 27, 2015 06:07
Show Gist options
  • Select an option

  • Save berak/28ba78093943d3120dd4 to your computer and use it in GitHub Desktop.

Select an option

Save berak/28ba78093943d3120dd4 to your computer and use it in GitHub Desktop.
import org.opencv.core.*;
import org.opencv.imgproc.*;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.videoio.*;
class SimpleSample {
static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }
//~ static int fcc(char a, char b, char c, char d) {
//~ return (d<<24 | c<<16 | b<<8 | a);
//~ }
public static void main(String[] args) {
Mat frame = new Mat(480,640,CvType.CV_8UC3,Scalar.all(127));
int fourcc = VideoWriter.fourcc('m','j','p','g');
VideoWriter writer = new VideoWriter("my.avi", fourcc, 20, frame.size(), true);
if (!writer.isOpened()) {
System.out.println("bummer!");
return;
}
for (int i=0; i<100; i++) {
Mat f = frame.clone();
Imgproc.putText(f, ("frame" + i), new Point(100,100), Core.FONT_HERSHEY_PLAIN, 2, new Scalar(200,0,0),3);
writer.write(f);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment