summaryrefslogtreecommitdiffstats
path: root/jni/feature_mos/src/mosaic/MosaicTypes.h
blob: 395ec458655f66cfbc982315e6afd4415e29630d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

///////////////////////////////////////////////////
// MosaicTypes.h
// S.O. # :
// Author(s): zkira
// $Id: MosaicTypes.h,v 1.15 2011/06/17 13:35:48 mbansal Exp $


#ifndef MOSAIC_TYPES_H
#define MOSAIC_TYPES_H

#include "ImageUtils.h"

/**
 *  Definition of rectangle in a mosaic.
 */
class MosaicRect
{
    public:
        MosaicRect()
        {
            left = right = top = bottom = 0.0;
        }

        inline int Width()
        {
            return right - left;
        }

        inline int Height()
        {
            return bottom - top;
        }

        /**
         *  Bounds of the rectangle
         */
        int left, right, top, bottom;
};

class BlendRect
{
    public:
    double lft, rgt, top, bot;
};

/**
 *  A frame making up the mosaic.
 *  Note: Currently assumes a YVU image
 *  containing separate Y,V, and U planes
 *  in contiguous memory (in that order).
 */
class MosaicFrame {
public:
  ImageType image;
  double trs[3][3];
  int width, height;
  BlendRect brect;  // This frame warped to the Mosaic coordinate system
  BlendRect vcrect; // brect clipped using the voronoi neighbors
  bool internal_allocation;

  MosaicFrame() { };
  MosaicFrame(int _width, int _height, bool allocate=true)
  {
    width = _width;
    height = _height;
    internal_allocation = allocate;
    if(internal_allocation)
        image = ImageUtils::allocateImage(width, height, ImageUtils::IMAGE_TYPE_NUM_CHANNELS);
  }


  ~MosaicFrame()
  {
    if(internal_allocation)
        if (image)
        free(image);
  }

  /**
  *  Get the V plane of the image.
  */
  inline ImageType getV()
  {
    return (image + (width*height));
  }

  /**
  *  Get the U plane of the image.
  */
  inline ImageType getU()
  {
    return (image + (width*height*2));
  }

  /**
  *  Get a pixel from the V plane of the image.
  */
  inline int getV(int y, int x)
  {
    ImageType U = image + (width*height);
    return U[y*width+x];
  }

  /**
  *  Get a pixel from the U plane of the image.
  */
  inline int getU(int y, int x)
  {
    ImageType U = image + (width*height*2);
    return U[y*width+x];
  }

};

/**
 *  Structure for describing a warp.
 */
typedef struct {
  int horizontal;
  double theta;
  double x;
  double y;
  double width;
  double radius;
  double direction;
  double correction;
  int blendRange;
  int blendRangeUV;
  int nlevs;
  int nlevsC;
  int blendingType;
  int stripType;
  // Add an overlap to prevent a gap between pictures due to roundoffs
  double roundoffOverlap;// 1.5

} BlendParams;

#endif