我在c++中有这个void函数
void DrawFace(cv::Mat img, Window face)
{
int x1 = face.x;
int y1 = face.y;
int x2 = face.width + face.x - 1;
int y2 = face.width + face.y - 1;
int centerX = (x1 + x2) / 2;
int centerY = (y1 + y2) / 2;
std::vector<cv::Point> pointList;
pointList.push_back(RotatePoint(x1, y1, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x1, y2, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x2, y2, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x2, y1, centerX, centerY, face.angle));
DrawLine(img, pointList);
}
我想让它只返回pointList向量,我对其进行了更改
void Drawface(cv::Mat img, Window face)
{
int x1 = face.x;
int y1 = face.y;
int x2 = face.width + face.x - 1;
int y2 = face.width + face.y - 1;
int centerX = (x1 + x2) / 2;
int centerY = (y1 + y2) / 2;
std::vector<cv::Point> pointList;
pointList.push_back(RotatePoint(x1, y1, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x1, y2, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x2, y2, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x2, y1, centerX, centerY, face.angle));
return pointList
}
如果有人能指出我哪里出了问题,以及我能做出什么改变,那将是非常有帮助的。
提前感谢
函数的返回类型仍然是void
。你需要改变它来反映身体的变化。此外,return pointList
后面缺少分号。
您需要声明函数的返回类型。
std::vector<cv::Point> Drawface(cv::Mat img, Window face)
{
int x1 = face.x;
int y1 = face.y;
int x2 = face.width + face.x - 1;
int y2 = face.width + face.y - 1;
int centerX = (x1 + x2) / 2;
int centerY = (y1 + y2) / 2;
std::vector<cv::Point> pointList;
pointList.push_back(RotatePoint(x1, y1, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x1, y2, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x2, y2, centerX, centerY, face.angle));
pointList.push_back(RotatePoint(x2, y1, centerX, centerY, face.angle));
return pointList;
}