diff --git a/CMakeLists.txt b/CMakeLists.txt index d5d446b..693847c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,9 +18,6 @@ message(STATUS "Found OpenCV >=3.0 at '${OpenCV_DIR}'") ### CUDA CHECK find_package(CUDA REQUIRED) -set(CUDA_COMPUTE_CAPABILITY "20") -set(CUDA_GENERATE_CODE "arch=compute_${CUDA_COMPUTE_CAPABILITY},code=sm_${CUDA_COMPUTE_CAPABILITY}" CACHE STRING "Which GPU architectures to generate code for (each arch/code pair will be passed as --generate-code option to nvcc, separate multiple pairs by ;)") -set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -arch compute_${CUDA_COMPUTE_CAPABILITY}) ### Compilation diff --git a/include/SlicCudaHost.h b/include/SlicCudaHost.h index e938729..585f8e3 100644 --- a/include/SlicCudaHost.h +++ b/include/SlicCudaHost.h @@ -45,7 +45,6 @@ class SlicCuda { // gpu variable float* d_fClusters; - float* d_fLabels; float* d_fAccAtt; //cudaArray @@ -95,7 +94,16 @@ class SlicCuda { */ void segment(const cv::Mat& frame); cv::Mat getLabels(){ return cv::Mat(m_FrameHeight, m_FrameWidth, CV_32F, h_fLabels); } - + int getLabelsNumber(){ + int maxId = 0; + for( int i=0; imaxId ){ + maxId = int(h_fLabels[i]); + } + } + + return maxId + 1; + } /* Discard orphan clusters (optional) */ diff --git a/src/SlicCudaHost.cu b/src/SlicCudaHost.cu index 027cd4d..3ec0748 100644 --- a/src/SlicCudaHost.cu +++ b/src/SlicCudaHost.cu @@ -22,6 +22,9 @@ SlicCuda::~SlicCuda(){ delete[] h_fLabels; gpuErrchk(cudaFree(d_fClusters)); gpuErrchk(cudaFree(d_fAccAtt)); + gpuErrchk(cudaDestroyTextureObject(oTexFrameBGRA)); + gpuErrchk(cudaDestroySurfaceObject(oSurfFrameLab)); + gpuErrchk(cudaDestroySurfaceObject(oSurfLabels)); gpuErrchk(cudaFreeArray(cuArrayFrameBGRA)); gpuErrchk(cudaFreeArray(cuArrayFrameLab)); gpuErrchk(cudaFreeArray(cuArrayLabels)); @@ -320,4 +323,4 @@ static void getSpxSizeFromDiam(const int imWidth, const int imHeight, const int } *spxWidth = ((diamSpx - wl2) < (wl1 - diamSpx)) ? wl2 : wl1; *spxHeight = ((diamSpx - hl2) < (hl1 - diamSpx)) ? hl2 : hl1; -} \ No newline at end of file +}