diff --git a/openbr/plugins/cuda/copyto.cpp b/openbr/plugins/cuda/copyto.cpp index 86b4800..cc63e58 100644 --- a/openbr/plugins/cuda/copyto.cpp +++ b/openbr/plugins/cuda/copyto.cpp @@ -26,9 +26,6 @@ private: const Mat& srcMat = src.m(); const int rows = srcMat.rows; const int cols = srcMat.cols; -std::cout << "CopyTo" << std::endl; - std::cout << "rows: " << rows << std::endl; - std::cout << "cols: " << cols << std::endl; // output will be a single pointer to graphics card memory Mat dstMat = Mat(4, 1, DataType::type); diff --git a/openbr/plugins/cuda/cudadefines.hpp b/openbr/plugins/cuda/cudadefines.hpp index 0930077..a5981e4 100644 --- a/openbr/plugins/cuda/cudadefines.hpp +++ b/openbr/plugins/cuda/cudadefines.hpp @@ -16,7 +16,7 @@ using namespace std; cout << pthread_self() << ": CUDA Malloc Error(" << *errPtr << "): " << cudaGetErrorString(*errPtr) << endl; \ throw 0; \ } \ - cout << pthread_self() << ": CUDA Malloc: " << (void*)*(int**)cudaPtrPtr << endl; + //cout << pthread_self() << ": CUDA Malloc: " << (void*)*(int**)cudaPtrPtr << endl; #define CUDA_SAFE_MEMCPY(dstPtr, srcPtr, count, kind, errPtr) \ *errPtr = cudaMemcpy(dstPtr, srcPtr, count, kind); \ diff --git a/openbr/plugins/cuda/cudacvt.cpp b/openbr/plugins/cuda/cudargb2grayscale.cpp index 1f3297d..6f72728 100644 --- a/openbr/plugins/cuda/cudacvt.cpp +++ b/openbr/plugins/cuda/cudargb2grayscale.cpp @@ -26,7 +26,7 @@ using namespace cv; namespace br { namespace cuda{ - void cudacvt_wrapper(void* srcPtr, void**dstPtr, int rows, int cols); + void cudargb2grayscale_wrapper(void* srcPtr, void**dstPtr, int rows, int cols); }} namespace br @@ -37,38 +37,19 @@ namespace br * \brief Colorspace conversion. * \author Li Li \cite Josh Klontz \cite jklontz */ -class CUDACvtTransform : public UntrainableTransform +class CUDARGB2GrayScaleTransform : public UntrainableTransform { Q_OBJECT - Q_ENUMS(ColorSpace) - Q_PROPERTY(ColorSpace colorSpace READ get_colorSpace WRITE set_colorSpace RESET reset_colorSpace STORED false) - Q_PROPERTY(int channel READ get_channel WRITE set_channel RESET reset_channel STORED false) public: - enum ColorSpace { Gray = CV_BGR2GRAY, - RGBGray = CV_RGB2GRAY, - HLS = CV_BGR2HLS, - HSV = CV_BGR2HSV, - Lab = CV_BGR2Lab, - Luv = CV_BGR2Luv, - RGB = CV_BGR2RGB, - XYZ = CV_BGR2XYZ, - YCrCb = CV_BGR2YCrCb, - Color = CV_GRAY2BGR }; private: - BR_PROPERTY(ColorSpace, colorSpace, Gray) - BR_PROPERTY(int, channel, -1) - void project(const Template &src, Template &dst) const { void* const* srcDataPtr = src.m().ptr(); int rows = *((int*) srcDataPtr[1]); int cols = *((int*) srcDataPtr[2]); int type = *((int*) srcDataPtr[3]); - std::cout << "CVT" << std::endl; - std::cout << "rows: " << rows << std::endl; - std::cout << "cols: " << cols << std::endl; Mat dstMat = Mat(src.m().rows, src.m().cols, src.m().type()); void** dstDataPtr = dstMat.ptr(); @@ -77,7 +58,7 @@ private: dstDataPtr[3] = srcDataPtr[3]; *((int*)dstDataPtr[3]) = CV_8UC1; // not sure if the type of the new mat is the same - br::cuda::cudacvt_wrapper(srcDataPtr[0], &dstDataPtr[0], rows, cols); + br::cuda::cudargb2grayscale_wrapper(srcDataPtr[0], &dstDataPtr[0], rows, cols); dst = dstMat; /* @@ -92,8 +73,8 @@ private: } }; -BR_REGISTER(Transform, CUDACvtTransform) +BR_REGISTER(Transform, CUDARGB2GrayScaleTransform) } // namespace br -#include "imgproc/cudacvt.moc" +#include "imgproc/cudargb2grayscale.moc" diff --git a/openbr/plugins/cuda/cudacvt.cu b/openbr/plugins/cuda/cudargb2grayscale.cu index 9c07c6b..ba10b80 100644 --- a/openbr/plugins/cuda/cudacvt.cu +++ b/openbr/plugins/cuda/cudargb2grayscale.cu @@ -14,7 +14,7 @@ using namespace cv::gpu; namespace br{ namespace cuda { - __global__ void cudacvt_kernel(uint8_t* srcPtr, uint8_t* dstPtr, int rows, int cols) + __global__ void cudargb2grayscale_kernel(uint8_t* srcPtr, uint8_t* dstPtr, int rows, int cols) { int rowInd = blockIdx.y*blockDim.y+threadIdx.y; int colInd = blockIdx.x*blockDim.x+threadIdx.x; @@ -31,17 +31,15 @@ namespace br{ namespace cuda { return; } - void cudacvt_wrapper(void* srcPtr, void** dstPtr, int rows, int cols) + void cudargb2grayscale_wrapper(void* srcPtr, void** dstPtr, int rows, int cols) { cudaError_t err; dim3 threadsPerBlock(8, 8); dim3 numBlocks(cols/threadsPerBlock.x + 1, rows/threadsPerBlock.y + 1); - std::cout << "Before malloc" << std::endl; CUDA_SAFE_MALLOC(dstPtr, rows*cols*sizeof(uint8_t), &err); - std::cout << "After malloc" << std::endl; - cudacvt_kernel<<>>((uint8_t*)srcPtr, (uint8_t*) (*dstPtr), rows, cols); + cudargb2grayscale_kernel<<>>((uint8_t*)srcPtr, (uint8_t*) (*dstPtr), rows, cols); CUDA_KERNEL_ERR_CHK(&err); CUDA_SAFE_FREE(srcPtr, &err); }