def take_snapshot():
    number = random.randint(0, 100)
    videoCaptureObject = cv2.VideoCapture(0)
    result = True
    while (result):
        ret, frame = videoCaptureObject.read()
        imageName = "img" + str(number) + ".png"
        cv2.imwrite(imageName, frame)
        startTime = time.time
        result = False
    return imageName
    print("Snapshot Taken.")
    videoCaptureObject.release()
    cv2.destroyallWindows()
Beispiel #2
0
import cv2
import numpy as np
from matplotlib import pyplot as plt

img = cv2.imread('fade.jpg', 0)
img_1 = cv2.resize(img, (256, 256))
gamma = 1.25
img_2 = np.power(img_1, gamma)
gamma = 1.5
img_3 = np.power(img_1, gamma)
gamma = 1.75
img_4 = np.power(img_1, gamma)

cv2.imshow('input_image', img_1)
cv2.imshow('gamma 2', img_2)
cv2.imshow('gamma 3', img_3)
cv2.imshow('gamma 4', img_4)
cv2.waitKey(1000000)
cv2.destroyallWindows()
Beispiel #3
0
#template! what's that heck is it?

import cv2
import numpy as np
from matplotlib import pyplot as plt

img = cv2.imread('doodle.jpg')
img2 = img.copy()
template = cv2.imread('image.jpeg')

w, h = template.shape[1], template.shape[0]

res = cv2.matchTemplate(img, template, cv2.TM_CCOEFF)
min_val, max_val; min_loc, max_loc=cv2.minMaxLoc(res)
top_left= max_loc
bottom_right = (top_left[0]+w,top_left[1]+h)

cv2.rectangle(img, top_left, bottom_right, 255, 2)
cv2.imshow('original', img2)
cv2.imshow('template', template)
cv2.imshow('image', img)

cv2.waitKey(0)

cv2.destroyallWindows()