如何在c ++中使用XGBOOST https://github.com/dmlc/xgboost/库?我已经创建了Python和Java API,但我找不到c ++的API
如何在一个图像上找到一种类型的多个对象.我使用ORB特征查找器和强力匹配器(opencv = 3.2.0).
我的源代码:
import numpy as np
import cv2
from matplotlib import pyplot as plt
MIN_MATCH_COUNT = 10
img1 = cv2.imread('box.png', 0) # queryImage
img2 = cv2.imread('box1.png', 0) # trainImage
#img2 = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
# Initiate ORB detector
#
orb = cv2.ORB_create(10000, 1.2, nlevels=9, edgeThreshold = 4)
#orb = cv2.ORB_create()
# find the keypoints and descriptors with SIFT
kp1, des1 = orb.detectAndCompute(img1, None)
kp2, des2 = orb.detectAndCompute(img2, None)
FLANN_INDEX_KDTREE = 0
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5) …Run Code Online (Sandbox Code Playgroud) 我的 python 代码在图像上找不到棋盘。我使用此代码来解决此任务:
import numpy as np
import cv2
import glob
# termination criteria
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)
a = 7
b = 6
objp = np.zeros((b*a,3), np.float32)
objp[:,:2] = np.mgrid[0:a,0:b].T.reshape(-1,2)
# Arrays to store object points and image points from all the images.
objpoints = [] # 3d point in real world space
imgpoints = [] # 2d points in image plane.
images = glob.glob('*.jpg')
for fname …Run Code Online (Sandbox Code Playgroud) 我在 Iris 数据集上使用来自 sklearn 的支持向量分类器。当我调用 decision_function它时返回负值。但是分类后测试数据集中的所有样本都具有正确的类别。我认为当样本是内点时,decision_function 应该返回正值,如果样本是异常值,则应该返回负值。我错在哪里?
from sklearn import datasets
from sklearn.svm import SVC
from sklearn.model_selection import train_test_split
iris = datasets.load_iris()
X = iris.data[:,:]
y = iris.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.3,
random_state=0)
clf = SVC(probability=True)
print(clf.fit(X_train,y_train).decision_function(X_test))
print(clf.predict(X_test))
print(y_test)
Run Code Online (Sandbox Code Playgroud)
这是输出:
[[-0.76231668 -1.03439531 -1.40331645]
[-1.18273287 -0.64851109 1.50296097]
[ 1.10803774 1.05572833 0.12956269]
[-0.47070432 -1.08920859 -1.4647051 ]
[ 1.18767563 1.12670665 0.21993744]
[-0.48277866 -0.98796232 -1.83186272]
[ 1.25020033 1.13721691 0.15514536]
[-1.07351583 -0.84997114 0.82303659]
[-1.04709616 -0.85739411 0.64601611]
[-1.23148923 -0.69072989 1.67459938]
[-0.77524787 …Run Code Online (Sandbox Code Playgroud)