Implement scoping using yet-unimplemented stream diversion operations; implement...
[Ale.git] / d2 / vise.h
blob8309f8b5b20ea52ddf841eec1dff8e075de68894
1 // Copyright 2004 David Hilvert <dhilvert@auricle.dyndns.org>,
2 // <dhilvert@ugcs.caltech.edu>
4 /* This file is part of the Anti-Lamenessing Engine.
6 The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with the Anti-Lamenessing Engine; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * vise.h: A superclass for all video stabilization engine classes.
25 #ifndef __vise_h__
26 #define __vise_h__
28 #include "transformation.h"
29 #include "image.h"
30 #include "point.h"
33 * Class vise accepts images from vise_core. It is assumed, when an image is
34 * received, that all transformations required for stabilization are available.
35 * This class is abstract, and must be subclassed to be instantiated.
38 class vise {
39 const char *prefix;
40 const char *suffix;
41 protected:
42 ale_real scale_factor;
44 render *r;
47 * Write a frame. This function does not support sequences having
48 * more than 100,000,000 frames (starting count with frame zero).
50 void write_frame(const image *im, unsigned int frame_number) {
51 if (frame_number > 99999999) {
52 fprintf(stderr, "\n\n *** Frame count too high for d2::vise::write_frame() ***\n\n\n");
53 exit(1);
56 int length = strlen(prefix) + strlen(suffix) + 8 + 1;
57 char *filename_string = (char *) malloc(length * sizeof(char));
59 snprintf(filename_string, length, "%s%08d%s", prefix, frame_number, suffix);
61 image_rw::write_image(filename_string, im, &image_rw::exp());
63 free(filename_string);
65 public:
66 vise(render *r, const char *prefix, const char *suffix, ale_real scale_factor) {
67 this->prefix = prefix;
68 this->suffix = suffix;
69 this->r = r;
70 this->scale_factor = scale_factor;
74 * Accept an image for rendering.
77 virtual void render_frame(unsigned int frame_number) = 0;
79 /*
80 * Report the frame lag for this stabilizer.
83 virtual unsigned int lag() = 0;
85 virtual ~vise() {
90 #endif