在OpenCV中,cvGetRows()函数有什么用途?
我应该什么时候使用这个功能。有人能给我举个例子吗?根据它在OpenCV中,cvGetRows()函数有什么用途?,opencv,Opencv,我应该什么时候使用这个功能。有人能给我举个例子吗?根据它返回数组行或行跨度。它返回您指定的行 我将借助Python终端对其进行解释: 以灰度模式加载图像并检查其宽度和高度 >>> import cv2.cv as cv >>> img = cv.LoadImage('approx2.jpg',0) >>> img <iplimage(nChannels=1 width=300 height=300 widthStep=300 )>
返回数组行或行跨度。
它返回您指定的行
我将借助Python终端对其进行解释:
以灰度模式加载图像并检查其宽度和高度
>>> import cv2.cv as cv
>>> img = cv.LoadImage('approx2.jpg',0)
>>> img
<iplimage(nChannels=1 width=300 height=300 widthStep=300 )>
现在我们应用第一个函数cv.GetRow()
看,现在高度只有30,因为它每5行提取一次
结果如下:
>类似于<代码> CV.GETCOLL()和CV.GETCOLSH()/< > > /P> < P>我找到了另一个调用方法。让我们考虑这个C++代码段。< /P>
CvMat* input_matrix,sub_matrix;
int start,end;
//declarations of variables go here
cvGetRows(input_matrix, &sub_matrix, start, end);
函数获取输入矩阵中从起始行到结束行的行,并通过子矩阵指针指向它。现在,我们可以使用该指针在输入矩阵中从起始行到结束行填充值
>>> row = cv.GetRow(img,150)
>>> row
<cvmat(type=42424000 8UC1 rows=1 cols=300 step=300 )>
>>> cv.Sum(row)
(14279.0, 0.0, 0.0, 0.0)
>>> rows = cv.GetRows(img,0,150)
>>> rows
<cvmat(type=42424000 8UC1 rows=150 cols=300 step=300 )>
>>> cv.Sum(rows)
(802501.0, 0.0, 0.0, 0.0)
>>> rows = cv.GetRows(img,0,300,5)
>>> rows
<cvmat(type=42420000 8UC1 rows=60 cols=300 step=1500 )>
CvMat* input_matrix,sub_matrix;
int start,end;
//declarations of variables go here
cvGetRows(input_matrix, &sub_matrix, start, end);