- Avoiding the use of ordinal() in an already-deployed enum
- Converting a recursive code to reverse a string into an iterative one in c++
- sensitize vars on form submit
- Are pure-bloods actually a distinct species from Muggles?
- Is this query nesting Right?? I am trying to connect 3 tables users,groups,users_groups?
- MSSQLServer Database Level Roles for Creating Tables
- Delete latest data from mongodb collection
- Getting an error ORA-00933 while using EXECUTE IMMEDIATE
- Rebuild transaction logs
- SQlite schema for table that contains server stats
- ExceptionConnection Timeout Expired.
- Oracle Internal Error
- How can I convert currency symbol to universal font?
- Typeface used in Garmin GPS device
- How to make a video of a counter e.g.100-1,000,000?
- What is a typical response from webserver for POST request?
- Is Tor used to perform hostile hacking?
- What are the new security features in Windows 10?
- Webauthn and TLS channel binding
- How to check hosted content for fraud?
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)