#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
void drawDashRect(CvArr* img,int linelength,int dashlength,CvRect* blob,CvScalar color,int thickness)
{
int w=cvRound(blob->width);//width
int h=cvRound(blob->height);//height
int tl_x=cvRound(blob->x);//top left x
int tl_y=cvRound(blob->y);//top left y
int totallength=dashlength+linelength;
int nCountX=w/totallength;//
int nCountY=h/totallength;//
CvPoint start,end;//start and end point of each dash
//draw the horizontal lines
start.y=tl_y;
start.x=tl_x;
end.x=tl_x;
end.y=tl_y;
for (int i=0;i<nCountX;i++)
{
end.x=tl_x+(i+1)*totallength-dashlength;//draw top dash line
end.y=tl_y;
start.x=tl_x+i*totallength;
start.y=tl_y;
cvLine(img,start,end,color,thickness);
}
for (int i=0;i<nCountX;i++)
{
start.x=tl_x+i
用opencv画虚线框矩形
最新推荐文章于 2023-06-06 22:12:03 发布