python中的IF语法错误
我在if语法中有一个错误python中的IF语法错误,python,Python,我在if语法中有一个错误 if(m.distance<0.75*n.distance): 我在做图像处理的项目 代码: while True: ret, QueryImgBGR=cam.read() QueryImg=cv2.cvtColor(QueryImgBGR,cv2.COLOR_BGR2GRAY) queryKP,queryDesc=detector.detectAndCompute(QueryImg,None) matches=fl
if(m.distance<0.75*n.distance):
- 我在做图像处理的项目
while True:
ret, QueryImgBGR=cam.read()
QueryImg=cv2.cvtColor(QueryImgBGR,cv2.COLOR_BGR2GRAY)
queryKP,queryDesc=detector.detectAndCompute(QueryImg,None)
matches=flann.knnMatch(queryDesc,trainDesc,k=2)
goodMatch=[]
for m,n in matches:
if(m.distance<0.75*n.distance):
goodMatch.append(m)
if(len(goodMatch)>MIN_MATCH_COUNT):
tp=[]
qp=[]
for m in goodMatch:
tp.append(trainKP[m.trainIdx].pt)
qp.append(queryKP[m.queryIdx].pt)
tp,qp=np.float32((tp,qp))
H,status=cv2.findHomography(tp,qp,cv2.RANSAC,3.0)
h,w=trainImg.shape
trainBorder=np.float32([[[0,0],[0,h-1],[w-1,h-1],[w-1,0]]])
queryBorder=cv2.perspectiveTransform(trainBorder,H)
cv2.polylines(QueryImgBGR,[np.int32(queryBorder)],True,(0,255,0),5)
else:
print "Not Enough match found- %d/%d"%(len(goodMatch),MIN_MATCH_COUNT)
cv2.imshow('result',QueryImgBGR)
if cv2.waitKey(10)==ord('q'):
break
cam.release()
cv2.destroyAllWindows()
分号用于终止语句,当出现在if语句中时,它将终止语句。它通常用于在同一行上编写多条语句,如
a=1;打印一份;c=3代码>您的错误是什么?如果条件为:欢迎使用StackOverflow,请留出一个空格。请阅读并遵循帮助文档中的发布指南。适用于这里。在您发布MCVE代码并准确描述问题之前,我们无法有效地帮助您。我们应该能够将您发布的代码粘贴到文本文件中,并重现您描述的问题。请检查并说明您使用的是Python2还是Python3。非常感谢。