Voglio ottenere larghezza e altezza dell'immagine, come posso farlo in OpenCV?Come ottenere larghezza e altezza dell'immagine in OpenCV?
Ad esempio:
Mat src = imread("path_to_image");
cout << src.width;
È quello giusto?
Voglio ottenere larghezza e altezza dell'immagine, come posso farlo in OpenCV?Come ottenere larghezza e altezza dell'immagine in OpenCV?
Ad esempio:
Mat src = imread("path_to_image");
cout << src.width;
È quello giusto?
È possibile utilizzare rows
e cols
:
cout << "Width : " << src.cols << endl;
cout << "Height: " << src.rows << endl;
o size()
:
cout << "Width : " << src.size().width << endl;
cout << "Height: " << src.size().height << endl;
Anche per OpenCV in python si può fare:
img = cv2.imread('myImage.jpg')
height, width, channels = img.shape
Buono, ma OP chiede C++ – Petruza
Sì, questo è vero ma la ricerca su google per Python porta tu qui. – imoutidi