How to get image width and height in OpenCV? [duplicate]
Solution 1:
You can use rows
and cols
:
cout << "Width : " << src.cols << endl;
cout << "Height: " << src.rows << endl;
or size()
:
cout << "Width : " << src.size().width << endl;
cout << "Height: " << src.size().height << endl;
or size
cout << "Width : " << src.size[1] << endl;
cout << "Height: " << src.size[0] << endl;
Solution 2:
Also for openCV in python you can do:
img = cv2.imread('myImage.jpg')
height, width, channels = img.shape