Is it possible to draw user-defined grid lines with defined points at all intersections, against the output of the color detection sample in the OpenCV sample file? Basically, the webcam will need to be detecting human head and shoulders from above you. Then when a person is detected, I need the grid lines to be there so that I am able to know from which outermost grid (left shoulder), to the next outermost grid (right shoulder), in both x and y axis (forehead and back of head). Thereafter, these points have to be sent for operation of mechanical parts like actuator and valves.
I'm an entry level OpenCV user, with just beginner knowledge about working with C++. I am currently using OpenCV 2.1 on VS2008.
It is difficult to tell what your problem really is.
If you just want to draw gridlines, there's no opencv function which does that.
To plot lines in a grid, you can use cv::line
in a loop, then draw the 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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With