Esempio n. 1
0
def cria_circulo(imagem, centro, r, cor, espessura):
    imagem = np.ones((300, 400, 3), np.uint8) * 255
    cv2.circle(imagem, centro, r, cor, espessura)
    cv2.imshow("Imagem", imagem)
    cv2.waitKey(0)
    cv2.destryAllWindows()
    return imagem
Esempio n. 2
0
def recortar_imagem(imagem):
    imagem = cv2.imread(imagem)
    imCrop = imagem[40:300, 40:400]
    cv2.imshow("ROI", imCrop)
    cv2.waitKey(0)
    cv2.destryAllWindows()

    return imagem
Esempio n. 3
0
def deslocar_imagem(imagem):
    altura, largura = imagem.shape[:2]
    deslocamento = np.float32([[1, 0, 25], [0, 1, 50]])
    deslocado = cv2.warpAffine(imagem, deslocamento, (altura, largura))
    cv2.imshow("Deslocado", deslocado)
    cv2.waitKey(0)
    cv2.destryAllWindows()

    return imagem
Esempio n. 4
0
def callback(data):
    bridge = CvBridge()
    try:
        cv_img = bridge.imgmsg_to_cv2(data, desired_encoding='passthrough')
    except CvBridgeError as e:
        print(e)
    cv2.imshow("image window", cv_img)
    cv2.waitKey(0)
    cv2.destryAllWindows()
Esempio n. 5
0
def rotacionar_imagem(imagem):
    imagem = cv2.imread(imagem)
    (altura, largura) = imagem.shape[:2]
    centro = (largura / 2, altura / 2)  # formato (x,y)
    mat = cv2.getRotationMatrix2D(centro, 90, 1.0)
    imagem_rotacionada = cv2.warpAffine(imagem, mat, (largura, altura))
    cv2.imshow("Imagem Rotacionada em 90 Graus", imagem_rotacionada)
    cv2.waitKey(0)
    cv2.destryAllWindows()

    return imagem
Esempio n. 6
0
def cria_poligono(imagem, pts, cor):
    pts = np.array(imagem)  # Cria lista de pontos.
    pts = pts.reshape(
        (-1, 1, 2))  # ajusta o formato do vetor de pontos para coluna unica.
    fechar = True
    pts = np.array([[50, 55], [130, 140], [150, 120], [100, 50]], np.int32)
    pts = pts.reshape(
        (-1, 1, 2))  # ajusta o formato do vetor de pontos para coluna unica.
    cv2.polylines(imagem, [pts], True, (0, 255, 0))
    cv2.imshow("Imagem", imagem)
    cv2.waitKey(0)
    cv2.destryAllWindows()

    return imagem
Esempio n. 7
0
def redimencionar_imagem(imagem):
    imagem = cv2.imread(imagem)
    #cv2.imshow("Original", imagem)
    escala = 1.5
    nova = cv2.resize(imagem,
                      None,
                      fx=escala,
                      fy=escala,
                      interpolation=cv2.INTER_AREA)
    cv2.imshow("Imagem em Escala 1,5X", nova)
    cv2.waitKey(0)
    cv2.destryAllWindows()

    return imagem
Esempio n. 8
0
def pedir_recortar(imagem):
    imagem = cv2.imread(imagem)
    pedido = int(
        input(
            "Digite o retangulo a ser recortado\n 1 para retangulo maior\n 2 retangulo menor\n escolha: "
        ))
    if pedido == 1:
        pedido = imCrop = imagem[40:300, 40:400]
    elif pedido == 2:
        pedido = imCrop = imagem[20:150, 20:200]
    cv2.imshow("ROI", pedido)
    cv2.waitKey(0)
    cv2.destryAllWindows()

    return imagem
Esempio n. 9
0
def main():

    img1 = np.zeros((512, 512, 3), np.uint8)
    windowName = 'OpenCv BGR color pallete'
    cv2.namedWindow(windowName)

    cv2.createTrackbar('B', windowName, 0, 255, emptyFunction)
    cv2.createTrackbar('G', windowName, 0, 255, emptyFunction)
    cv2.createTrackbar('R', windowName, 0, 255, emptyFunction)

    while (True):
        cv2.imshow(windowName, img1)

        if cv2.waitKey(1) == 27:
            break

        blue = cv2.getTrackbarPos('B', windowName)
        green = cv2.getTrackbarPos('G', windowName)
        red = cv2.getTrackbarPos('R', windowName)

        img1[:] = [blue, green, red]
        print(blue, green, red)

    cv2.destryAllWindows()
Esempio n. 10
0
        cv2.rectangle(image, refPt[0], refPt[1], (0, 255, 0), 2)
        cv2.imshow("image", image)


ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help="Path to the image")
args = vars(ap.parse_args())

image = cv2imread(args["image"])
clone = image.copy()
cv2.namedWindow("image")
cv2.setMouseCallback("image", click_and_crop)

while True:
    cv2.imshow("image", image)
    key = cv2.waitKey(1) & 0xFF

    if key == ord("r"):
        image = clone.copy()

    elif key == ord("c"):
        break

if len(refPt) == 2:
    roi = clone[refPt[0][1]:refPt[1][1], refPt[0][0]:refPt[1][0]]
    cv2.imshow("ROI", roi)
    cv2.waitKey(0)

cv2.destryAllWindows()
Esempio n. 11
0
import pytesseract
from PIL import Image
import cv2 as cv
import numpy as np
import sys

img = cv.imread('payment.jpg', 0)
kernel = np.ones((1, 1), dtype="uint8")
img = cv.erode(img, kernel, iterations=1)
img = cv.threshold(img, 0, 255, cv.THRESH_BINARY | cv.THRESH_OTSU)[1]
img = cv.medianBlur(img, 3)

cv.imshow('image', img)
cv.waitKey(0)
cv.destryAllWindows()
Esempio n. 12
0
def criar_hist_dados(imagem, idades, bins):
    plt.hist(idades, bins)
    plt.show()
    cv2.destryAllWindows()

    return imagem
Esempio n. 13
0
def carregar_imagem(imagem):
    imagem = cv2.imread(imagem)
    cv2.imshow("Cachorro", imagem)
    cv2.waitKey(0)
    cv2.destryAllWindows()
    return imagem
	    data = urllib.urlencode({'row_id' : (curr_idx + 1),
				 'available' : (curr_parking_lot_row.empty_spaces),
				 'update' : 'update'})
	    content = urllib2.urlopen(url=url, data= data).read()
	    #print content



	    #print out some stats
	    print('found {0} cars and {1} empty space(s) in row {2}'.format(
	        curr_parking_lot_row.total_spaces - curr_parking_lot_row.empty_spaces,
	        curr_parking_lot_row.empty_spaces,
	        curr_idx +1))

	    curr_idx += 1

#plot some figures
#plt.show()

	parking_rows = []

	#if the 'q' key is pressed, stop the loop
	if cv2.waitKey(1) & 0xFF == ord("q"):
		break;
	time.sleep(5)
#cleanup the camera and close any open window
camera.release()
cv2.destryAllWindows()