opencv中的拼接面问题 [英] Mosaicing face problems in opencv
问题描述
您好我使用opencv和c ++。我有一个左侧的轮廓和同一个人的前面。如果在确定面部图像之间的变换矩阵并将该变换矩阵应用于左侧图像之后,当我将它叠加在原始正面上时,它不应该给我这样的面部,一切对齐?我显然做错了,得到这个结果。任何人都可以帮助这个请?这是研究论文的链接 http: //www.utdallas.edu/~herve/abdi-ypaa-jmm2006.pdf
Hi I am using opencv and c++. I have a left profile and a front face of the same individual. If after determining the transformation matrix between the face images and applying that transformation matrix to the left image,when I superimpose it on the original frontal face,shouldn’t it have given me a face like this ,with everything aligned?I am obviously doing something wrong and getting this result . Can anyone help with this please?Here is the link to that research paper http://www.utdallas.edu/~herve/abdi-ypaa-jmm2006.pdf
推荐答案
拍摄图片从您之前的一个问题中,手动查找绿色点的像素对应关系(因此3个对应关系)和此代码
taken the images from one of your previous questions, manually finding pixel correspondences for the green dots only (so 3 correspondences) and this code
//cv::Mat perspectiveTransform = cv::getPerspectiveTransform(firstFacePositions, secondFacePositions) ;
cv::Mat affineTransform = cv::getAffineTransform(firstFacePositions, secondFacePositions) ;
std::cout << affineTransform << std::endl;
cv::Mat perspectiveTransform = cv::Mat::eye(3,3,CV_64FC1);
for(unsigned int y=0; y<2; ++y)
for(unsigned int x=0; x<3; ++x)
{
perspectiveTransform.at<double>(y,x) = affineTransform.at<double>(y,x);
}
std::cout << perspectiveTransform << std::endl;
cv::Mat warped1;
cv::warpPerspective(face1,warped1,perspectiveTransform,face2.size());
cv::imshow("combined",warped1/2 + face2/2);
我得到以下结果:
使用<$相反,使用蓝色标记,我得到:
using the line cv::Mat perspectiveTransform = cv::getPerspectiveTransform(firstFacePositions, secondFacePositions);
instead and using the blue marker too, I get:
>
编辑:C ++语法,但是与C#和Java类似的工作原理。
edit: C++ syntax, but that works with C# and Java similar I guess.
这篇关于opencv中的拼接面问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!