Converting cvMat to GpuMat gives segmentation fault

asked 2016-10-24 07:54:22 -0600

lm35 gravatar image

I am converting "cv_img = cv::Mat(ptrGrabResult->GetHeight(),ptrGrabResult->GetWidth(), CV_8UC3,(uint8_t*)image.GetBuffer());" into GpuMat using "d_frame= GpuMat(cv_img);"

where d_frame is declared as cv::cuda::GpuMat d_frame;

at the conversion im getting segmentation fault. please suggest a solution . I referred the following linkStackoverflow, OpencvQ&A

edit retag flag offensive close merge delete


is there any chance, your "image" object goes out of scope, before you try to copy to GpuMat ?

(can you show a bit more code around that ?)

berak gravatar imageberak ( 2016-10-24 08:00:08 -0600 )edit

image is a continuous video frame

lm35 gravatar imagelm35 ( 2016-10-24 08:03:49 -0600 )edit

the cv::Mat constructor you're using does not copy pixels, only the pointer to it. (which might get invalid).

you might need to clone() the Mat.

berak gravatar imageberak ( 2016-10-24 08:07:34 -0600 )edit

added code here

lm35 gravatar imagelm35 ( 2016-10-24 08:15:23 -0600 )edit

Image data that Mat cv_img holds have got rows =958 and coulmns = 1278. is this beyond the limit for GpuMat ?

lm35 gravatar imagelm35 ( 2016-10-25 04:30:04 -0600 )edit