Drawing a fixed set of grid lines with opencv

Is it possible to draw user-defined grid lines with specific points at all intersections against the output of the color definition sample in the opencv sample file? Basically, a webcam will have to detect a human head and shoulders on top of you. Then, when a person is discovered, I need grid lines to be there so that I can find out from which external grid (left shoulder), to the next external grid (right shoulder), both along the x axis and along the y axis (forehead and the back of the head). After that, these points must be sent for the operation of mechanical parts such as actuators and valves.

I will be very grateful for any help, because I really despaired now.

thank!

I am an entry-level opentv user, with only newcomers to working with C ++. I am currently using opencvV2.1, on VS2008.

+5
source share
2 answers

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.

// assume that mat.type=CV_8UC3

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); 
+3
source

To draw a grid on an image using the OpenCV line function

Mat mat_img(image);
int stepSize = 65;

int width = mat_img.size().width;
int height = mat_img.size().height;

for (int i = 0; i<height; i += stepSize)
    cv::line(mat_img, Point(0, i), Point(width, i), cv::Scalar(0, 255, 255));

for (int i = 0; i<width; i += stepsSize)
    cv::line(mat_img, Point(i, 0), Point(i, height), cv::Scalar(255, 0, 255));
0
source

All Articles