2014-02-18 91 views
0

如何使用OpenCV確定圖像(Mat格式)的分辨率(寬x高)?如何計算圖像的分辨率?

我有一個線程,在一次接收許多圖像..一個。我想要確定圖像的分辨率,當線程接收到它時(以像素爲單位獲得寬度和高度的尺寸)。

回答

2

像這樣:

cv::Mat someMat; 
int width; 
int height; 

width = someMat.cols; 
height = someMat.rows; 

或:

width = someMat.size().width; 
height = someMat.size().height; 
+0

非常感謝你! – AgentSmith891

+1

還有一件事,opencv在這裏有一個很棒的文檔http://docs.opencv.org/你可以在這裏找到關於opencv的所有知識。 –

+0

很高興知道......謝謝! – AgentSmith891

2

對於Mat mat,你可以簡單地使用以下方法來獲得它的尺寸(寬度和高度):

int width = mat.cols; 
int height = mat.rows; 
+0

謝謝你非常感謝! – AgentSmith891