使用OpenCV绘制一组固定的网格线 [英] Drawing fixed set of grid lines with OpenCV

查看:1422
本文介绍了使用OpenCV绘制一组固定的网格线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以相对于OpenCV样本文件中颜色检测样本的输出绘制在所有相交处具有定义点的用户定义的网格线?基本上,网络摄像头需要从您的上方检测人的头和肩膀.然后,当检测到人时,我需要在其中存在网格线,以便能够知道在x和y轴(前额和前额)中从哪个最外面的网格(左肩)到下一个最外面的网格(右肩).头后).此后,必须将这些点发送给执行器和阀门等机械零件.

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.

我是OpenCV的入门级用户,只有关于C ++的入门知识. 我目前在VS2008上使用OpenCV 2.1.

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.

如果您只想绘制网格线,则没有opencv函数可以执行此操作. 要在网格中绘制线,可以在循环中使用cv::line,然后使用嵌套循环绘制相交.

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); 

这篇关于使用OpenCV绘制一组固定的网格线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆