sar*_*d m 38 c++ python opencv
我想得到图像的宽度和高度,我怎么能在OpenCV中做到这一点?
例如:
Mat src = imread("path_to_image");
cout << src.width;
Run Code Online (Sandbox Code Playgroud)
是对的吗?
Mik*_*iki 73
你可以使用rows和cols:
cout << "Width : " << src.cols << endl;
cout << "Height: " << src.rows << endl;
Run Code Online (Sandbox Code Playgroud)
或者size():
cout << "Width : " << src.size().width << endl;
cout << "Height: " << src.size().height << endl;
Run Code Online (Sandbox Code Playgroud)
Ano*_*oah 45
另外对于python中的openCV,你可以这样做:
img = cv2.imread('myImage.jpg')
height, width, channels = img.shape
Run Code Online (Sandbox Code Playgroud)