OSDN Git Service

add video.cpp
[paldema/paldema.git] / src / test / video.cpp
diff --git a/src/test/video.cpp b/src/test/video.cpp
new file mode 100644 (file)
index 0000000..341a69f
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright (C) 2009 Masaki Saito <rezoolab@gmail.com>\r
+//\r
+// video.cpp
+// このプログラムは連番のtgaファイルを読み込み、
+// スペースキーを押す度に画像が更新されます。
+
+#include "../cpp/pdvideo.cpp"\r
+#include <string>\r
+#include <cv.h>\r
+#include <highgui.h>
+
+const std::string filename = "dat/video00.tga";
+
+int main() {
+  pd::Video* video = new pd::Video(filename);
+  
+  IplImage* img = video->getImage();
+  
+  cvNamedWindow("Video", CV_WINDOW_AUTOSIZE);
+  cvShowImage("Video", img);
+  cvWaitKey(0);
+  
+  while(true) {
+    if((img = video->next()) != NULL) {
+      cvShowImage("Video", img);
+      cvWaitKey(0);
+    }else break;
+  }
+  
+  delete video;
+  return 0;
+}