Mercurial Hosting > traffic-intelligence
view c/cvutils.cpp @ 11:e77e2fd69b02
modularized code (not compiling)
author | Nicolas Saunier <nico@confins.net> |
---|---|
date | Wed, 11 Nov 2009 12:01:43 -0500 |
parents | eb38637f338d |
children | ff5403319cec |
line wrap: on
line source
#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; } void goToFrameNum(CvCapture* capture, const int& currentFrameNum, const int& targetFrameNum) { if (currentFrameNum > targetFrameNum) cerr << "Current frame number " << currentFrameNum << " is after the target frame number " << targetFrameNum << "." << endl; for (int frameNum = currentFrameNum; frameNum<targetFrameNum; ++frameNum) { IplImage* frame = cvQueryFrame(inputVideo); if (!frame) break; frameNum++; } }