Hi. I'm new to using CUDA with OpenCV so this might be a very simple error but I'm kinda stuck. My code is the following:
#include <opencv2/opencv.hpp>
#include <opencv2/cudaimgproc.hpp>
#include <stdio.h>
#include <omp.h>
#include <string>
using namespace cv;
int main( int argc, char** argv )
{
cuda::setDevice(0);
Mat pictureBGR;
Mat pictureSegment;
cuda::GpuMat bgr;
std::cout << cuda::getCudaEnabledDeviceCount() << std::endl;
pictureBGR = imread("2.jpg"); //unos slike za pretragu
if(!pictureBGR.data)
{
std::cout << "Error loading image!" << std::endl;
return -1;
}
bgr.upload(pictureBGR);
//cuda::cvtColor(bgr, bgr, COLOR_BGR2BGRA, CV_8UC4);
TermCriteria criteria(CV_TERMCRIT_EPS, 0, 0.008);
cuda::meanShiftSegmentation(bgr, bgr, 20, 20, 10, criteria);
namedWindow("Display Image", CV_WINDOW_AUTOSIZE);
imshow("Display Image", bgr);
waitKey(0);
return 0;
}
And i'm getting the following error:
Assertion failed (src.type() == CV_8UC4) in meanShiftSegmentation, file /home/zburazin/opencv-3.0.0/modules/cudaimgproc/src/mssegmentation.cpp, line 229
terminate called after throwing an instance of 'cv::Exception'
what(): /home/zburazin/opencv-3.0.0/modules/cudaimgproc/src/mssegmentation.cpp:229: error: (-215) src.type() == CV_8UC4 in function meanShiftSegmentation
I understand that the meanShiftSegmentation only takes GpuMat of type 8UC4, but I am still to find a solution to convert it. Any ideas?
std::cout << cuda::getCudaEnabledDeviceCount() << std::endl; returns 1 btw.