我有以下功能
void DrawAndShowCircle(int windowWidth, int windowHeight,int windowType,Scalar windowBGColor, VirtualCircle circle)
{
cv::circle(circleImage,circle.Center,circle.Radius,circle.Color,circle.Thickness,circle.LineType);
}
void DrawAndShowCircles(int windowWidth, int windowHeight,int windowType,Scalar windowBGColor, vector<VirtualObject> circles)
{
circleImage = Mat(windowHeight,windowWidth,windowType);
circleImage.setTo(windowBGColor);
for(vector<VirtualObject>::iterator it = circles.begin(); it != circles.end(); ++it)
{
DrawAndShowCircle(windowWidth,windowHeight,windowType,windowBGColor,*it);
}
imshow("circle",circleImage);
cvWaitKey(0);
}
我遇到的问题是,在 DrawAndShowCircles 中,我一直在理解类型转换,此时我使用 for 循环遍历对象。
我有 VirtualObject
继承的基类VirtualCircle
我正在尝试遍历向量并显示圆圈。这是为 OpenCV 完成的,因此您会发现一些 OpenCV 函数。
这是调用代码
vector<VirtualObject> circles;
circles.push_back(VirtualCircle(Point(100,50),15,2,Scalar(255,100,100),1));
circles.push_back(VirtualCircle(Point(100,100),25,2,Scalar(100,255,100),1));
circles.push_back(VirtualCircle(Point(100,150),35,2,Scalar(100,100,255),1));
DrawAndShowCircles(200,200,CV_8UC3,Scalar(255,255,255),circles);
我无法使用 for 循环遍历。我不清楚类型转换。请指教。