Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # WORD NO WAR
- # NUOVA VERSIONE 19/03/2022
- # PER ATTIVARE IL CODICE CLICK SULLA FRECCETTA NERA A SINISTRA NELLA FINESTRA SUCCESSIVA
- # potete cambiare questi valori per cambiare il colore
- #schema del colore: (Blu,Verde,Rosso)
- # I VALORI DEI COLORI SI TROVANO IN : https://www.rapidtables.org/it/web/color/RGB_Color.html
- # ATTENZIONE: QUI I COLORI SONO IN RGB (ROSSO, VERDE, BLU)
- # QUANDO SI COPIANO I VALORI NEL CODICE QUI SOTTO BISOGNA RICORDARSI CHE QUI LO SCHEMA è: BLU, VERDE, ROSSO
- ######################## CAMBIANDO QUESTI VALORI SI OTTENGONO RISULTATI DIVERSI #####################################################
- ######################## 更改这些值的结果不同 #########################################################################################
- COLORE_1=(255,255,153) # (BLU, VERDE, ROSSO) # (蓝色、绿色、红色)
- COLORE_2=(0,255,0) # (BLU, VERDE, ROSSO) # (蓝色、绿色、红色)
- verso=-1 # con questo valore a -1 le macchie salgono anzichè scendere ### 当这个值为-1时,斑点会上升而不是下降。 ###
- ######################################################################################################################################
- if verso > 1:
- verso=1
- elif verso <-1:
- verso=-1
- import os
- S=os.system
- S('clear')
- # NON SON RIUSCITO A FARE FUNZIONARE : cv.destroyAllWindows()
- from google.colab import output
- import random
- import cv2 as cv
- import pandas as pd
- from google.colab.patches import cv2_imshow
- import requests
- import time
- import numpy as np
- DIR=os.listdir
- p=print
- vedi_G=cv2_imshow
- v=vedi_G # sul pc usare v=cv.imshow
- DIR()
- os.makedirs('test',exist_ok='True')
- #DIR()
- dy=80
- dx=10
- #loop1=100 # aumentando questo valore si aumentano le macchie rosse
- loop2=500
- def azione(im_test,refresh=0.5, loop1=1):
- y_max,x_max=im_test.shape[:2]
- for i in range (loop1):
- ############S('clear')
- im_da_vedere=im_test.copy()
- #output.clear()
- #############################v(im_da_vedere)
- #cv.waitKey()
- time.sleep(refresh)
- del(im_da_vedere)
- S('clear')
- cv.destroyAllWindows()
- ####################cv.pollKey() # da usare sul pc
- ################time.sleep(0.3)
- y=random.randint(100, (y_max-100))
- x=random.randint(100, (x_max-100))
- #p(y,x)
- for j in range(loop2):
- dx=random.randint(1,30)
- dy=random.randint(1,80)*verso
- if verso<0:
- Y=random.randint(y+dy,y)
- else:
- Y=random.randint(y, y+dy)
- X=random.randint(x, x+dx)
- if X<0:
- X=2
- if Y<0:
- Y=2
- try:
- im_test[Y,X]=COLORE_1
- #v(im_test)
- #time.sleep(.3)
- #cv.destroyAllWindows()
- except:
- p('err1')
- for j in range(loop2):
- dx=random.randint(1,15)
- dy=random.randint(1,120)*verso
- if verso<0:
- Y2=random.randint(Y+dy,Y)
- else:
- Y2=random.randint(Y, Y+dy)
- X2=random.randint(X, X+dx)
- if X2<0:
- X2=2
- if Y2<0:
- Y2=2
- if Y2>y_max:
- Y2=y_max-1
- X2=random.randint(X, X+dx)
- if X2>x_max:
- X2=x_max-1
- try:
- im_test[Y2,X2]=COLORE_2
- #v(im_test)
- #time.sleep(.3)
- #cv.destroyAllWindows()
- except:
- p('err2')
- return im_test
- # carico immagine PUTIN
- # definisco url con immagine
- image_url='https://imagizer.imageshack.com/img922/6258/HS0BOM.jpg'
- # definisco la fullpat dove voglio salvare l'immagine
- fl_dest_fullpat='test/Putin_06.jpg'
- import requests
- # METODO NOTEVOLE
- # USO IL MIO REPOSITORY DDI IMMAGINI imageshack
- # COPIO IL LINK DIRECT: IN QUESTO CASO: https://imagizer.imageshack.com/img922/6258/HS0BOM.jpg
- # LO UTILIZZO QUI IN QUESTO MODO CON requests
- # salvo il file sul mio hd
- # carico il file sul mio script
- # FATTO
- # da fare: TROVARE UN MODO DIRETTO SENZA PASSARE DA SALVATAGGIO SU DISCO
- # carico immagine da url
- ###image_url='https://imagizer.imageshack.com/img922/6258/HS0BOM.jpg'
- # URL of the image to be downloaded is defined as image_url
- r = requests.get(image_url) # create HTTP response object
- # send a HTTP request to the server and save
- # the HTTP response in a response object called r
- # salvo immagine recuperata da url in fl_dest_fullpat
- with open(fl_dest_fullpat,'wb') as f: # scrittura binaria
- # Saving received content as a png file in
- # binary format
- # write the contents of the response (r.content)
- # to a new file in binary mode.
- f.write(r.content)
- # Ora ho l'immagine nel mio hard disk
- # la posso caricare normalmente con cv.imread
- Immagine=cv.imread(fl_dest_fullpat)
- #FATTO
- #PERFETTO
- # quasi buono
- # TEST PUTIN
- # parametri per i cicli e per il random
- IM_PUTIN=Immagine.copy()
- y_max,x_max=(IM_PUTIN.shape[:2])
- p(y_max,x_max)
- y_max,x_max=(IM_PUTIN.shape[:2])
- IM_PUTIN_ELAB=IM_PUTIN[10:y_max-200,100:x_max-800]# ridimensionato
- #vedi_G(IM_PUTIN_ELAB)
- #v(IM_PUTIN_ELAB)
- ############# obsoleto ########### im_test=IM_PUTIN_ELAB.copy()
- #IM_PUTIN.shapeim_test=IM_PUTIN_ELAB_01.copy()
- ############# ZELENSKY ########################
- # ZELENSKY
- fl_dest_fullpat_zelensky='test/zelensky.jpg'
- image_url='https://imagizer.imageshack.com/img922/1461/JG7HGY.png'
- # URL of the image to be downloaded is defined as image_url
- r = requests.get(image_url) # create HTTP response object
- # send a HTTP request to the server and save
- # the HTTP response in a response object called r
- # salvo immagine recuperata da url in fl_dest_fullpat
- with open(fl_dest_fullpat_zelensky,'wb') as f: # scrittura binaria
- # Saving received content as a png file in
- # binary format
- # write the contents of the response (r.content)
- # to a new file in binary mode.
- f.write(r.content)
- # Ora ho l'immagine nel mio hard disk
- # la posso caricare normalmente con cv.imread
- Immagine=cv.imread(fl_dest_fullpat_zelensky)
- ymax=Immagine.shape[0]
- xmax=Immagine.shape[1]
- rid_x=xmax//4
- rid_y=ymax//10
- IM_ZELENSKY=Immagine[rid_y:ymax-rid_y,rid_x+rid_x//3:xmax-rid_x+rid_x//4]
- IM_ZELENSKY_ELAB=IM_ZELENSKY[10:-56,27:-27]
- ###############################################
- loop_tot=int(input("Numero di cicli desiderati (non esagerare COMINCIA CON 10): .... "))
- intervallo=float(input("Numero di secondi di intervallo (5-100): .... "))
- im_1=IM_PUTIN_ELAB
- im_2=IM_ZELENSKY_ELAB
- for k in range(loop_tot):
- #######################S('clear')
- im_1=azione(im_1,intervallo)
- im_2=azione(im_2,intervallo)
- im_tot=np.concatenate([im_1,im_2],axis=1)
- output.clear()
- v(im_tot)
- time.sleep(intervallo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement