C++ 查找点相对于整个图像的X和Y坐标
我试图在2D图像中找到鼻尖地标。它的工作不是100%正确,但作为第一个办法,它完全满足我C++ 查找点相对于整个图像的X和Y坐标,c++,opencv,face-detection,feature-detection,roi,C++,Opencv,Face Detection,Feature Detection,Roi,我试图在2D图像中找到鼻尖地标。它的工作不是100%正确,但作为第一个办法,它完全满足我 vector<Rect> noses; vector<Rect> faces; vector<Rect> eyes; Mat frame_gray; Mat matched_frame; //frame with matched face Mat gray; Rect region_of_interest; cvtColor(frame, frame_gray, COL
vector<Rect> noses;
vector<Rect> faces;
vector<Rect> eyes;
Mat frame_gray;
Mat matched_frame; //frame with matched face
Mat gray;
Rect region_of_interest;
cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(30, 30));
for (int i = 0; i < faces.size(); i++)
{
Point pt1(faces[i].x, faces[i].y); // Display detected faces on main window - live stream from camera
Point pt2((faces[i].x + faces[i].height), (faces[i].y + faces[i].width));
rectangle(frame, pt1, pt2, Scalar(255,0 , 0), 2, 8, 0);
cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
equalizeHist( frame_gray, frame_gray );
//NOSE TIP DETECTION
Rect noseROI1;
noseROI1.x = (faces[i].x);
noseROI1.y = faces[i].y + (faces[i].height/2.5);
noseROI1.width = (faces[i].width);
noseROI1.height = (faces[i].height/2.8);
Point ptNoseX(noseROI1.x, noseROI1.y);
Point ptNoseY(noseROI1.x+noseROI1.width, noseROI1.y+noseROI1.height);
//Rectangle around region of interest concentrated on nose
rectangle(frame, ptNoseX,ptNoseY, Scalar(0,255,255), 2, 2, 0);
Mat image_roi_nose = frame(noseROI1);
nose_cascade.detectMultiScale(image_roi_nose, noses, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(40, 30));
for (int i = 0; i < noses.size(); i++)
{
region_of_interest.x = noses[i].x;
region_of_interest.y = noses[i].y;
region_of_interest.width = (noses[i].width);
region_of_interest.height = (noses[i].height);
matched_frame = frame(region_of_interest);
cvtColor(matched_frame, gray, CV_BGR2GRAY);
Point pt1(noses[i].x, noses[i].y);
Point pt2((noses[i].x + noses[i].height), (noses[i].y + noses[i].width));
rectangle(image_roi_nose, pt1, pt2, Scalar(0, 255, 0), 2, 8, 0);
int x1 = noses[i].x + (noses[i].height/2);
int y1 = noses[i].y + (noses[i].width/2);
circle(image_roi_nose, Point(x1, y1), 2, CV_RGB(255,0,0),2, 8, 0);
}
矢量鼻;
向量面;
矢量眼;
垫子框架为灰色;
Mat-u框架//相配面框
席灰色;
感兴趣的矩形区域;
CVT颜色(框架、框架灰、颜色灰);
人脸层叠。检测多尺度(帧灰度,人脸,1.1,2,0;层叠图像,大小(30,30));
对于(int i=0;i
此代码找到鼻尖,但它返回我x1
和y1
与Mat image\u roi\u nose
,我如何计算该点相对于整个图像的坐标??
如果我的问题不清楚,请让我知道我会尝试解释更多细节
谢谢大家的帮助
x = x1 + noseROI1.x;
y = y1 + noseROI1.y;