def main(): vp = VideoPlayer('resources/video/field1/WideWide - Clip 001.mp4') frames = vp.extract_frames() #for frame in frames: hsv = cv2.cvtColor(frames[13], cv2.COLOR_BGR2HSV) if colors: cv2.putText(hsv, str(colors[-1]), (10, 50), cv2.FONT_HERSHEY_PLAIN, 2, (0, 0, 0), 2) cv2.imshow('frame', hsv) cv2.setMouseCallback('frame', on_mouse_click, hsv) cv2.waitKey() cv2.destroyAllWindows() # avgb = int(sum(c[0] for c in colors) / len(colors)) # avgg = int(sum(c[0] for c in colors) / len(colors)) # avgr = int(sum(c[0] for c in colors) / len(colors)) # print avgb, avgg, avgr minb = min(c[0] for c in colors) ming = min(c[1] for c in colors) minr = min(c[2] for c in colors) maxb = max(c[0] for c in colors) maxg = max(c[1] for c in colors) maxr = max(c[2] for c in colors) print(minr, ming, minb, maxr, maxg, maxb) lb = [minb, ming, minr] ub = [maxb, maxg, maxr] print(lb, ub)
import cv2 import numpy as np from VideoPlayer import VideoPlayer from VideoWriter import VideoWriter from LineDrawer import LineDrawer from Model import Model from LinePicker import LinePicker from ModelTransformer import ModelTransformer from HSVTrackbar import HSVPicker if __name__ == '__main__': vp = VideoPlayer( 'resources/video/field1/cliphd4.mp4') #inicializa com o caminho frames = vp.extract_frames( ) # abre o arquivo e retorna um vetor com os frames frames_with_line = [] # cria vetor com frames com linha field_lines_mask = [] # mascara das linhas do campo lp = LinePicker( frames[1] ) #abre o frame de número 1 para a escolha dos pontos (fp,sc) -apertar enter #copia e imprime os pontos first_point = lp.first_down_point scrimmage = lp.scrimmage_point print(first_point, scrimmage) HSV_LOW, HSV_HIGH, BLUR = HSVPicker(frames[1]).getHSVMask( ) #abre o seletor de filtros pro HSV e retorna os limites da máscara