ObjectLearningByPushingDefinitions.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 // defines which camera is used
26 //#define OLP_USE_XB3
27 //#define OLP_USE_KAHEAD
28 //#define OLP_USE_DBVISION
29 #define OLP_USE_ARMAR3
30 //#define OLP_USE_ARMAR3_ARMAR3_4
31 
32 //// camera calibration file
33 //#if defined OLP_USE_XB3
34 // #define OLP_CAMERA_CALIBRATION_FILE "C:/Users/Lovov/My Documents/Visual Studio 2008/Projects/SiftFeaturePlaneFinder2/SiftFeaturePlaneFinder/cameras-David7.txt"
35 //#elif defined OLP_USE_KAHEAD
36 // //#define OLP_CAMERA_CALIBRATION_FILE "C:/img/Experiments with Armar/camera_armar3b_640x480_wide-exp8-10.txt"
37 // //#define OLP_CAMERA_CALIBRATION_FILE "C:/img/Experiments with Armar/camera_armar3b_640x480_wide-exp1-7.txt"
38 // #define OLP_CAMERA_CALIBRATION_FILE "C:/Users/Lovov/My Documents/Visual Studio 2008/Projects/SiftFeaturePlaneFinder2/SiftFeaturePlaneFinder/cameras-Head3.txt"
39 // //#define OLP_CAMERA_CALIBRATION_FILE "C:/Users/Lovov/My Documents/Visual Studio 2008/Projects/SiftFeaturePlaneFinder2/SiftFeaturePlaneFinder/cameras-Kyoto1.txt"
40 //#elif defined OLP_USE_DBVISION
41 // #define OLP_CAMERA_CALIBRATION_FILE "params/StereoParametersIVT.cf"
42 //#elif defined OLP_USE_ARMAR3_ARMAR3_4
43 // //#define OLP_CAMERA_CALIBRATION_FILE "/localhome/armar-user/armar-user_test3_mca2.4/david_mca2.4/armar3/robot_interface/files/camera_armar3a_640x480_wide.txt"
44 // #define OLP_CAMERA_CALIBRATION_FILE "/localhome/armar-user/armar-user_test3_mca2.4/armar3/robot_interface/files/camera_armar3a_640x480_wide.txt"
45 //#elif defined OLP_USE_ARMAR3
46 // #define OLP_CAMERA_CALIBRATION_FILE "/common/homes/staff/schieben/home/mca2.4/projects/armar3/robot_interface/files/camera_armar3a_640x480_wide.txt"
47 // //#define OLP_CAMERA_CALIBRATION_FILE "/home/staff/schieben/mca2.4-3b/projects/armar3b/robot_interface/files/camera_armar3b_640x480_wide.txt"
48 //#endif
49 
50 // defines image sizes
51 #if defined OLP_USE_XB3
52 #define OLP_IMG_WIDTH_CAM 1280
53 #define OLP_IMG_HEIGHT_CAM 960
54 #elif defined OLP_USE_KAHEAD
55 #define OLP_IMG_WIDTH_CAM 640
56 #define OLP_IMG_HEIGHT_CAM 480
57 #elif defined OLP_USE_DBVISION
58 #define OLP_IMG_WIDTH_CAM 640 // <- enter the resolution of the camera images here
59 #define OLP_IMG_HEIGHT_CAM 480
60 #elif defined OLP_USE_ARMAR3
61 #define OLP_IMG_WIDTH_CAM 640
62 #define OLP_IMG_HEIGHT_CAM 480
63 #else
64 #define OLP_IMG_WIDTH_CAM 640
65 #define OLP_IMG_HEIGHT_CAM 480
66 #endif
67 
68 #define OLP_IMG_WIDTH 640
69 #define OLP_IMG_HEIGHT 480
70 
71 
72 // define if a human executes the pushing
73 //#define OLP_HUMAN_PUSHES
74 // defines which robot is used for pushing
75 //#define OLP_USE_KUKA_ARMS
76 //#define OLP_USE_ATR_ROBOT
77 
78 // operating system
79 //#define WIN32
80 #define LINUX
81 
82 // influences the computational effort, e.g. the number of iterations of RANSAC
83 #if defined _DEBUG
84 #define OLP_EFFORT_MODIFICATOR 0.5f
85 #else
86 #define OLP_EFFORT_MODIFICATOR 1.0f
87 #endif
88 
89 
90 // modifies the tolerance for points lying on planes and cylinders, can be reduced
91 // for good or increased for bad stereo calibrations
92 #if defined OLP_USE_XB3
93 #define OLP_TOLERANCE_MODIFICATOR 0.9f
94 #elif defined OLP_USE_KAHEAD
95 #define OLP_TOLERANCE_MODIFICATOR 1.5f
96 #elif defined OLP_USE_DBVISION
97 #define OLP_TOLERANCE_MODIFICATOR 1.5f
98 #elif defined OLP_USE_ARMAR3
99 #define OLP_TOLERANCE_MODIFICATOR 1.5f
100 #else
101 #define OLP_TOLERANCE_MODIFICATOR 1.0f
102 #endif
103 
104 
105 // the maximal allowed distance of an object from the camera, in mm
106 #define OLP_MAX_OBJECT_DISTANCE 1500.0f // 1200
107 
108 // minimal number of feature points for a hypothesis
109 #define OLP_MIN_NUM_FEATURES 30 // 25
110 
111 // maximal number of initial hypotheses that will be generated
112 #define OLP_MAX_NUM_HYPOTHESES 80 // 120
113 
114 // influences how many clusters are created when applying x-means to the generated initial hypotheses
115 // a bigger factor leads to more clusters
116 #define OLP_CLUSTERING_FACTOR_PLANES 2.5f
117 // maximal number of parts into which the object may be divided by clustering
118 #define OLP_MAX_NUM_CLUSTERING_PARTS 6 // 6
119 
120 
121 // number of parallel threads if OpenMP is used. If undefined, the number of threads will be set to the number of CPUs
122 #ifdef OLP_USE_ARMAR3_ARMAR3_4
123 #define OMP_NUM_THREADS 2
124 #else
125 //#define OMP_NUM_THREADS 1
126 #endif
127 
128 
129 // decide if classes of known objects will be loaded
130 //#define OLP_LOAD_KNOWN_OBJECTS false
131 
132 
133 // decide if a new visual vocabulary will be learned (may take around 1 hour!)
134 //#define OLP_LEARN_NEW_VISUAL_VOCABULARY false
135 
136 // for the point/komma problem
137 #define OLP_KOMMA
138 
139 // directories and files for object recognition
140 #if defined OLP_USE_ARMAR3_ARMAR3_4
141 #define OLP_OBJECT_LEARNING_DIR "/localhome/armar-user/armar-user_test3_mca2.4/david_mca2.4/OLP/data/"
142 #define OLP_HISTOGRAM_DIR "/localhome/armar-user/armar-user_test3_mca2.4/david_mca2.4/OLP/data/Histograms-punkt/"
143 #define OLP_OBJECT_NAMES_FILE "/localhome/armar-user/armar-user_test3_mca2.4/david_mca2.4/OLP/data/Histograms-punkt/ObjectNames.txt"
144 #define OLP_VOCABULARY_FILE "/localhome/armar-user/armar-user_test3_mca2.4/david_mca2.4/OLP/data/VisualVocabulary1000d.txt"
145 #define OLP_ADDITIONAL_OBJECT_IMAGES_DIR "/localhome/armar-user/armar-user_test3_mca2.4/david_mca2.4/OLP/data/objects/"
146 #define OLP_NEW_VOCABULARY_FILE "/localhome/armar-user/armar-user_test3_mca2.4/david_mca2.4/OLP/data/VisualVocabulary1000e.txt"
147 #define OLP_NEW_VOCABULARY_TRAINING_IMAGES "/localhome/armar-user/armar-user_test3_mca2.4/david_mca2.4/OLP/data/objects/MoreObjects000.bmp"
148 #elif defined OLP_USE_ARMAR3
149 #ifdef OLP_KOMMA
150 //#define OLP_HISTOGRAM_DIR "/common/homes/staff/schieben/home/OLP/data/Histograms-komma/"
151 //#define OLP_OBJECT_NAMES_FILE "/common/homes/staff/schieben/home/OLP/data/Histograms-komma/ObjectNames.txt"
152 //#define OLP_VOCABULARY_FILE "/common/homes/staff/schieben/home/OLP/data/VisualVocabulary1000d-komma.txt"
153 //#define OLP_VOCABULARY_FILE "/home/mobiletamer/OLP/data/VisualVocabulary1000d-komma.txt"
154 #else
155 #define OLP_HISTOGRAM_DIR "/common/homes/staff/schieben/home/OLP/data/Histograms-punkt/"
156 #define OLP_OBJECT_NAMES_FILE "/common/homes/staff/schieben/home/OLP/data/Histograms-punkt/ObjectNames.txt"
157 #define OLP_VOCABULARY_FILE "/common/homes/staff/schieben/home/OLP/data/VisualVocabulary1000d-punkt.txt"
158 //#define OLP_VOCABULARY_FILE "/home/mobiletamer/OLP/data/VisualVocabulary1000d.txt"
159 #endif
160 //#define OLP_OBJECT_LEARNING_DIR "/home/staff/schieben/OLP/data/LearnedObjects/"
161 // #define OLP_OBJECT_LEARNING_DIR "/common/homes/staff/schieben/home/datalog/LearnedObjects/temp/"
162 #define OLP_OBJECT_LEARNING_DIR "/common/homes/students/haas/OLP/temp/"
163 
164 //#define OLP_ADDITIONAL_OBJECT_IMAGES_DIR "/common/homes/staff/schieben/home/OLP/data/objects/"
165 //#define OLP_NEW_VOCABULARY_FILE "/common/homes/staff/schieben/home/OLP/data/VisualVocabulary1000e.txt"
166 //#define OLP_NEW_VOCABULARY_TRAINING_IMAGES "/common/homes/staff/schieben/home/OLP/data/objects/MoreObjects000.bmp"
167 #elif defined OLP_USE_DBVISION
168 #define OLP_OBJECT_LEARNING_DIR "params/ObjectLearning/"
169 #define OLP_HISTOGRAM_DIR "params/ObjectLearning/HistogramsE/"
170 #define OLP_OBJECT_NAMES_FILE "params/ObjectLearning/HistogramsE/ObjectNames.txt"
171 #define OLP_VOCABULARY_FILE "params/ObjectLearning/VisualVocabulary1000d.txt"
172 #define OLP_ADDITIONAL_OBJECT_IMAGES_DIR "params/ObjectLearning/objects/"
173 #define OLP_NEW_VOCABULARY_FILE "params/ObjectLearning/objects/VisualVocabulary1000e.txt"
174 #define OLP_NEW_VOCABULARY_TRAINING_IMAGES "params/ObjectLearning/objects/MoreObjects000.bmp" // <- names have to end on 000, 001, 002 etc.
175 #else
176 #define OLP_OBJECT_LEARNING_DIR "c:/img/"
177 #define OLP_HISTOGRAM_DIR "c:/img/HistogramsE/"
178 #define OLP_OBJECT_NAMES_FILE "c:/img/HistogramsE/ObjectNames.txt"
179 #define OLP_VOCABULARY_FILE "c:/img/VisualVocabulary1000d.txt"
180 #define OLP_ADDITIONAL_OBJECT_IMAGES_DIR "c:/img/objects/"
181 #define OLP_NEW_VOCABULARY_FILE "c:/img/VisualVocabulary1000e.txt"
182 #define OLP_NEW_VOCABULARY_TRAINING_IMAGES "c:/img/objects/MoreObjects000.bmp" // <- names have to end on 000, 001, 002 etc.
183 #endif
184 //#define OLP_NEW_VOCABULARY_NUMBER_OF_TRAINING_IMAGES 20
185 
186 
187 // define if images should be shown in OpenCV windows
188 #ifndef OLP_USE_ARMAR3_ARMAR3_4
189 #define OLP_SHOW_RESULT_IMAGES
190 #endif
191 // waiting time for the visualization (in ms)
192 #define OLP_WAITING_TIME_VISUALISATION 400
193 
194 // screenshots
195 #ifdef OLP_USE_ARMAR3_ARMAR3_4
196 #define OLP_MAKE_RESULT_SCREENSHOTS false
197 #define OLP_MAKE_INTERMEDIATE_SCREENSHOTS false
198 #define OLP_SAVE_COMPLETE_POINTCLOUD false
199 #define OLP_SAVE_CONFIRMED_OBJECT false
200 #else
201 #define OLP_MAKE_RESULT_SCREENSHOTS true
202 #define OLP_MAKE_INTERMEDIATE_SCREENSHOTS true
203 #define OLP_SAVE_COMPLETE_POINTCLOUD true
204 #define OLP_SAVE_CONFIRMED_OBJECT true
205 #endif
206 #define OLP_SCREENSHOT_PATH OLP_OBJECT_LEARNING_DIR
207 //#define OLP_SCREENSHOT_PATH "/homes/staff/schieben/datalog/YCB/Head/temp/"
208 
209 
210 // scaling factor for the image before being fouriertransformed
211 #define OLP_FOURIER_TRANSFORM_SCALING_FACTOR 0.5
212 
213 
214 
215 // size of the MSER color histogram
216 #define OLP_SIZE_MSER_HISTOGRAM 64
217 // number of SIFT descriptors per point
218 //#define OLP_NUM_DESCRIPTORS_PER_POINT 9
219 // size of the hue histogram for object recognition
220 #define OLP_SIZE_OBJECT_HUE_HISTOGRAM 64
221 
222 
223 // tolerance for the validation if a point moved concurrently (in mm)
224 #define OLP_TOLERANCE_CONCURRENT_MOTION 80.0f // 70
225 // minimal necessary motion for a hypothesis to be validated (in mm)
226 #define OLP_MINIMAL_MOTION_MEASURE 30.0f // 50
227 // when using RGBD: maximal distance (in px) from next confirmed point for being added as a new candidate (if point is also in changed image area)
228 #define OLP_MAX_DISTANCE_FOR_ADDING_FOREGROUND_CANDIDATE_2D 40
229 // when using RGBD: maximal distance (in mm) from next confirmed point for being added as a new candidate (if point is also in changed image area)
230 #define OLP_MAX_DISTANCE_FOR_ADDING_FOREGROUND_CANDIDATE_3D 70
231 // generate a segmentation image region from the confirmed points, and add all scene points in that region to the confirmed points
232 #define OLP_ADD_POINTS_FROM_SEGMENTED_REGION
233 // threshold to decide whether a pixel changed or not
234 #define OLP_FOREGROUND_THRESHOLD 50 //50
235 
236 
237 // for color ICP: weight of the color distance to the cartesian distance (maximal color distance = x mm)
238 #define OLP_ICP_COLOR_DISTANCE_WEIGHT 40.0f
239 // for color ICP: point correspondences with a bigger distance than this will not be used
240 #define OLP_ICP_CUTOFF_DISTANCE 3*OLP_TOLERANCE_CONCURRENT_MOTION // FLT_MAX
241 
242 
243 
244 // set minimal distance between Harris Interest Points that will be detected (in pixels)
245 #define OLP_HARRIS_POINT_DISTANCE 3.0f
246 // set minimal relative saliency of Harris Interest Points (smaller -> more points)
247 #define OLP_HARRIS_POINT_QUALITY 0.0001f // 0.001
248 
249 // define to calculate and use MSERs
250 #define OLP_USE_MSERS
251 
252 
253 // define to use points from the depth map
254 #define OLP_USE_DEPTH_MAP
255 // distance between depth map pixels that will be used
256 #define OLP_DEPTH_MAP_PIXEL_DISTANCE 3 // 3
257 // effort for relocalizing a hypothesis after pushing
258 #ifdef OLP_USE_ARMAR3_ARMAR3_4
259 #define OLP_EFFORT_POINTCLOUD_MATCHING 1
260 #else
261 #define OLP_EFFORT_POINTCLOUD_MATCHING 3 // 3
262 #endif
263 // factor for clustering the changed points after the first push to create foreground hypotheses (bigger->more hypotheses)
264 #define OLP_CLUSTERING_FACTOR_FOREGROUND_HYPOTHESES 10.0f
265 // clustering of promising regions for object re-localization (bigger->more promising positions will be tested)
266 #define OLP_CLUSTERING_FACTOR_OBJECT_LOCALIZATION 2.5f // 1.5
267 
268 #ifdef OLP_USE_DEPTH_MAP
269 // create hypotheses from large color MSERs
270 #define OLP_FIND_UNICOLORED_HYPOTHESES // <--
271 // minimal size for an MSER to be used for creating a hypothesis (in pixels)
272 #define OLP_MSER_HYPOTHESIS_MIN_SIZE 225
273 // maximal size for an MSER to be used for creating a hypothesis (in pixels)
274 #define OLP_MSER_HYPOTHESIS_MAX_SIZE (OLP_IMG_WIDTH*OLP_IMG_HEIGHT/100)
275 // create planar hypotheses
276 #define OLP_FIND_PLANES // <--
277 // create cylindrical hypotheses
278 //#define OLP_FIND_CYLINDERS
279 // create spherical hypotheses
280 //#define OLP_FIND_SPHERES
281 // create hypotheses from clusters of points that just lie close to each other, but not on a plane/cylinder/sphere
282 //#define OLP_FIND_IRREGULAR_CLUSTERS
283 // generate hypotheses from not-yet-covered salient regions
284 #define OLP_FIND_SALIENCY_HYPOTHESES // <--
285 // use the LCCP segmentation to generate hypotheses
286 //#define OLP_USE_LCCP
287 #define OLP_MIN_SIZE_LCCP_SEGMENT OLP_MIN_NUM_FEATURES
288 #define OLP_MAX_SIZE_LCCP_SEGMENT (OLP_IMG_WIDTH*OLP_IMG_HEIGHT/100)
289 //#define OLP_MAKE_LCCP_SEG_IMAGES
290 #else
291 // create planar hypotheses
292 //#define OLP_FIND_PLANES
293 // create cylindrical hypotheses
294 //#define OLP_FIND_CYLINDERS
295 // create spherical hypotheses
296 //#define OLP_FIND_SPHERES
297 // create hypotheses from clusters of points that just lie close to each other, but not on a plane/cylinder/sphere
298 //#define OLP_FIND_IRREGULAR_CLUSTERS
299 #endif
300 
301 
302 // define this to keep only those initial hypotheses that are local maxima (with relation to their height)
303 #ifdef OLP_USE_DEPTH_MAP
304 #define OLP_FILTER_INITIAL_HYPOTHESES_WITH_MAXIMUMNESS
305 #endif
306 
307 // no SIFT points with x coordinate in image smaller than this value will be used, so that the
308 // resulting hypotheses can get a correct maximumness rating
309 #ifdef OLP_FILTER_INITIAL_HYPOTHESES_WITH_MAXIMUMNESS
310 #define OLP_MIN_X_VALUE_SIFT_POINTS 120
311 #else
312 #define OLP_MIN_X_VALUE_SIFT_POINTS 0
313 #endif
314 
315 
316 // a central position in front of the robot. The hypothesis closest to this position is chosen for pushing,
317 // and the object is always pushed towards this point
318 #define OLP_CENTRAL_POSITION_FOR_PUSHING_X 0
319 #define OLP_CENTRAL_POSITION_FOR_PUSHING_Y 500
320 #define OLP_CENTRAL_POSITION_FOR_PUSHING_Z 1100
321 
322 
323 // define if using OpenCV version >= 2.3
324 #define OLP_USE_NEW_OPENCV
325