Posted: Thu Jul 21, 2011 9:45 am
Here is my piece of code:
Part 1: Get the images:
Part 2:
Part 3: (I know its ugly, but it worked )
Part 1: Get the images:
Code: Select all
$ ffmpeg -i a.mp4 -y -f image2 Yoga/output%04d.png
Part 2:
Code: Select all
#!/usr/bin/python
# -*- coding: utf-8 -*-
import numpy, sys
import os, glob
from subprocess import Popen, PIPE
from PIL import Image
path = '/home/moose/Desktop/challenges/Yoga/'
liste = [None for i in xrange(0, 415)]
for infile in glob.glob( os.path.join(path, '*.png') ):
number = infile.split("/")
number = number[-1].split(".")
number = number[0].split("utput")
number = int(number[1])
im = Image.open(infile)
im.show()
# from human import eyes
value = raw_input("0 oder 1: ")
liste[number] = value
print liste
Code: Select all
#!/usr/bin/python
# -*- coding: utf-8 -*-
from copy import deepcopy
def bin2dec(binary):
""" binary string to ascii letter """
if len(binary) != 8:
return False
dec = 0
for i in xrange(0, 8):
dec += 2**(7-i) * int(binary[i])
return dec
def choose(binaryList):
results = [binaryList]
for i in xrange(0, binaryList.count("-1")):
results_tmp = []
key = results[0].index("-1")
for el in results:
el1 = deepcopy(el)
el2 = deepcopy(el)
el1[key] = "0"
results_tmp.append(el1)
el2[key] = "1"
results_tmp.append(el2)
results = deepcopy(results_tmp)
return results
path = '/home/moose/Desktop/challenges/Yoga/'
liste = [None, '0', '1', '1', '1', '0', '1', '0', '0', #t 1 - 8
'0', '1', '1', '0', '1', '0', '0', '0', #h 9 - 16
'0', '1', '1', '0', '0', '1', '0', '1', #e 17 - 24
'0', '0', '1', '0', '0', '0', '0', '0', # 25 - 32
'0', '1', '1', '0', '0', '0', '0', '1', #a 33 - 40
'0', '1', '1', '0', '1', '1', '1', '0', #n 41 - 48
'0', '1', '1', '1', '0', '0', '1', '1', #s 49 - 56
'0', '1', '1', '1', '0', '1', '1', '1', #w 57 - 64
'0', '1', '1', '0', '0', '1', '0', '1', #e 72 - 80
'0', '1', '1', '1', '0', '0', '1', '0', #r 88 - 96
'0', '0', '1', '0', '0', '0', '0', '0', # 97 - 104
'0', '0', '1', '0', '0', '0', '0', '0', # 105 - 112
'0', '1', '1', '1', '0', '1', '0', '0', #t 113 - 120
'0', '1', '1', '0', '1', '0', '0', '0', #h 121 - 128
'0', '1', '1', '0', '1', '0', '0', '1', #i 129 - 136
'0', '1', '1', '1', '0', '0', '1', '1', #s 137 - 144
'0', '0', '1', '0', '0', '0', '0', '0', # 145 - 152
'0', '1', '1', '0', '0', '0', '1', '1', #c 153 - 160
'0', '1', '1', '0', '1', '0', '0', '0', #h 161 - 168
'0', '1', '1', '0', '0', '0', '0', '1', #a 169 - 176
'0', '1', '1', '0', '1', '1', '0', '0', #l 177 - 184
'0', '1', '1', '0', '1', '1', '0', '0', #l 185 - 192
'0', '1', '1', '0', '0', '1', '0', '1', #e 193 - 200
'0', '1', '1', '0', '1', '1', '1', '0', #n 201 - 208
'0', '1', '1', '0', '0', '1', '1', '1', #g 209 - 216
'0', '1', '1', '0', '0', '1', '0', '1', #e 217 - 224
'0', '0', '1', '0', '0', '0', '0', '0', # 225 - 232
'0', '1', '1', '0', '1', '0', '0', '1', #i 233 - 240
'0', '1', '1', '1', '0', '0', '1', '1', #s 241 - 248
'0', '0', '1', '0', '0', '0', '0', '0', # 249 - 256
'0', '0', '1', '0', '0', '1', '1', '1', #' 257 - 264
'0', '1', '1', '0', '0', '0', '0', '1', #a 265 - 272
'0', '1', '1', '1', '0', '0', '1', '1', #s 273 - 280
'0', '1', '1', '0', '0', '0', '0', '1', #a 281 - 288
'0', '1', '1', '0', '1', '1', '1', '0', #n 289 - 296
'0', '1', '1', '0', '0', '0', '0', '1', #a 297 - 304
'0', '0', '1', '0', '0', '1', '1', '1', #' 305 - 312
'0', '0', '1', '0', '1', '1', '1', '0', # 313 - 320
'0', '0', '-1', '0', '0', '-1', '-1', '-1', '0', '0', '-1',
'-1', '-1', '1', '1', '0', '0', '0', '1',
'0', '0', '0', '0', '0', '0', '-1', '-1',
'0', '-1', '1', '1', '-1', '0', '1', '1',
'0', '-1', '1', '0', '-1', '0', '-1', '-1',
'0', '1', '1', '0', '-1', '0', '1', '-1',
'0', '-1', '1', '0', '1', '0', '1', '-1',
'0', '-1', '-1', '0', '-1', '0', '-1', '1',
'0', '-1', '-1', '0', '-1', '0', '1', '-1',
'0', '1', '1', '0', '1', '0', '1', '1',
'0', '-1', '1', '0', '-1', '0', '1', '-1',
'0', '1', '1', '0', '1', '0', '1', '1',
'0', '-1', '-1', '0', '-1', '0', '-1', '-1',
'0', '-1', '-1']
smallLetters = range(97, 123)
bigLetters = range(65, 91)
digits = range(48, 58)
others = [32] #, 33, 34, 39,44,46,58]
validCharacters = []
for el in smallLetters:
validCharacters.append(el)
"""for el in bigLetters:
validCharacters.append(el)"""
"""for el in digits:
validCharacters.append(el)"""
for el in others:
validCharacters.append(el)
liste = liste[1:]
for i in xrange(0, len(liste)/8):
tmp = liste[8*i:8*i+8]
if "-1" not in tmp:
print chr(bin2dec("".join(tmp)))
else:
possibilityList = choose(tmp)
characters = [chr(bin2dec(el)) for el in possibilityList]
print characters