1 | /***************************************************************************
|
---|
2 | *
|
---|
3 | * Copyright 2000 by David Demirdjian. All rights reserved.
|
---|
4 | *
|
---|
5 | * Developed by David Demirdjian
|
---|
6 | *
|
---|
7 | * Permission to use, copy, or modify this software and its documentation
|
---|
8 | * for educational and research purposes only and without fee is hereby
|
---|
9 | * granted, provided that this copyright notice and the original authors's
|
---|
10 | * names appear on all copies and supporting documentation. If individual
|
---|
11 | * files are separated from this distribution directory structure, this
|
---|
12 | * copyright notice must be included. For any other uses of this software,
|
---|
13 | * in original or modified form, including but not limited to distribution
|
---|
14 | * in whole or in part, specific prior permission must be obtained from
|
---|
15 | * MIT. These programs shall not be used, rewritten, or adapted as the
|
---|
16 | * basis of a commercial software or hardware product without first
|
---|
17 | * obtaining appropriate licenses from David Demirdjian. The author makes
|
---|
18 | * no representations about the suitability of this software for any purpose.
|
---|
19 | * It is provided "as is" without express or implied warranty.
|
---|
20 | *
|
---|
21 | **************************************************************************/
|
---|
22 | #ifndef _DATASTRUCTURES_H
|
---|
23 | #define _DATASTRUCTURES_H
|
---|
24 |
|
---|
25 | // ********************************************************************
|
---|
26 | // ********************************************************************
|
---|
27 | // InputImages: structure containing the input images (at a given scale)
|
---|
28 | class InputImages {
|
---|
29 | public:
|
---|
30 | InputImages();
|
---|
31 | ~InputImages();
|
---|
32 | void alloc(int w, int h, int extra_margin);
|
---|
33 | void deAlloc();
|
---|
34 |
|
---|
35 | int numImages; // 2 (pair) or 3
|
---|
36 | unsigned char *subIm_l, *subIm_r, *subIm_t;
|
---|
37 | unsigned char *subIm_l_origin, *subIm_r_origin, *subIm_t_origin;
|
---|
38 | };
|
---|
39 |
|
---|
40 | // **********************************************************************
|
---|
41 | // StereoImage: structure representing the depth information (disparity and sub-pixel)
|
---|
42 | // at a given scale.
|
---|
43 | // This contains in particular: imDepth8u and imDepth32f
|
---|
44 | // which contain the disparity images (size width*height, 8bits unsigned char
|
---|
45 | // and 32bits float) stored as 1-dim. arrays.
|
---|
46 | class StereoImage {
|
---|
47 | public:
|
---|
48 | StereoImage();
|
---|
49 | ~StereoImage();
|
---|
50 | void alloc(int w, int h);
|
---|
51 | void deAlloc();
|
---|
52 | void Reset(void);
|
---|
53 |
|
---|
54 | void createValidPixelsList(int topmargin);
|
---|
55 | // create some 'borders' around the stereo image
|
---|
56 | void setUndefinedBorders(int leftMargin, int rightMargin);
|
---|
57 | // set the undefined depth value ...
|
---|
58 | void setUndefinedDepthValue(const unsigned char undefined_val);
|
---|
59 |
|
---|
60 | void generateDepth32f();
|
---|
61 | void generateDepth8uFromDepth32f();
|
---|
62 |
|
---|
63 | // ***** dense representation *************
|
---|
64 | int width,height;
|
---|
65 | // disparity image (8bits unsigned char)
|
---|
66 | unsigned char *imDepth8u, *imDepth8u_origin;
|
---|
67 | // disparity image (32bits float)
|
---|
68 | float *imDepth32f, *imDepth32f_origin;
|
---|
69 |
|
---|
70 | // ***** sparse representation *************
|
---|
71 | // index of valid pixels in imDepth
|
---|
72 | int *valid_pixels;
|
---|
73 | short *x, *y;
|
---|
74 | float *depth_float_list;
|
---|
75 | unsigned int m_nGood3DPoints; // nb of valid pixels
|
---|
76 |
|
---|
77 | // undefined depth value: all undefined pixels in the disp. image will have this value
|
---|
78 | unsigned char UNDEFINED_DEPTH;
|
---|
79 |
|
---|
80 | private:
|
---|
81 | int *valid_pixels_origin;
|
---|
82 | short *x_origin, *y_origin;
|
---|
83 | float *depth_float_list_origin;
|
---|
84 | };
|
---|
85 |
|
---|
86 |
|
---|
87 | // ***********************************************************************
|
---|
88 | // ***********************************************************************
|
---|
89 | // ReconstPoints3D: structure representing a 3D Euclidean reconstruction
|
---|
90 | class ReconstPoints3D {
|
---|
91 | public:
|
---|
92 | ReconstPoints3D();
|
---|
93 | ~ReconstPoints3D();
|
---|
94 | void alloc(int N);
|
---|
95 | void FreeMemoryBuffers(void);
|
---|
96 |
|
---|
97 | // I/O functions to load/save a 3D reconstruction
|
---|
98 | int load(char* filename);
|
---|
99 | int save(char* filename);
|
---|
100 |
|
---|
101 | // return arrays containing 3-D reconstruction
|
---|
102 | float* getXlist() const;
|
---|
103 | float* getYlist() const;
|
---|
104 | float* getZlist() const;
|
---|
105 | unsigned char* getARGBlist() const; // color (ARGB) list
|
---|
106 | float* getPointSizelist() const; // size of the points
|
---|
107 |
|
---|
108 | // return num. of reconstructed points
|
---|
109 | int getNumPoints() const;
|
---|
110 |
|
---|
111 | // return 3 images containing X,Y and Z values
|
---|
112 | void getImages_3D(float* X_im, float* Y_im, float* Z_im, const int* valid_pixels);
|
---|
113 |
|
---|
114 | friend class Reconst3D;
|
---|
115 |
|
---|
116 | // ROI of thte scene
|
---|
117 | float m_fExtentMinX;
|
---|
118 | float m_fExtentMaxX;
|
---|
119 | float m_fExtentMinY;
|
---|
120 | float m_fExtentMaxY;
|
---|
121 | float m_fExtentMinZ;
|
---|
122 | float m_fExtentMaxZ;
|
---|
123 |
|
---|
124 | protected:
|
---|
125 | // 3D reconstruction
|
---|
126 | float *m_p3DPointsX;
|
---|
127 | float *m_p3DPointsY;
|
---|
128 | float *m_p3DPointsZ;
|
---|
129 | unsigned char *m_p3DPointsC; // list of RGBA values
|
---|
130 | float *m_p3DPointsS; // size of the 3D points
|
---|
131 | unsigned int m_nGood3DPoints; // number of points in the scene
|
---|
132 |
|
---|
133 | private:
|
---|
134 | // original data pointers
|
---|
135 | float *m_p3DPointsX_origin;
|
---|
136 | float *m_p3DPointsY_origin;
|
---|
137 | float *m_p3DPointsZ_origin;
|
---|
138 | };
|
---|
139 |
|
---|
140 | #endif |
---|