找到与整个图像相关的点的X和Y坐标
Find X and Y coordinates of point in relation to the whole image
我试图在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, 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);
}
此代码找到鼻尖,但是它返回了我的x1
和y1
,与Mat image_roi_nose
有关,如何计算与整个图像有关的这一点的坐标?如果我的问题尚不清楚,请让我知道我会尝试用更多细节来解释它。
谢谢大家的帮助!
x = x1 + noseROI1.x;
y = y1 + noseROI1.y;
相关文章:
- 在C++中使用GDAL可以将图像的像素坐标转换为lat,long吗
- 从 3 个视点在 3 张图像上有 3 个点如何在 3D 空间中获取其坐标?
- 将 2D 图像坐标转换为 z = 0 的 3D 世界坐标
- 如何将世界坐标转换为相机图像坐标
- OPENCV(C ) - 从已知的3D对象和相机位置计算图像的2D坐标
- 在调整大小窗口时,如何使用鼠标单击来获取图像的坐标
- C 矩阵乘法 - 从深度图像中恢复3D坐标
- 图像点(像素)到真实世界坐标(米)
- 找到与整个图像相关的点的X和Y坐标
- 如何区分具有对象坐标的两个图像
- ITK 中具有稀疏和连续坐标的图像
- 图像处理 - OpenCV - 查找图像中圆的面积和中心坐标
- 仅对从扭曲图像获得的坐标应用重映射,而不对整个图像应用重映射
- OpenCV:查找二进制 Mat 图像的所有非零坐标
- 使用 OpenCV 将鼠标指针悬停在图像上时在图像上打印像素坐标
- 将数据坐标构建为像素坐标的图像
- 使用坐标垫访问图像值(OpenCV / C++)
- 从扭曲的图像返回到原始坐标
- 将字节数组从位图图像读取到坐标X和Y中
- cv::warpAffine -负图像坐标