Mensagens

A mostrar mensagens de dezembro, 2020

Criar imagens fragmentadas a partir de vídeos

import cv2 import os # Ler o vídeo cam = cv2.VideoCapture("jhs3504-la-justicia-social-es-injusta.mp4") try: # Criar uma pasta chamado imagens if not os.path.exists('imagenstiradas'): os.makedirs('imagenstiradas') # se não for criada, gerará erro except OSError: print('Erro: Criar uma pasta de imagens') # frame currentframe = 0 while (True): # Lendo a imagem ret, frame = cam.read() if ret: # se ainda houver vídeo, continue criando imagens name = './imagenstiradas/frame' + str(currentframe) + '.jpg' print('Criando...' + name) # escrevendo as imagens extraídas cv2.imwrite(name, frame) # aumentar o contador para que # mostre quantos quadros são criados currentframe += 1 else: break cam.release() cv2.destroyAllWindows()

Detectar caras em um vídeo

import cv2 face_cascade = cv2.CascadeClassifier( 'haarcascade_frontalface_default.xml' ) cap = cv2.VideoCapture( 0 ) while 1 : ret , img = cap.read() gray = cv2.cvtColor(img , cv2.COLOR_BGR2GRAY) faces = face_cascade.detectMultiScale(gray , 1.3 , 5 ) for (x , y , w , h) in faces: cv2.rectangle(img , (x , y) , (x + w , y + h) , ( 255 , 0 , 0 ) , 2 ) roi_gray = gray[y:y + h , x:x + w] roi_color = img[y:y + h , x:x + w] cv2.imshow( 'img' , img) k = cv2.waitKey( 30 ) & 0xff if k == 27 : break cap.release() cv2.destroyAllWindows()

Detectar caras em uma foto

Para baixar o haarcascade_frontalface_default.xml basta clicar aqui . Código relacionado: Detectar caras em um vídeo import cv2 faceCascade= cv2.CascadeClassifier( "haarcascade_frontalface_default.xml" ) img = cv2.imread( 'equipa.png' ) imgGray = cv2.cvtColor(img , cv2.COLOR_BGR2GRAY) faces = faceCascade.detectMultiScale(imgGray , 1.1 , 4 ) for (x , y , w , h) in faces: cv2.rectangle(img , (x , y) , (x+w , y+h) , ( 255 , 0 , 0 ) , 2 ) cv2.imshow( "Resultado" , img) cv2.waitKey( 0 )  

Baixar um vídeo do Youtube usando tkinter

Outras páginas relacionadas: 1. Fazer download baixa um vídeo Youtube 2.Retirar informação do vídeo do Youtube from pytube import YouTube from tkinter.filedialog import * from tkinter.messagebox import * from tkinter import * from threading import * file_size = 0 def completeDownload ( stream=None , file_path=None ): print ( "Download completo" ) showinfo( "Mensagem" , "O Vídeo já foi baixado" ) butao[ 'state' ] = "active" butao[ 'text' ] = "Download do Vídeo" urlFile.delete( 0 , END) def downloadProgresso ( stream=None , chunk=None , bytes_remaining= None ): percent =( 100 *((file_size-bytes_remaining)/file_size)) butao[ 'text' ] = "{:00.0f} % do download" .format(percent) def startDownload (url): global file_size path_to_save = askdirectory() if path_to_save is None : return try : yt = YouTube(url) st = yt.streams.first() yt.r...

Python Youtube (fazer download- baixa- do vídeo)

Outras códigos relacionados: 1.Baixar um vídeo do Yotube usando tkinter 2.Retirar informação do vídeo from pytube import YouTube # link do video yt = YouTube( "https://www.youtube.com/watch?v=QwqnRYPcrl0&t=88s" ) st =yt.streams.first() st.download()

Python Youtube (retirar informação do vídeo)

Códigos relacionados: 1.Download do vídeo de Youtube 2.Baixar um vídeo do Youtube usando tkinter   from pytube import YouTube # Fonte: https://python-pytube.readthedocs.io/ #en/latest/api.html?highlight=download#youtube-object # link do video yt = YouTube( "https://www.youtube.com/watch?v=QwqnRYPcrl0&t=88s" ) # Mostrar o título do vídeo print (yt.title) # Mostrar a descrição do Vídeo print (yt.description) # Mostrar o autor do vídeo print (yt.author) # Mostrar data do vídeo print (yt.publish_date) # Mostrar as vizualizações do vídeo print (yt.views) #Mostra a duração do vídeo em segundos. print (yt.length) # Mostra em URL uma imagem do vídeo. print (yt.thumbnail_url)  

Calcular IMC usando tkinter (versão melhorada)

from tkinter import * # Criando uma variavel para identificar a janela root = Tk() class imc(): def __init__ ( self ): self .root = root self .janela() self .desenho() # criando o Loop root.mainloop() def janela ( self ): self .root.title( "Calculadora do índice de massa corporal (IMC)" ) self .root.configure( background = '#B0C4DE' ) self .root.geometry( "450x150" ) self .root.resizable( True, True ) def desenho ( self ): self .quilos = DoubleVar() self .lb_quilos = Label( text = 'Peso (em Kg)' , font =( 'Verdana' , '8' , 'bold' ) , bg = '#D3D3D3' , fg = '#000000' ) self .lb_quilos.place( relx = 0.2 , rely = 0.05 , relwidth = 0.35 , relheight = 0.1 ) self .input_quilos = Entry( textv...

Calculadora de idade (usando tkinter-versão 2)

Outros Artigos relacionados Calculadora de idade simples Calculadora de anos  primeira versão  (usando tkinter ) from tkinter import * # Criando uma variavel para identificar a janela root = Tk() class calculadora_idade(): def __init__ ( self ): self .root = root self .janela() self .desenho() # criando o Loop root.mainloop() def janela ( self ): self .root.title( "Calculadora da idade" ) self .root.configure( background = '#B0C4DE' ) self .root.geometry( "400x150" ) self .root.resizable( True, True ) def desenho ( self ): self .datanascimento = IntVar() self .lb_datanascimento = Label( text = 'Ano de Nascimento' , font =( 'Verdana' , '8' , 'bold' ) , bg = '#D3D3D3' , fg = '#000000' ) self .lb_datanascimento.place( relx = 0.2 , ...

Calculadora de idade (usando tkinter)

Outros Artigos relacionados Calculadora de Anos (dá anos, mês e dias) Calculadora de idade simples Calculadora de anos versão melhorada (usando tkinter ) from tkinter import * from datetime import date # Criando uma variavel para identificar a janela root = Tk() class calculadora_idade(): def __init__ ( self ): self .root = root self .janela() self .desenho() # criando o Loop root.mainloop() def janela ( self ): self .root.title( "Calculadora da idade" ) self .root.configure( background = '#B0C4DE' ) self .root.geometry( "400x150" ) self .root.resizable( True, True ) def desenho ( self ): self .datanascimento = IntVar() self .lb_datanascimento = Label( text = 'Ano de Nascimento' , font =( 'Verdana' , '8' , 'bold' ) , bg = '#D3D3D3' , fg = '...

Calculadora de idade

Outros Artigos relacionados Calculadora de anos simples usando tkinter Calculadora de anos versão melhorada (usando tkinter ) from datetime import date current_date = date.today() data_nascimento= int ( input ( "Ano de nascimento:" )) data_actual = current_date.year idade =data_actual-data_nascimento print (idade)