changeset 9:eb38637f338d

created cvutils
author Nicolas Saunier <nico@confins.net>
date Sun, 08 Nov 2009 10:33:41 -0500
parents 59b7e3954178
children 068cf45c3f1b
files c/Makefile c/cvutils.cpp c/test-pixels.cpp include/cvutils.hpp
diffstat 4 files changed, 36 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/c/Makefile	Sat Nov 07 23:33:51 2009 -0500
+++ b/c/Makefile	Sun Nov 08 10:33:41 2009 -0500
@@ -2,6 +2,8 @@
 
 CXX = g++
 
+INCLUDE = -I../include
+
 LDFLAGS = -lm
 LDFLAGS += -lboost_program_options-mt -lboost_filesystem-mt -lboost_system-mt -lboost_unit_test_framework-mt
 LDFLAGS += -lfltk
@@ -45,7 +47,7 @@
 builddir:
 	@createdirectory.sh $(BUILD_DIR)
 
-test-pixels: test-pixels.o
+test-pixels: test-pixels.o cvutils.o
 	$(CXX) $(CFLAGS) $(LIBS) $^ -o $(BUILD_DIR)/test-pixels $(LDFLAGS)
 #	$(CXX) $(CFLAGS) $(LIBS) $^ -o $(BUILD_DIR)/$@ $(LDFLAGS)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/c/cvutils.cpp	Sun Nov 08 10:33:41 2009 -0500
@@ -0,0 +1,20 @@
+#include "cvutils.hpp"
+
+#include "opencv/cv.h"
+
+#include <iostream>
+
+using namespace std;
+
+IplImage* allocateImage(const int& width, const int& height, const int& depth, const int& channels) { return ::allocateImage(cvSize(width, height), depth, channels);}
+
+IplImage* allocateImage(const CvSize& size, const int& depth, const int& channels) {
+  IplImage* image = cvCreateImage(size, depth, channels);
+
+  if (!image) {
+    cerr << "Error: Couldn't allocate image.  Out of memory?\n" << endl;
+    exit(-1);
+  }
+
+  return image;
+}
--- a/c/test-pixels.cpp	Sat Nov 07 23:33:51 2009 -0500
+++ b/c/test-pixels.cpp	Sun Nov 08 10:33:41 2009 -0500
@@ -1,3 +1,5 @@
+#include "cvutils.hpp"
+
 #include "opencv/cv.h"
 #include "opencv/highgui.h"
 
@@ -5,16 +7,6 @@
 
 using namespace std;
 
-IplImage* allocateImage(const CvSize& size, const int& depth, const int& channels) {
-  IplImage* image = cvCreateImage(size, depth, channels);
-
-  if (!image) {
-    cerr << "Error: Couldn't allocate image.  Out of memory?\n" << endl;
-    exit(-1);
-  }
-
-  return image;
-}
 
 int main(int argc, char *argv[]) {
   //cout << "Hello World" << endl;
@@ -22,7 +14,7 @@
   CvCapture *inputVideo = cvCaptureFromFile(argv[1]);
 
   IplImage* frame = cvQueryFrame(inputVideo);
-  IplImage* bwFrame = allocateImage(cvSize(frame->width, frame->height), IPL_DEPTH_8U, 1);
+  IplImage* bwFrame = allocateImage(frame->width, frame->height, IPL_DEPTH_8U, 1);
 
   int frameNum = 0;
   while (frame) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/cvutils.hpp	Sun Nov 08 10:33:41 2009 -0500
@@ -0,0 +1,10 @@
+#ifndef CVUTILS_HPP
+#define CVUTILS_HPP
+
+#include "opencv/cxtypes.h"
+
+IplImage* allocateImage(const int& width, const int& height, const int& depth, const int& channels);
+
+IplImage* allocateImage(const CvSize& size, const int& depth, const int& channels);
+
+#endif