April 2017
Beginner to intermediate
250 pages
6h 28m
English
Now that we've been able to iterate through the triangles of a subdivision, we are able to warp one triangle from an original annotated image into a generated distorted one. This is useful for mapping the texture from the original shape to a distorted one. The following piece of code will guide the process:
void warpTextureFromTriangle(Point2f srcTri[3], Mat originalImage, Point2f dstTri[3], Mat warp_final){ Mat warp_mat(2, 3, CV_32FC1); Mat warp_dst, warp_mask; CvPoint trianglePoints[3]; trianglePoints[0] = dstTri[0]; trianglePoints[1] = dstTri[1]; trianglePoints[2] = dstTri[2]; warp_dst = Mat::zeros(originalImage.rows, originalImage.cols, originalImage.type()); warp_mask = Mat::zeros(originalImage.rows, originalImage.cols, ...Read now
Unlock full access