我完全按照这个简单的OpenCV特征匹配示例:
import cv2
img = cv2.imread('box.png',0) # queryImage
orb = cv2.ORB() # Initiate ORB detector
# find the keypoints and descriptors with ORB
kp1, des1 = orb.detectAndCompute(img, None)
Run Code Online (Sandbox Code Playgroud)
并收到以下错误:
TypeError: Incorrect type of self (must be 'Feature2D' or its derivative)
Run Code Online (Sandbox Code Playgroud)
我正在使用OpenCV 3.3.1
我试图将其从 C++ 转换为 Python,但它给出了不同的色调结果。
在 C++ 中:
/// Transform it to HSV
cvtColor( src, hsv, CV_BGR2HSV );
/// Use only the Hue value
hue.create( hsv.size(), hsv.depth() );
int ch[] = { 0, 0 };
mixChannels( &hsv, 1, &hue, 1, ch, 1 );
Run Code Online (Sandbox Code Playgroud)
我在Python中尝试过这个:
# Transform it to HSV
hsv = cv2.cvtColor(src, cv2.COLOR_BGR2HSV)
# Use only the Hue value
hue = np.zeros(hsv.shape, dtype=np.uint8)
ch = [0] * 2
cv2.mixChannels(hsv, hue, ch)
Run Code Online (Sandbox Code Playgroud) 我正在使用 Cmake 浏览目录中的所有 .py 文件,并使用 Pylint 检测错误和检查编码标准。
有没有办法让我检查是否使用 cmake 安装了 Pylint?这段代码是否独立于操作系统(例如对于 Ubuntu 和 Windows)?
我想在下图中裁剪圆圈:
我的代码,我能够检测到圆圈但不能裁剪它:
import cv2
#import cv2.cv as cv
img1 = cv2.imread('amol.jpg')
img = cv2.imread('amol.jpg',0)
gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(gray, 50, 255, cv2.THRESH_BINARY)
edges = cv2.Canny(thresh, 100, 200)
#cv2.imshow('detected ',gray)
cimg=cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
circles = cv2.HoughCircles(edges, cv2.HOUGH_GRADIENT, 1, 10000, param1 = 50, param2 = 30, minRadius = 0, maxRadius = 0)
for i in circles[0,:]:
i[2]=i[2]+4
cv2.circle(img1,(i[0],i[1]),i[2],(0,255,0),2)
#Code to close Window
cv2.imshow('detected Edge',img1)
cv2.waitKey(0)
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud) 我想在一行中将从函数返回的值转换为int但当我尝试时出现以下错误:
TypeError: int() argument must be a string or a number, not 'tuple'
Run Code Online (Sandbox Code Playgroud)
我的代码如下:
def test_func():
return 3.4, 3.5
a, b = int(test_func())
print a , b
Run Code Online (Sandbox Code Playgroud) 这更多的是一个基本问题,而不是一个有用的问题,但就这样吧。
根据 C++ 标准,后缀表达式(例如v[i])优先于一元表达式(例如--i)。因此,我想知道程序执行此语句所遵循的实际步骤顺序是什么v[--i] = 100;。
std::vector<int> v = {0, 200};
int i = 1;
v[--i] = 100; // {100, 200}
Run Code Online (Sandbox Code Playgroud)
考虑到上述优先级,程序是否首先访问向量的元素 200,然后才发生减量,指向 0,然后再将其更改为 100?