Ask Your Question
1

cuda::meanShiftSegmentation - Assertion Failed Error

asked 2016-02-06 12:23:56 -0600

zvonimirb gravatar image

updated 2016-02-08 06:46:59 -0600

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 )
{
Mat pictureBGR;
Mat pictureSegment;
cuda::GpuMat bgr;
cuda::GpuMat convertedBgr;
cuda::GpuMat dstBgr;

std::cout << cuda::getCudaEnabledDeviceCount() << std::endl;
pictureBGR = imread("2.jpg"); //unos slike za pretragu
if(!pictureBGR.data)
{
    std::cout << "Gre\u0161ka pri u\u010ditavanju slike!" << std::endl;
    return -1;
}

bgr.upload(pictureBGR);
cuda::cvtColor(bgr, convertedBgr, CV_BGR2BGRA);

TermCriteria criteria(CV_TERMCRIT_EPS, 0, 0.08);
cuda::meanShiftSegmentation(convertedBgr, dstBgr, 20, 20, 3, criteria);
dstBgr.download(pictureSegment);

namedWindow("Display Image", CV_WINDOW_AUTOSIZE);
imshow("Display Image", pictureSegment);
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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-02-10 05:01:54 -0600

zvonimirb gravatar image

Can I bump this? Still can't figure out the problem :(

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-02-06 12:23:56 -0600

Seen: 800 times

Last updated: Feb 10 '16