Mercurial Hosting > traffic-intelligence
changeset 10:068cf45c3f1b
added optical flow skeleton (test to reach a frame with cvqueryframe (fast for small resolutions)
author | Nicolas Saunier <nico@confins.net> |
---|---|
date | Mon, 09 Nov 2009 01:56:25 -0500 |
parents | eb38637f338d |
children | e77e2fd69b02 |
files | c/Makefile c/optical-flow.cpp |
diffstat | 2 files changed, 52 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/c/Makefile Sun Nov 08 10:33:41 2009 -0500 +++ b/c/Makefile Mon Nov 09 01:56:25 2009 -0500 @@ -40,16 +40,24 @@ CXXFLAGS = $(INCLUDE) $(CFLAGS) +#GUI_OBJS = +CV_OBJS = cvutils.o +#COMMON_OBJS = +OBJS = $(COMMON_OBJS) $(CV_OBJS) +#TESTS_OBJS = + default: all builddir -all: test-pixels +all: test-pixels optical-flow builddir: @createdirectory.sh $(BUILD_DIR) -test-pixels: test-pixels.o cvutils.o - $(CXX) $(CFLAGS) $(LIBS) $^ -o $(BUILD_DIR)/test-pixels $(LDFLAGS) -# $(CXX) $(CFLAGS) $(LIBS) $^ -o $(BUILD_DIR)/$@ $(LDFLAGS) +optical-flow: optical-flow.o $(OBJS) + $(CXX) $(CFLAGS) $(LIBS) $^ -o $(BUILD_DIR)/$@ $(LDFLAGS) + +test-pixels: test-pixels.o $(OBJS) + $(CXX) $(CFLAGS) $(LIBS) $^ -o $(BUILD_DIR)/$@ $(LDFLAGS) clean: rm -f *.gch */*.o *.o *.a $(BUILD_DIR)/*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c/optical-flow.cpp Mon Nov 09 01:56:25 2009 -0500 @@ -0,0 +1,40 @@ +#include "cvutils.hpp" + +#include "opencv/cv.h" +#include "opencv/highgui.h" + +#include <iostream> +#include <ctime> + +using namespace std; + + +int main(int argc, char *argv[]) { + //cout << "Hello World" << endl; + + CvCapture *inputVideo = cvCaptureFromFile(argv[1]); + + IplImage* frame = cvQueryFrame(inputVideo); + //IplImage* bwFrame = allocateImage(frame->width, frame->height, IPL_DEPTH_8U, 1); + + int frameNum = 0; + time_t seconds; + time_t t0 = time(NULL); + while (frame) { + if (frameNum%1000 == 0) { + seconds = time(NULL)-t0; + + cout << frameNum << " " << seconds << endl; + } +// cvConvertImage(frame, bwFrame); + +// for (int i=0; i<frame->height; ++i) +// for (int j=0; j<frame->width; ++j) +// int gray = cvGetReal2D(bwFrame, i, j); + + frame = cvQueryFrame(inputVideo); + frameNum++; + } + + return 1; +}