Image management code issue

Hi guys.

Having a bit of trouble here with some code for working with images. I will first say that this does involve using OpenCV so if this is not the place for this issue do not hesitate to let me know.

Essentially what I am having trouble with doing is error checking a cv::Mat using a if statement. Here is my code:
==========

IplImage *src, *dst;

src = cvLoadImage("C:/Users/Kmpok/Desktop/images/baboon200.jpg");
dst = cvLoadImage("C:/Users/Kmpok/Desktop/images/baboon200_rotated.jpg");

//Converts from IplImage to Mat
cv::Mat srcMat = cv::cvarrToMat(src);
cv::Mat dstMat = cv::cvarrToMat(dst);

src = cvLoadImage("C:/Users/Kmpok/Desktop/images/baboon200.jpg");
dst = cvLoadImage("C:/Users/Kmpok/Desktop/images/baboon200_rotated.jpg");

cv::Mat srcMat;

if (argc == 2)
{
srcMat = cv::cvarrToMat(src);
if (srcMat != NULL)
{
printf("Load successful");
}
else
{
printf("Load failed.");
}
}

==========

Basically what I did was convert a IplImage variable to cv::Mat. That was src to srcMat. That is going through with no trouble from what I can see as it builds just fine if I comment out the entire If statement. The issue is the if statement itself. How do I check to see if scrMat got its value or if it is NULL using a if statement? I have searched this to death and can not find this.

Any help at all is much appreciated. Thank you.
1
2
3
4
cv::mat srcMat = cv::imread("C:/Users/Kmpok/Desktop/images/baboon200.jpg");

if(srcMat.empty())
   std::cerr << "Load failed\n";
Topic archived. No new replies allowed.