简体   繁体   English

图像映射到参考形状OpenCv

[英]Image mapping to reference shape OpenCv

在此处输入图片说明

Here is the reference Image 这是参考图像

在此处输入图片说明

Here is the test image. 这是测试图像。

I wanted to know which algorithm can help me in mapping test image shape to the reference image shape, so that both of them overlap perfectly. 我想知道哪种算法可以帮助我将测试图像形状映射到参考图像形状,从而使两者完美重叠。

OpenCv Python. OpenCv Python。

You can find out keypoints in one of your images using any of the keypoint detection methods available in openCV(harris, FAST. etc). 您可以使用openCV中的任何关键点检测方法(harris,FAST等)在一张图像中找出关键点。 You can then track those points in your other image and then compute rotation translation using 'findessentialmatrix' and 'recoverPose' openCV functions. 然后,您可以在其他图像中跟踪这些点,然后使用“ findessentialmatrix”和“ recoverPose” openCV函数计算旋转平移。 Once you get your rotations and translation you can rotate your first image with those values to excatly map them on top of each other. 一旦获得旋转和平移,就可以使用这些值旋转第一张图像,以使它们彼此完美地映射。

here are the functions you can call one after other ( check for inputs and dependencies from opencv page): 这是可以一个接一个地调用的函数(请检查opencv页面的输入和依赖项):

1) FAST for keypoint detection 1)快速检测关键点

2) Lukas kanade for keypoint tracking 2)Lukas kanade用于关键点跟踪

3) findEssentialMatrix 3)findEssentialMatrix

4) recoverPose 4)restorePose

A similar case with step by code and a walk through is given in the OpenCV tutorials here . 此处的OpenCV教程提供了类似的示例,其中包含逐步的代码和逐步的介绍。

It wont work for the simple example you show because there is no unique mapping. 因为没有唯一的映射,所以它对您显示的简单示例不起作用。 Your blue square is uniform and thus there is no way to know if it has been rotated by 45, 135, 225, or 315 degrees. 您的蓝色方块是统一的,因此无法知道它是否已旋转45、135、225或315度。 So you will either need to make your images non-rotationally symmetrical or give them texture rather than a uniform colour. 因此,您要么需要使图像非旋转对称,要么使它们具有纹理而不是均匀的颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM