c++ - Find X and Y coordinates of point in relation to the whole image -
i trying find nose tip landmark inside 2d image. it's not working 100% correct, first approach satisfy me.
vector<rect> noses; vector<rect> faces; vector<rect> eyes; mat frame_gray; mat matched_frame; //frame 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)); (int = 0; < faces.size(); i++) { point pt1(faces[i].x, faces[i].y); // display detected faces on main window - live stream 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)); (int = 0; < 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); }
this code finds nose tip, returns me x1
, y1
in relation mat image_roi_nose
, how can calculate coordinates of point in relation whole image?? if question unclear, please let me know try explain more details.
thank help!
x = x1 + noseroi1.x; y = y1 + noseroi1.y;
Comments
Post a Comment