00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00035 #pragma once
00036 #ifndef BUT_PLANE_DET_PARAMSPACEH_H
00037 #define BUT_PLANE_DET_PARAMSPACEH_H
00038
00039
00040 #include <opencv2/highgui/highgui.hpp>
00041 #include <opencv2/imgproc/imgproc_c.h>
00042
00043
00044 #include <sensor_msgs/CameraInfo.h>
00045
00046
00047 #include <srs_env_model_percp/but_plane_detector/parameter_space.h>
00048 #include <srs_env_model_percp/but_segmentation/normals.h>
00049
00050
00051 namespace srs_env_model_percp
00052 {
00053
00054 #define DEFAULT_ANGLE_STEP 5
00055 #define DEFAULT_SHIFT_STEP 5
00056 #define DEFAULT_BIN_SIZE 16
00057 #define DEFAULT_BIN_SIZE3 DEFAULT_BIN_SIZE*DEFAULT_BIN_SIZE*DEFAULT_BIN_SIZE
00058
00062 class IndexStruct
00063 {
00064 public:
00068 int lowResolutionIndex;
00069
00073 int highResolutionIndex;
00074 };
00075
00080 class ParameterSpaceHierarchy
00081 {
00082 public:
00083 typedef but_plane_detector::Plane<float> tPlane;
00084 typedef std::vector<tPlane, Eigen::aligned_allocator<tPlane> > tPlanes;
00085
00086
00087 public:
00097 ParameterSpaceHierarchy(double anglemin, double anglemax, double zmin, double zmax, double angleRes = DEFAULT_ANGLE_STEP, double shiftRes = DEFAULT_SHIFT_STEP);
00098
00102 ~ParameterSpaceHierarchy();
00103
00109 int findMaxima(tPlanes &indices, double min_value, int neighborhood, int around);
00110
00118 void addVolume(ParameterSpace &second, int angle1, int angle2, int shift);
00119
00128 void addVolume(ParameterSpace &second, int angle1, int angle2, int shift, float factor);
00129
00134 double getAngle(int index);
00135
00140 double getShift(int irndex);
00141
00148 double get(int angle1, int angle2, int z);
00149
00154 double get(int bin_index, int inside_index);
00155
00162 double get(double angle1, double angle2, double z);
00163
00171 void set(int angle1, int angle2, int z, double val);
00172
00178 void set(int bin_index, int inside_index, double val);
00179
00187 void set(double angle1, double angle2, double z, double val);
00188
00192 int getSize();
00193
00200 IndexStruct getIndex(double angle1, double angle2, double z);
00201
00208 IndexStruct getIndex(int angle1, int angle2, int z);
00209
00219 void getIndex(double angle1, double angle2, double z, int &angle1Index, int &angle2Index, int &shiftIndex);
00220
00228 void fromIndex(int bin_index, int inside_index, int& angle1, int& angle2, int& z);
00229
00238 static void toAngles(float x, float y, float z, float &a1, float &a2);
00239
00248 static void toEuklid(float a1, float a2, float &x, float &y, float &z);
00249
00250 void clear();
00254 bool m_init;
00255
00259 double m_angleStep;
00260
00264 double m_shiftStep;
00265
00269 double m_angleLoStep;
00270
00274 double m_shiftLoStep;
00275
00279 double m_shiftmin;
00280
00284 double m_shiftmax;
00285
00289 double m_anglemin;
00290
00294 double m_anglemax;
00295
00299 int m_size;
00300
00304 int m_loSize;
00305
00309 int m_angleSize;
00310
00314 int m_angleSize2;
00315
00319 int m_shiftSize;
00320
00324 int m_angleLoSize;
00325
00329 int m_angleLoSize2;
00330
00334 int m_shiftLoSize;
00335
00339 int m_hiSize;
00340
00344 int m_hiSize2;
00345
00349 cv::Mat m_paramSpace;
00350
00354 double **m_dataLowRes;
00355 };
00356
00360 class ParameterSpaceHierarchyFullIterator
00361 {
00362 public:
00366 ParameterSpaceHierarchyFullIterator(ParameterSpaceHierarchy *space)
00367 {
00368 index = space->m_angleSize*space->m_angleSize*space->m_shiftSize;
00369
00370 bin_index = 0;
00371 inside_index = 0;
00372
00373 end = false;
00374 m_space = space;
00375 max_size = space->m_loSize;
00376 }
00377
00381 double getVal()
00382 {
00383 return m_space->get(bin_index, inside_index);
00384 }
00385
00390 void setVal(double val)
00391 {
00392 m_space->set(bin_index, inside_index, val);
00393 }
00394
00398 ParameterSpaceHierarchyFullIterator &operator ++()
00399 {
00400 if (m_space->m_dataLowRes[bin_index] == NULL)
00401 {
00402 inside_index = 0;
00403 ++bin_index;
00404 }
00405 else
00406 {
00407 ++inside_index;
00408 if (inside_index >= DEFAULT_BIN_SIZE3)
00409 {
00410 inside_index = 0;
00411 ++bin_index;
00412 }
00413 }
00414
00415 if (bin_index>=max_size) end = true;
00416 return *this;
00417 }
00418
00422 int bin_index;
00423
00427 int inside_index;
00428
00432 bool end;
00433 private:
00434
00438 int index;
00439
00443 int max_size;
00444
00448 ParameterSpaceHierarchy *m_space;
00449 };
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525 }
00526
00527 #endif