nim*_*cap 5 mapping opencv textures image image-processing
我想将图像放到/包装到3D对象.为了保持简单和快速,我想使用映射图像,而不是使用(和学习)3D库.映射图像以这种方式使用:

因此,您为每个对象生成一次映射图像,并对要包装的所有图像使用相同的映射.
我的问题是如何生成这样的映射图像(给定3D模型)?由于我不知道术语,我的搜索失败了.对不起,如果我使用错误的行话.
您可以在下面看到工作流程的说明.
我有对象的3D模型和输入图像,我想生成可以用来生成纹理图像的映射图像.
我甚至不知道从哪里开始,任何指针都表示赞赏.
更多信息
我最初的想法是以某种方式使用外部程序包装身份映射(见下文).我已经在Photoshop中生成了水平和垂直渐变图像,只是为了看看是否使用photoshop生成的图像进行映射.结果看起来不太好.我没有希望,但值得一试.
输入

映射(x和y),它们只是调整图像大小,它们没有做任何花哨的事情.

结果

你可以看到有很多文物.我通过扭曲渐变产生的自定义映射图像甚至看起来更糟.
以下是有关映射的更多信息:http://www.imagemagick.org/Usage/mapping/#distortion_maps
我正在使用OpenCV remap()函数进行映射.
如果我理解你的意思,你想用 2D 来做这一切吗?
为每个立方体表面调用 warpPerspective() 会比使用 remap() 成功得多
伪代码概要:
// for each surface:
// get the desired src and dst polygon
// the src one is your texture-image, so that's:
vector<Point> p_src(4), p_dst(4);
p_src[0] = Point(0,0);
p_src[1] = Point(0,src.rows-1);
p_src[2] = Point(src.cols-1,0);
p_src[3] = Point(src.cols-1,src.rows-1);
// the dst poly is the one you want textured, a 3d->2d projection of the cube surface.
// sorry, you've got to do that on your own ;(
// let's say, you've come up with this for the cube - top:
p_dst[0] = Point(15,15);
p_dst[1] = Point(44,19);
p_dst[2] = Point(56,30);
p_dst[3] = Point(33,44);
// now you need the projection matrix to transform from one to another:
Mat proj = getPerspectiveTransform( p_src, p_dst );
// finally, you can warp your texture to the dst-polygon:
warpPerspective(src, dst, proj, dst.size());
Run Code Online (Sandbox Code Playgroud)
如果你能找到《Learning Opencv》一书,它在第 170 页左右有描述。
最后的警告,因为你在抱怨人工制品, - 是的,这一切看起来都很俗气,“真正的”3D 引擎在这里做了很多工作,子像素 uv 映射、过滤、mipmapping 等,如果你想要的话看起来不错,考虑使用“真实”的东西。
顺便说一句,opencv 内置了很好的 opengl 支持