The OpenCV 2 Cookbook page 40 claims that this is not possible. Also regarding Mat_:
"Using the at method in the cv :: Mat class can sometimes be cumbersome because the return type must be specified as a template argument for each call. In cases where the matrix type is known, you can use the cv :: Mat_ class, which is a subclass of the cv template :: Mat.
cv::Mat_<uchar> im2= image; // im2 refers to image im2(50,100)= 0; //access to row 50 and column 100
Since the type cv :: Mat_ elements are declared when a variable is created, the operator () method knows at compile time which type returns. "
EDIT : use Mat.type ()
Mat image=imread("image.bmp"); cout<<image.type();
Console output:
16
Wiki: the method returns the type of the matrix element, an identifier compatible with a system of type CvMat, such as CV_16SC3 or a 16-bit signed 3-channel array, etc.
William
source share