Structs.h
Go to the documentation of this file.
00001 // ****************************************************************************
00002 // This file is part of the Integrating Vision Toolkit (IVT).
00003 //
00004 // The IVT is maintained by the Karlsruhe Institute of Technology (KIT)
00005 // (www.kit.edu) in cooperation with the company Keyetech (www.keyetech.de).
00006 //
00007 // Copyright (C) 2014 Karlsruhe Institute of Technology (KIT).
00008 // All rights reserved.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are met:
00012 //
00013 // 1. Redistributions of source code must retain the above copyright
00014 //    notice, this list of conditions and the following disclaimer.
00015 //
00016 // 2. Redistributions in binary form must reproduce the above copyright
00017 //    notice, this list of conditions and the following disclaimer in the
00018 //    documentation and/or other materials provided with the distribution.
00019 //
00020 // 3. Neither the name of the KIT nor the names of its contributors may be
00021 //    used to endorse or promote products derived from this software
00022 //    without specific prior written permission.
00023 //
00024 // THIS SOFTWARE IS PROVIDED BY THE KIT AND CONTRIBUTORS “AS IS” AND ANY
00025 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00026 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00027 // DISCLAIMED. IN NO EVENT SHALL THE KIT OR CONTRIBUTORS BE LIABLE FOR ANY
00028 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00029 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00031 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00032 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00033 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034 // ****************************************************************************
00035 // ****************************************************************************
00036 // Filename:  Structs.h
00037 // Author:    Pedram Azad
00038 // Date:      2004
00039 // ****************************************************************************
00040 
00041 
00042 #ifndef __STRUCTS_H__
00043 #define __STRUCTS_H__
00044 
00045 
00046 // ****************************************************************************
00047 // Necessary includes
00048 // ****************************************************************************
00049 
00050 // IVT
00051 #include "Math/Math2d.h"
00052 #include "Math/Math3d.h"
00053 #include "DataStructures/DynamicArrayTemplate.h"
00054 
00055 // system
00056 #include <string.h>
00057 #include <math.h>
00058 #include <vector>
00059 
00060 
00061 
00062 // ****************************************************************************
00063 // Structs
00064 // ****************************************************************************
00065 
00066 struct ROI
00067 {
00068         int min_x, min_y, max_x, max_y;
00069 };
00070 
00071 struct PointPair2d
00072 {
00073         Vec2d p1;
00074         Vec2d p2;
00075 };
00076 
00077 struct PointPair3d
00078 {
00079         Vec3d p1;
00080         Vec3d p2;
00081 };
00082 
00089 struct Rectangle2d
00090 {
00094         Vec2d center;
00095 
00099         float width;
00100         
00104         float height;
00105 
00109         float angle;
00110 };
00111 
00118 struct Circle2d
00119 {
00123         Vec2d center;
00124         
00128         float radius;
00129 };
00130 
00137 struct Ellipse2d
00138 {
00142         Vec2d center;
00143         
00147         float radius_x;
00148         
00152         float radius_y;
00153         
00161         float angle;
00162 };
00163 
00179 struct StraightLine2d
00180 {
00181         StraightLine2d()
00182         {
00183                 Math2d::SetVec(point, Math2d::zero_vec);
00184                 Math2d::SetVec(directionVector, Math2d::zero_vec);
00185                 Math2d::SetVec(normalVector, Math2d::zero_vec);
00186                 c = 0.0f;
00187         }
00188 
00189         StraightLine2d(const Vec2d &point1, const Vec2d &point2)
00190         {
00191                 // choose first point as reference point
00192                 Math2d::SetVec(point, point1);
00193 
00194                 // compute direction vector
00195                 Math2d::SubtractVecVec(point2, point1, directionVector);
00196 
00197                 // normalize direction vector
00198                 Math2d::NormalizeVec(directionVector);
00199 
00200                 // compute normal vector (will be normalized, since u is normalized)
00201                 Math2d::SetVec(normalVector, -directionVector.y, directionVector.x);
00202 
00203                 // compute - n * a
00204                 c = -Math2d::ScalarProduct(normalVector, point);
00205         }
00206 
00207         StraightLine2d(float angle, float c)
00208         {
00209                 // set c
00210                 this->c = c;
00211 
00212                 // compute normal vector (will be normalized, since sin^2 + cos^2 = 1
00213                 Math2d::SetVec(normalVector, cosf(angle), sinf(angle));
00214 
00215                 // compute direction vector (will be normalized, since n is normalized)
00216                 Math2d::SetVec(directionVector, -normalVector.y, normalVector.x);
00217 
00218                 // compute an arbitrary point belonging to the straight line
00219                 if (fabsf(normalVector.x) > fabsf(normalVector.y))
00220                 {
00221                         Math2d::SetVec(point, -c / normalVector.x, 0.0f);
00222                 }
00223                 else
00224                 {
00225                         Math2d::SetVec(point, 0.0f, -c / normalVector.y);
00226                 }
00227         }
00228 
00229         StraightLine2d(const PointPair2d &pointPair)
00230         {
00231                 StraightLine2d(pointPair.p1, pointPair.p2);
00232         }
00233 
00237         Vec2d point;
00238 
00242         Vec2d directionVector;
00243 
00247         Vec2d normalVector;
00248         
00252         float c;
00253 };
00254 
00255 struct MyRegion
00256 {
00257         // constructor
00258         MyRegion()
00259         {
00260                 pPixels = 0;
00261         }
00262 
00263         // copy constructor
00264         MyRegion(const MyRegion &region)
00265         {
00266                 nPixels = region.nPixels;
00267 
00268                 if (region.pPixels)
00269                 {
00270                         pPixels = new int[nPixels];
00271                         memcpy(pPixels, region.pPixels, nPixels * sizeof(int));
00272                 }
00273                 else
00274                         pPixels = 0;
00275 
00276                 nSeedOffset = region.nSeedOffset;
00277 
00278                 Math2d::SetVec(centroid, region.centroid);
00279 
00280                 min_x = region.min_x;
00281                 min_y = region.min_y;
00282                 max_x = region.max_x;
00283                 max_y = region.max_y;
00284 
00285                 ratio = region.ratio;
00286         }
00287         
00288         // destructor
00289         ~MyRegion()
00290         {
00291                 if (pPixels)
00292                         delete [] pPixels;
00293         }
00294 
00295         // assign operator
00296         MyRegion& operator= (const MyRegion &region)
00297         {
00298                 nPixels = region.nPixels;
00299 
00300                 if (pPixels)
00301                         delete [] pPixels;
00302 
00303                 if (region.pPixels)
00304                 {
00305                         pPixels = new int[nPixels];
00306                         memcpy(pPixels, region.pPixels, nPixels * sizeof(int));
00307                 }
00308                 else
00309                         pPixels = 0;
00310 
00311                 nSeedOffset = region.nSeedOffset;
00312 
00313                 Math2d::SetVec(centroid, region.centroid);
00314 
00315                 min_x = region.min_x;
00316                 min_y = region.min_y;
00317                 max_x = region.max_x;
00318                 max_y = region.max_y;
00319 
00320                 ratio = region.ratio;
00321 
00322                 return *this;
00323         }
00324         
00325         // attributes
00326         int *pPixels;
00327         int nPixels;
00328 
00329         int nSeedOffset;
00330         
00331         Vec2d centroid;
00332         
00333         int min_x;
00334         int min_y;
00335         int max_x;
00336         int max_y;
00337         
00338         float ratio;
00339 };
00340 
00341 
00342 // ****************************************************************************
00343 // Typedefs
00344 // ****************************************************************************
00345 
00346 typedef std::vector<MyRegion> RegionList;
00347 typedef CDynamicArrayTemplate<MyRegion> CRegionArray;
00348 typedef CDynamicArrayTemplate<Circle2d> CCircle2dArray;
00349 typedef CDynamicArrayTemplate<Ellipse2d> CEllipse2dArray;
00350 typedef CDynamicArrayTemplate<StraightLine2d> CStraightLine2dArray;
00351 typedef CDynamicArrayTemplate<int> CIntArray;
00352 
00353 
00354 
00355 #endif /* __STRUCTS_H__ */


asr_ivt
Author(s): Allgeyer Tobias, Hutmacher Robin, Kleinert Daniel, Meißner Pascal, Scholz Jonas, Stöckle Patrick
autogenerated on Thu Jun 6 2019 21:46:58