- Bash compound substring expansion
- Squid proxy with negative speed increase
- Installing Kali 2018.2 on Raspberry Pi Zero W
- gnome-shell error log
- How does ssh handle 2 computers on the local network with the same username?
- Why can't I ping my Centos7 VM running on VMPlayer?
- Running local shell script on multiple remote server in parallel and get the status
- Filter separated paragraphs according to their first word?
- Why is ls -i slower than ls?
- What are the pros & cons of removing login screen on app launch?
- Erupted in violence
- Using prepositions and conjunctions in a sentence
- Use of 'in pair' or 'in group' in a sentence
- What is the idiom 'what more could one ask for' in American English?
- Camouflage but not quite… like zebras
- Why native speakers use “Could” in this sentence: “It’s too sour. I couldn’t take it anymore.”
- Is this correct usage of “prefer of”
- Is it safe if I rely “only” on mutual funds for retirement planning?
- How to enter loans made, loans received, and capital contributions in GnuCash?
- Embedding an eps image into LaTeX
Motor driving using template matching using python and opencv on Rapberry pi
I want to drive a motor when my template is matched, I have written code of template matching but can't figure out how to drive the motor with it.
This is my code:
import numpy as np
import matplotlib.pyplot as plt
import RPi.GPIO as GPIO # Import the GPIO library.
import time # Import time library
GPIO.setup(12, GPIO.OUT) # Set GPIO pin 12 to output mode.
pwm = GPIO.PWM(12, 100)
cap = cv2.VideoCapture(0) #Webcam Capture
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
template = cv2.imread('gate.jpg',0)
w, h = template.shape[::-1]
res = cv2.matchTemplate(gray,template,cv2.TM_CCOEFF_NORMED)
threshold = 0.8
loc = np.where(res>threshold)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
top_left = min_loc
bottom_right = (top_left+w,top_left+h)