Segmentation fault when cv::Mat is constructed by Image buffer and not by VideoCapture::retreive
When I add to a buffer (a Qt QQueue) a cv::MAT that gets acquired using function
Mat grabbedFrame;
videoCapture.retreive(grabbedFrame);
the image gets dequed and cloned just fine.
When I create a Mat using the constructor below
Mat PylonToOpenCvImage = cv::Mat(ptrGrabResult->GetHeight(), ptrGrabResult->GetWidth(), CV_8UC1, (uint8_t *) pylonImage.GetBuffer());
trying to deque and clone gives a segmentation fault....
But Using
cv::imshow()
both images can be viewed....
What could be wrong? What are The differences between the grabbedFrame variable ant the PylonToOpenCvImage one.
The seg fault seems to be here
Mat Mat::clone() const
{
Mat m;
copyTo(m);
return m;
}
at the copyTo(m) function from mat.inl.hpp. Although please don't take it for granted
Additionally this is the error I get
OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in Mat, file /build/opencv-iC2m9y/opencv-3.2.0+dfsg/modules/core/src/matrix.cpp, line 522
terminate called after throwing an instance of 'cv::Exception'
what(): /build/opencv-iC2m9y/opencv-3.2.0+dfsg/modules/core/src/matrix.cpp:522: error: (-215) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function Mat
regards