GpuSurfFeatures.cppGo to the documentation of this file.00001 /* 00002 Copyright (c) 2010, Paul Furgale and Chi Hay Tong 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without 00006 modification, are permitted provided that the following conditions are 00007 met: 00008 00009 * Redistributions of source code must retain the above copyright notice, 00010 this list of conditions and the following disclaimer. 00011 * Redistributions in binary form must reproduce the above copyright 00012 notice, this list of conditions and the following disclaimer in the 00013 documentation and/or other materials provided with the distribution. 00014 * The names of its contributors may not be used to endorse or promote 00015 products derived from this software without specific prior written 00016 permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00019 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00020 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00021 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 00022 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00023 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00024 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00025 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00026 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00027 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 */ 00030 00031 #include "GpuSurfFeatures.hpp" 00032 #include "assert_macros.hpp" 00033 00034 #include <cuda.h> 00035 #include <cudpp.h> 00036 #include <builtin_types.h> 00037 #include <cuda_runtime_api.h> 00038 #include "gpu_globals.h" 00039 00040 namespace asrl { 00041 GpuSurfFeatures::GpuSurfFeatures() 00042 { 00043 m_descriptorsDirty = false; 00044 m_featuresDirty = false; 00045 m_countDirty = false; 00046 // Initialize a buffer for the feature points. 00047 m_features.init(ASRL_SURF_MAX_FEATURES); 00048 m_features.memset(0); 00049 m_descriptors.init(ASRL_SURF_MAX_FEATURES * ASRL_SURF_DESCRIPTOR_DIM); 00050 m_feature_counter.init(2,false); 00051 m_feature_counter.memset(0); 00052 m_rawFeatures.init(ASRL_SURF_MAX_CANDIDATES); 00053 } 00054 00055 GpuSurfFeatures::~GpuSurfFeatures() 00056 { 00057 00058 } 00059 00060 00061 Keypoint * GpuSurfFeatures::downloadFeatures() 00062 { 00063 if(m_featuresDirty) { 00064 00065 m_features.pullFromDevice(ftCount()); 00066 m_featuresDirty = false; 00067 } 00068 return m_features.h_get(); 00069 00070 } 00071 00072 00073 unsigned int GpuSurfFeatures::ftCount() 00074 { 00075 if(m_countDirty) 00076 { 00077 m_feature_counter.pullFromDevice(); 00078 m_countDirty = false; 00079 } 00080 00081 return m_feature_counter[0]; 00082 } 00083 00084 unsigned int GpuSurfFeatures::rawFeatureCount() 00085 { 00086 if(m_countDirty) 00087 { 00088 m_feature_counter.pullFromDevice(); 00089 m_countDirty = false; 00090 } 00091 00092 return m_feature_counter[1]; 00093 } 00094 00095 void GpuSurfFeatures::clearFeatureCounts() 00096 { 00097 m_feature_counter.memset(0); 00098 } 00099 00100 float * GpuSurfFeatures::downloadDescriptors() 00101 { 00102 if(m_descriptorsDirty) { 00103 m_descriptors.pullFromDevice(ftCount() * ASRL_SURF_DESCRIPTOR_DIM); 00104 m_descriptorsDirty = false; 00105 } 00106 00107 return m_descriptors.h_get(); 00108 } 00109 00110 void GpuSurfFeatures::setDirty() 00111 { 00112 m_descriptorsDirty = true; 00113 m_featuresDirty = true; 00114 m_countDirty = true; 00115 } 00116 00117 } // namespace asrl Generated on Fri Apr 30 20:06:19 2010 for gpusurf by 1.6.2 |