Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions include/SlicCudaHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class SlicCuda {

// gpu variable
float* d_fClusters;
float* d_fLabels;
float* d_fAccAtt;

//cudaArray
Expand Down Expand Up @@ -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; i<m_nbPx; i++ ){
if( int(h_fLabels[i])>maxId ){
maxId = int(h_fLabels[i]);
}
}

return maxId + 1;
}
/*
Discard orphan clusters (optional)
*/
Expand Down
5 changes: 4 additions & 1 deletion src/SlicCudaHost.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}
}