Hi Guys,
I am trying to use findContours on CUDA processed images. I am trying to achieve this in two separate threads running concurrently. When I try to do the same I am getting Segmentation fault. Please find the code below :
void functionCalledFirst(Mat &img)
{
cudaThreadSynchronize();
runCUDA(img);
}
void runCUDA(Mat &img)
{
int fsize = 2048*1080;
cudaMallocManaged(&m_dbuffer, fsize);
cudaMallocManaged(&m_dcudaout, fsize);
cudaMemcpy (m_dbuffer,(char * ) img.data,fsize,cudaMemcpyHostToDevice)
runCudaKernel(m_dcudaout , dbuffer); // binary output
cv::Mat cudaOutMat = cv::Mat(img.rows,img.cols, CV_8UC1, (void *) m_dcudaout , 2048);
findContours(cudaOutMat, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0) );
}
When I comment out findContours the code runs without crashing. Please help me figure out what the problem could be ?
Thanks.