It's hard to say what your problem is.
If you just want to draw grids , there is no opencv function that does this. To build lines in a grid, you can use cv::linein a loop, then draw intersections with a nested loop.
dist=50;
int width=mat.size().width;
int height=mat.size().height;
for(int i=0;i<height;i+=dist)
cv::line(mat,Point(0,i),Point(width,i),cv::Scalar(255,255,255));
for(int i=0;i<width;i+=dist)
cv::line(mat,Point(i,0),Point(i,height),cv::Scalar(255,255,255));
for(int i=0;i<width;i+=dist)
for(int j=0;j<height;j+=dist)
mat.at<cv::Vec3b>(i,j)=cv::Scalar(10,10,10);
source
share