#includeusing namespace cv; int main() { Mat image = imread("image.jpg"); Size image_size = image.size(); std::cout << "Image has " << image_size.width << " columns and " << image_size.height << " rows." << std::endl; return 0; }
#includeThis code creates a new matrix with 3 rows and 4 columns of type float. It then calls the size function to retrieve its dimensions, which are printed to the console. Package/Library: OpenCV.using namespace cv; int main() { int rows = 3; int cols = 4; Mat matrix(rows, cols, CV_32FC1); std::cout << "Matrix has " << matrix.rows << " rows and " << matrix.cols << " columns." << std::endl; return 0; }