我想获得图像宽度和高度,我该如何在OpenCV中实现?
例如:
(function () {
// Append the safeHTML polyfill
var scriptElem = document.createElement('script');
scriptElem.setAttribute('src', 'scripts/winstore-jscompat.js');
var scriptElem2 = document.createElement('script');
scriptElem.setAttribute('src', 'scripts/system-polyfills.js');
if (document.body) {
document.body.appendChild(scriptElem);
document.body.appendChild(scriptElem2);
} else {
document.head.appendChild(scriptElem);
document.head.appendChild(scriptElem2);
}
}());
是吗?
答案 0 :(得分:67)
您可以使用rows
和cols
:
cout << "Width : " << src.cols << endl;
cout << "Height: " << src.rows << endl;
或size()
:
cout << "Width : " << src.size().width << endl;
cout << "Height: " << src.size().height << endl;
答案 1 :(得分:36)
对于python中的openCV,你可以这样做:
img = cv2.imread('myImage.jpg')
height, width, channels = img.shape