def ValidateMcuCoordinate(self, oCoordinate): if oCoordinate.x < self.mcuInfo.min.x: if oCoordinate.y > self.mcuInfo.min.y: oCoordinate.y -= 1 oCoordinate.x = self.mcuInfo.max.x + oCoordinate.x - self.mcuInfo.min.x + 1 else: return coordinate(-1,-1) elif oCoordinate.x > self.mcuInfo.max.x: if oCoordinate.y < self.mcuInfo.max.y: oCoordinate.y += 1 oCoordinate.x = self.mcuInfo.min.x + oCoordinate.x - self.mcuInfo.max.x - 1 else: return coordinate(-1,-1) return oCoordinate
def __init__(self, img, c_coordinate): self.coordinate = img.ValidateMcuCoordinate(c_coordinate) self.pixel_coordinate = util.coordinate(self.coordinate.x * 8, self.coordinate.y * 8) self.filename = img.filename self.data = None self.GetStream(img)
def CompareResult(mcu_coordinate, img1, img2): score = cScore.RangeScore(img1.mcuInfo.testRange) for testOffset in range(img1.mcuInfo.testRange.min, img1.mcuInfo.testRange.max): test_coordinate = img1.ValidateMcuCoordinate( coordinate(mcu_coordinate.x + testOffset, mcu_coordinate.y)) score.AddScore(CompareMCU(test_coordinate, img1, img2)) return score
def ComparePixel(MCU1, MCU2): mcu_Score = cScore.MCUScore(MCU1.coordinate) for y_row1, y_row2 in zip(MCU1.data, MCU2.data): for x_col1, x_col2 in zip(y_row1, y_row2): pixel = cScore.PixelScore(coordinate(x_col1, y_row1)) for band1, band2 in zip(x_col1, x_col2): pixel.Add(math.fabs(band1 - band2) * 3) mcu_Score.AddScore(pixel) return mcu_Score
def __init__(self, pos = None, dir = None): if pos: self.position = util.coordinate(pos) else: self.position = C.DEFAULT_POSITION if dir: self.direction = dir else: self.direction = C.DEFAULT_DIRECTION self.touching = None
import math import time import util import matplotlib.pyplot as plt deltaT = 0.01 g = 9.80665 theta = 55 launch_velocity = 142 launch_theta = math.pi / 180 * theta t = 0 s = util.coordinate(0, 0, "s") v = util.coordinate(launch_velocity * math.cos(launch_theta), launch_velocity * math.sin(launch_theta), "v") a = util.coordinate(0, -g, "a") sXlist = [s.x] sYlist = [s.y] fig = plt.figure(figsize=(12, 9)) ax1 = fig.add_subplot(1, 1, 1) #print(theta, launch_velocity) while t < 1000: s.calculateD(v, deltaT) sXlist.append(s.x)
imgs_mod_folder = os.path.join("Reaper") #imgs_mod_folder = os.path.join("Reaper", "sombra_25b6c") #imgs_mod_folder = os.path.join("Reaper", "sombra_25b6c", "sombra_25b6c_04_25b6d") #imgs_mod_folder = os.path.join("Reaper", "sombra_25b6d") fix_folder = "Fix\\" imgs = ['\\' + 'tece_imgur', '\\' + 'sombra'] #imgs = ['\\'+'tece_imgur','\\'+ 'sombra_25b6c_04'] #imgs = ['\\'+'tece_imgur','\\'+ 'sombra_25b6c_04_25b6d_8b'] #imgs = ['\\'+'tece_imgur','\\'+ 'sombra']#_25b6d_8a'] extansion = '.jpg' Glitchs = Glitchs() #Glitchs.Add(Glitch(int("0x00025B6C", 0), coordinate(90,17)))# ['8a','8a','8a','8a','8a',]}) Glitchs.Add(Glitch(int("0x00025B6D", 0), coordinate(90, 17))) # ['8a','8a','8a','8a','8a',]}) #Glitchs.Add(Glitch(int("0x00025B6E", 0), coordinate(91,17)))# ['8a','8a','8a','8a','8a',]}) #Glitchs.Add(Glitch(int("0x00025D27", 0), coordinate(98,17)))# ['8a','8a','8a','8a','8a',]}) sombra_msg = SombraMessage() result = [] McuInfo = MCU_Info(coordinate(0, 0), coordinate(239, 137), MinMax(0, 2)) logFile = open('log_row' + '.txt', 'w') #logFile = open( imgs_mod_folder + imgs[1] +'_log_p_' + '%02x'%(Glitchs.glitch[0].GetGlitchAddress())+'_'+ str(Glitchs.glitch[0].GetGlitchCoordinate().x) +'_'+ str(McuInfo.testRange.max) + '.txt','w') ori_f = SombraImage(imgs_folder + imgs[0] + extansion, McuInfo) mod_f = SombraImage(imgs_mod_folder + imgs[1] + extansion, McuInfo) max_fix1 = 16 max_fix2 = 16 # for y_row in range(0,20):
BLOCK = '█' SPACE = '+' CAR = '@' CHAR_MAP = {0: SPACE, 1: BLOCK, 2: CAR} DEFAULT_DIRECTION = 2 DIRECTION_MAP = {0: 'North', 1: 'Northeast', 2: 'East', 3: 'Southeast', 4: 'South', 5: 'Southwest', 6: 'West', 7: 'Northwest' } DEFAULT_POSITION = coordinate(0, 0) # this is used to increment position based on the direction DIRECTION_TO_POSITION_MAP = {0: coordinate(0,1), 1: coordinate(1,1), 2: coordinate(1,0), 3: coordinate(1,-1), 4: coordinate(0,-1), 5: coordinate(-1,-1), 6: coordinate(-1,0), 7: coordinate(-1,1) }
import os from cImg import SombraImage from glitch import Glitch, Glitchs, SombraMessage, FixeGlitch from mcuPixelReader import MCU_Info from mcuPixelReader.compare import CompareRow from util import coordinate, MinMax logFile = open('log_row' + '.txt', 'w') imgs_folder = os.path.join("Reaper") imgs_mod_folder = os.path.join("Reaper") imgs = ['Reaper/tece_imgur', 'Reaper/sombra'] extansion = '.jpg' glitch = Glitch(int("0x00025B6D", 0), coordinate(90, 17)) McuInfo = MCU_Info(coordinate(0, 0), coordinate(239, 137), MinMax(0, 2)) ori_f = SombraImage(imgs[0] + extansion, McuInfo) mod_f = SombraImage(imgs[1] + extansion, McuInfo) max_fix1 = 16 max_fix2 = 16 glitchRes = [] if not glitch.AsFix(): for addres1 in range(0, max_fix1): for addres2 in range(0, max_fix2): tryfix = (addres1 * 16) + addres2
def CompareRow(mcu_y, img1, img2): score = cScore.RangeScore( util.MinMax(img1.mcuInfo.min.x, img1.mcuInfo.max.x)) for x_col in range(img1.mcuInfo.min.x, img1.mcuInfo.max.x): score.AddScore(CompareMCU(coordinate(x_col, mcu_y), img1, img2)) return score