@@ -154,9 +154,9 @@ void FeaturesDev::reset( int num_ext, int num_ori )
154154 if ( _ori != nullptr ) { cudaFree ( _ori ); _ori = nullptr ; }
155155 if ( _rev != nullptr ) { cudaFree ( _rev ); _rev = nullptr ; }
156156
157- _ext = popsift::cuda::malloc_devT <Feature> ( num_ext, __FILE__, __LINE__ );
158- _ori = popsift::cuda::malloc_devT <Descriptor>( num_ori, __FILE__, __LINE__ );
159- _rev = popsift::cuda::malloc_devT <int > ( num_ori, __FILE__, __LINE__ );
157+ _ext = popsift::cuda::malloc_mgdT <Feature> ( num_ext, __FILE__, __LINE__ );
158+ _ori = popsift::cuda::malloc_mgdT <Descriptor>( num_ori, __FILE__, __LINE__ );
159+ _rev = popsift::cuda::malloc_mgdT <int > ( num_ori, __FILE__, __LINE__ );
160160
161161 setFeatureCount ( num_ext );
162162 setDescriptorCount ( num_ori );
@@ -248,18 +248,26 @@ show_distance( int3* match_matrix,
248248 if ( threadIdx .x == 0 )
249249 {
250250 if ( match_matrix[i].z )
251- printf ( " accept feat %4d [%4d] matches feat %4d [%4d] ( 2nd feat %4d [%4d] ) dist %.3f vs %.3f\n " ,
251+ {
252+ Feature* lx = &l_ext[l_fem[i]];
253+ Feature* rx = &r_ext[r_fem[match_matrix[i].x ]];
254+ printf ( " accept feat %4d [%4d] matches feat %4d [%4d] ( 2nd feat %4d [%4d] ) dist %.3f vs %.3f"
255+ " (%.1f,%.1f)-(%.1f,%.1f)\n " ,
252256 l_fem[i], i,
253257 r_fem[match_matrix[i].x ], match_matrix[i].x ,
254258 r_fem[match_matrix[i].y ], match_matrix[i].y ,
255- d1, d2 );
259+ d1, d2,
260+ lx->xpos , lx->ypos , rx->xpos , rx->ypos );
261+ }
256262 else
263+ {
257264 printf ( " reject feat %4d [%4d] matches feat %4d [%4d] ( 2nd feat %4d [%4d] ) dist %.3f vs %.3f\n " ,
258265 l_fem[i], i,
259266 r_fem[match_matrix[i].x ], match_matrix[i].x ,
260267 r_fem[match_matrix[i].y ], match_matrix[i].y ,
261268 d1, d2 );
262269 }
270+ }
263271 __syncthreads ();
264272 }
265273}
@@ -303,6 +311,54 @@ void FeaturesDev::match( FeaturesDev* other )
303311 cudaFree ( match_matrix );
304312}
305313
314+ int3 * FeaturesDev::matchAndReturn ( FeaturesDev* other )
315+ {
316+ int l_len = getDescriptorCount ( );
317+ int r_len = other->getDescriptorCount ( );
318+
319+ int3 * match_matrix = popsift::cuda::malloc_mgdT<int3 >( l_len, __FILE__, __LINE__ );
320+
321+ dim3 grid;
322+ grid.x = l_len;
323+ grid.y = 1 ;
324+ grid.z = 1 ;
325+ dim3 block;
326+ block.x = 32 ;
327+ block.y = 1 ;
328+ block.z = 1 ;
329+
330+ compute_distance
331+ <<<grid,block>>>
332+ ( match_matrix, getDescriptors (), l_len, other->getDescriptors (), r_len );
333+
334+ return match_matrix;
335+ }
336+
337+ void FeaturesDev::freeMatches ( int3 * match_matrix )
338+ {
339+ popsift::cuda::free_mgd ( match_matrix );
340+ }
341+
342+ Descriptor* FeaturesDev::getDescriptor ( int descIndex )
343+ {
344+ return &_ori[descIndex];
345+ }
346+
347+ const Descriptor* FeaturesDev::getDescriptor ( int descIndex ) const
348+ {
349+ return &_ori[descIndex];
350+ }
351+
352+ Feature* FeaturesDev::getFeatureForDescriptor ( int descIndex )
353+ {
354+ return &_ext[_rev[descIndex]];
355+ }
356+
357+ const Feature* FeaturesDev::getFeatureForDescriptor ( int descIndex ) const
358+ {
359+ return &_ext[_rev[descIndex]];
360+ }
361+
306362/* ************************************************************
307363 * Feature
308364 *************************************************************/
0 commit comments