Fawkes API Fawkes Development Version
square_shrinker.cpp
1
2/***************************************************************************
3 * square_shrinker.cpp - Implementation of SquareShrinker
4 *
5 * Created: Tue Apr 22 2008 20:58:40 (GO2008, day 4)
6 * Copyright 2005-2008 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#include <fvclassifiers/square_shrinker.h>
25#include <fvmodels/color/colormodel.h>
26#include <fvmodels/scanlines/scanlinemodel.h>
27#include <fvutils/base/roi.h>
28#include <fvutils/color/colorspaces.h>
29
30#include <cstddef>
31
32namespace firevision {
33
34/** @class SquareShrinker <fvclassifiers/square_shrinker.h>
35 * Square shrinker.
36 * This shrinker makes sure that a ROI is always squared.
37 * @author Tim Niemueller
38 */
39
40/** Constructor. */
42{
43}
44
45/** Shrink!
46 * Do the actual shrinking.
47 * @param roi ROI to shrink
48 */
49void
51{
52 if (roi->width < roi->height) {
53 roi->start.y += (roi->height - roi->width) / 2;
54 roi->height = roi->width;
55 } else if (roi->width > roi->height) {
56 roi->start.x += (roi->width - roi->height) / 2;
57 roi->width = roi->height;
58 }
59}
60
61} // end namespace firevision
Region of interest.
Definition: roi.h:55
unsigned int height
ROI height.
Definition: roi.h:119
fawkes::upoint_t start
ROI start.
Definition: roi.h:115
unsigned int width
ROI width.
Definition: roi.h:117
Shrinker class to shrink ROIs.
Definition: shrinker.h:32
virtual void shrink(ROI *roi)
Shrink! Do the actual shrinking.
unsigned int x
x coordinate
Definition: types.h:36
unsigned int y
y coordinate
Definition: types.h:37