小编Muh*_*han的帖子

如何使用SURF功能(Python OpenCV)匹配和对齐两个图像?

我正在使用以下代码来匹配两个图像的冲浪特征,但无法裁剪和对齐图像。

原始图像-旋转图像和匹配图像如下。

原版的 旋转的 匹配

我想像原始图像一样将旋转后的图像拉直,并裁剪出直线对齐的图像。我尝试了几何变换,但无法对齐图像。

import numpy
import cv2

############### Image Matching ###############


def match_images(img1, img2):
    """Given two images, returns the matches"""
    detector = cv2.SURF(400, 5, 5)
    matcher = cv2.BFMatcher(cv2.NORM_L2)

    kp1, desc1 = detector.detectAndCompute(img1, None)
    kp2, desc2 = detector.detectAndCompute(img2, None)

    raw_matches = matcher.knnMatch(desc1, trainDescriptors = desc2, k = 2) 
    kp_pairs = filter_matches(kp1, kp2, raw_matches)
    return kp_pairs

def filter_matches(kp1, kp2, matches, ratio = 0.75):
    mkp1, mkp2 = [], []
    for m in matches:
        if len(m) == 2 and m[0].distance < m[1].distance * ratio: …
Run Code Online (Sandbox Code Playgroud)

python opencv image surf

4
推荐指数
1
解决办法
2692
查看次数

如何从 json 注释图像制作 tfrecords

我已经使用 tensorflow object detection-api 来训练我自己的对象检测器。但当时,图像是使用labelimg注释的,它为每个图像创建 xml 文件。现在我得到了每个图像都有 json 文件的标记图像。那么如何我使用这些 json 文件来创建 tfrecords。

python json object-detection tensorflow object-detection-api

4
推荐指数
1
解决办法
6671
查看次数