I am trying to use OpenCVs feature detection on numpy arrays. Unfortunately OpenCV raises an error when I want to detect features:
error: OpenCV(4.0.1) C:\ci\opencv-suite_1573470242804\work\modules\imgproc\src\resize.cpp:3787: error: (-215:Assertion failed) inv_scale_x > 0 in function 'cv::resize'
I tried it in the context of a bigger project but my minimum working example is:
import cv2 as cv
import numpy as np
from numpy import random
import matplotlib.pyplot as plt
orb_parameters = dict(nfeatures=15000,scaleFactor=1.2,nlevels=30,firstLevel=0,WTA_K=2,scoreType=1,patchSize=20,fastThreshold=2)
descriptor = cv.ORB_create(**orb_parameters)
detector = descriptor
FLANN_INDEX_LSH = 6
index_params = dict(algorithm=FLANN_INDEX_LSH,table_nummer=6,key_size=12,multi_probe_level=1)
search_params = dict(checks = 50)
matcher = cv.FlannBasedMatcher(index_params,search_params)
np_scene = random.randint(0,255,(80,80),np.uint8)
np_query = random.randint(0,255,(80,80),np.uint8)
keypoints_query = detector.detect(np_query,None)
keypoints_scene = detector.detect(np_scene,None)
keypoints_query, descriptors_query = descriptor.compute(np_query, keypoints_query)
keypoints_scene, descriptors_scene = descriptor.compute(np_scene, keypoints_scene)
matches = matcher.knnMatch(descriptors_query,descriptors_scene,k=2)
drawnMatches = cv.drawMatches(np_query, keypoints_query, np_scene, keypoints_scene, matches)
plt.figure()
plt.imshow(drawnMatches)
plt.show()
Could somebody point me in the right direction on how to use the feature detection functionality of OpenCV with numpy arrays?