当我运行我的python代码
import numpy as np
import cv2
import matplotlib.pyplot as plt
img1 = cv2.imread('/home/shar/home.jpg',0) # queryImage
img2 = cv2.imread('/home/shar/home2.jpg',0) # trainImage
# Initiate SIFT detector
sift = cv2.xfeatures2d.SIFT_create()
# find the keypoints and descriptors with SIFT
kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None)
# BFMatcher with default params
bf = cv2.BFMatcher()
matches = bf.knnMatch(des1,des2, k=2)
# Apply ratio test
good = []
for m,n in matches:
if m.distance < 0.75*n.distance:
good.append([m])
# cv2.drawMatchesKnn expects list of lists as matches. …Run Code Online (Sandbox Code Playgroud) 当我运行我的python代码
import numpy as np
import cv2
import matplotlib.pyplot as plt
img1 = cv2.imread('/home/shar/home.jpg',0) # queryImage
img2 = cv2.imread('/home/shar/home2.jpg',0) # trainImage
# Initiate SIFT detector
orb = cv2.ORB()
# find the keypoints and descriptors with SIFT
kp1, des1 = orb.detectAndCompute(img1,None)
kp2, des2 = orb.detectAndCompute(img2,None)
# create BFMatcher object
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
# Match descriptors.
matches = bf.match(des1,des2)
# Sort them in the order of their distance.
matches = sorted(matches, key = lambda x:x.distance)
# Draw first 10 matches.
img3 …Run Code Online (Sandbox Code Playgroud) 下面是我用于跟踪白色对象的python代码.
它工作 - 但只有几秒钟然后整个屏幕变黑,有时它不起作用.
我尝试了蓝色并且它有效 - 但白色和绿色给我带来了问题:
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
while(1):
_, frame = cap.read()
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
# define range of white color in HSV
# change it according to your need !
sensitivity = 15
lower_white = np.array([0,0,255-sensitivity])
upper_white = np.array([255,sensitivity,255])
# Threshold the HSV image to get only white colors
mask = cv2.inRange(hsv, lower_white, upper_white)
# Bitwise-AND mask and original image
res = cv2.bitwise_and(frame,frame, mask= mask)
cv2.imshow('frame',frame)
cv2.imshow('mask',mask)
cv2.imshow('res',res)
k …Run Code Online (Sandbox Code Playgroud) 我正在使用ORB python opencv匹配功能,但当我运行此代码时,我得到此错误Traceback(最近一次调用最后):文件"ffl.py",第27行,in为m,n匹配:TypeError:'cv2 .DMatch'对象不可迭代
我不知道如何解决它
import numpy as np
import cv2
import time
ESC=27
camera = cv2.VideoCapture(0)
orb = cv2.ORB_create()
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
imgTrainColor = cv2.imread('/home/shar/home.jpg')
imgTrainGray = cv2.cvtColor(imgTrainColor, cv2.COLOR_BGR2GRAY)
kpTrain = orb.detect(imgTrainGray,None)
kpTrain, desTrain = orb.compute(imgTrainGray, kpTrain)
firsttime = True
while True:
ret, imgCamColor = camera.read()
imgCamGray = cv2.cvtColor(imgCamColor, cv2.COLOR_BGR2GRAY)
kpCam = orb.detect(imgCamGray,None)
kpCam, desCam = orb.compute(imgCamGray, kpCam)
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = bf.match(desCam,desTrain)
good = []
for m,n in matches:
if m.distance < 0.7*n.distance:
good.append(m)
if …Run Code Online (Sandbox Code Playgroud) 在我的opencv3 Python3代码下方查找以匹配引发以下错误的对象:
类型错误:由名称 ('k') 和位置 (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)
Run Code Online (Sandbox Code Playgroud)
关于如何解决它的想法?
i have my paypal ssl certificate for the paypal ipn added for my code like that and it working without any problems
var httpsOptions = {
key: fs.readFileSync('./app/certsandkeys/my-prvkey.pem'),
cert: fs.readFileSync('./app/certsandkeys/my-pubcert.pem'),
requestCert: true
//pfx: fs.readFileSync('./app/certsandkeys/ssl/crt.pfx'),
//passphrase:"password"
}
https.createServer(httpsOptions, app).listen(443,function (req,res) {
console.log("server listening on port " + 443);
});
Run Code Online (Sandbox Code Playgroud)
but what i need now is to certificating my whole site so i created an ssl cert and key using openssl (server.crt and server.csr and server.key ) but now i don't know …
我使用pip安装了matplotlib lib,但是当我运行此代码时,它给了我这个错误:
shar@shar-Lenovo-G50-30 ~ $ python3 opencv.py
Traceback (most recent call last):
File "opencv.py", line 3, in <module>
from matplotlib import pyplot as plt
ImportError: cannot import name 'pyplot'
Run Code Online (Sandbox Code Playgroud)
我的代码是:
import numpy as np
import cv2
from matplotlib import pyplot as plt
img1 = cv2.imread('/home/shar/home.jpg',0) # queryImage
img2 = cv2.imread('/home/shar/home2.jpg',0) # trainImage
# Initiate SIFT detector
orb = cv2.ORB()
# find the keypoints and descriptors with SIFT
kp1, des1 = orb.detectAndCompute(img1,None)
kp2, des2 = orb.detectAndCompute(img2,None)
# create BFMatcher object
bf …Run Code Online (Sandbox Code Playgroud) 当我使用make commande我得到这个错误
[ 24%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_QT.cpp.o
In file included from /home/sharkawey/op/opencv-master/modules/highgui/src/window_QT.cpp:47:0:
/home/sharkawey/op/opencv-master/modules/highgui/src/window_QT.h:46:20: fatal error: QtOpenGL: No such file or directory
#include <QtOpenGL>
^
compilation terminated.
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_QT.cpp.o] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make: *** [all] Error 2
Run Code Online (Sandbox Code Playgroud)
我用这个命令编译opencv
cmake -D CMAKE_BUILD_TYPE=RELEASE -D INSTALL_C_EXAMPLES=ON
-D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON
-D WITH_QT=ON -D CMAKE_INSTALL_PREFIX=/usr/local
-D WITH_OPENGL=ON -D WITH_V4L=ON
-D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_TBB=ON ..
Run Code Online (Sandbox Code Playgroud)
但是问题还在这里