gpt4 book ai didi

python - 类型错误 : Argument given by name ('k' ) and position (2)

转载 作者:太空狗 更新时间:2023-10-30 02:43:54 25 4
gpt4 key购买 nike

在下面找到我的 opencv3 Python3 代码来匹配引发以下错误的对象:

TypeError: Argument given by name ('k') and position (2)

代码如下:

import numpy as np
import cv2
import time
import distance
camera = cv2.VideoCapture(0)
sift = cv2.xfeatures2d.SIFT_create()
img = cv2.imread('/home/shar/bo.jpg')
imgTrainGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
kpTrain = sift.detect(imgTrainGray,None)
kpTrain, desTrain = sift.compute(imgTrainGray, kpTrain)
FLANN_INDEX_KDTREE = 0
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks=50)
flann = cv2.FlannBasedMatcher(index_params,search_params)

matches = flann.knnMatch(kpTrain,desTrain,k=2)

关于如何修复它的想法?

最佳答案

这对我有用

FLANN_INDEX_KDTREE = 0
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks=50)

flann = cv2.FlannBasedMatcher(index_params,search_params)
matches = flann.knnMatch(np.asarray(des1,np.float32),np.asarray(des2,np.float32),k=2)

关于python - 类型错误 : Argument given by name ('k' ) and position (2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31739179/

25 4 0
文章推荐: python - 提取
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com