I have some allocated cv::Mat face; with actual data in it and I want to perform something along the lines of the following:
cv::Mat gray_image;
cv::Mat x_gradient_image;
cv::Mat temp;
cv::cvtColor(face, gray_image, CV_RGB2GRAY);
cv::Sobel(gray_image, temp, 1, 1, 0);
cv::convertScaleAbs(temp, x_gradient_image, 1, 0);
This causes the program to crash, but I assumed in the new C++ API that cv::Mat objects were good at allocating their own memory. What is the simplest way to allocate the memory for those cv::Mat objects?
I changed the depth parameter in the call to Sobel and your code worked for me: