我在实时相机捕获中使用 opencv 模板匹配,并收到错误消息:
error: (-215) _img.size().height <= _templ.size().height && _img.size().width <= _templ.size().width in function matchTemplate
Run Code Online (Sandbox Code Playgroud)
环境:
OpenCV: 3.4.1
Python3
Run Code Online (Sandbox Code Playgroud)
代码(是官网doc的例子,我只是替换了图片)
import cv2 as cv
import numpy as np
img_rgb = cv.imread('mybook.png')
img_gray = cv.cvtColor(img_rgb, cv.COLOR_BGR2GRAY)
template = cv.imread('book.jpg',0)
w, h = template.shape[::-1]
res = cv.matchTemplate(img_gray,template,cv.TM_CCOEFF_NORMED)
threshold = 0.8
loc = np.where( res >= threshold)
for pt in zip(*loc[::-1]):
cv.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0,0,255), 2)
cv.imwrite('res.png',img_rgb)
Run Code Online (Sandbox Code Playgroud)
我想知道我是否做错了什么?非常感谢!
我正在练习使用 cucmber.js 通过 BDD 编写一些单元测试。当我尝试使用“And”语句时。该错误表明
TypeError: And is not a function
Run Code Online (Sandbox Code Playgroud)
这是我的代码
。特征
Feature: dataTable
Scenario Outline: <a> + <b> + <c> = <answer>
Given I had number <a>
And I add another number <b>
When I add with <c>
Then I got answer <answer>
Examples:
|a|b|c|answer|
|1|2|3|6|
|10|15|25|50|
Run Code Online (Sandbox Code Playgroud)
.stepDefinition
defineSupportCode(function({Given,When,Then,And}){
let ans = 0;
Given('I had number {int}', function(input){
ans = input
})
And('I add another number {int}',function(input){
ans += input
})
When('I add with {int}',function(input){
ans += input …Run Code Online (Sandbox Code Playgroud)