Yoga Message

Discussion of challenges you have already solved
moose
Posts: 67
Joined: Fri Jul 16, 2010 7:32 pm

Post by moose »

Here is my piece of code:

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
Part 3: (I know its ugly, but it worked ;-) )

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
User avatar
Hippo
Posts: 339
Joined: Sat Feb 01, 2014 12:05 am
Location: Praha 5

Post by Hippo »

I used some other party soft to convert it to 413 jpg's. Than I have tried to figure method how to distinguish 0 from 1. Finally I have croped the interesting region and added R,G and B "duplicates" for hopefully better readability.
Than I have put 8 images per row in irfanview preview and read ascii myself ... short enough ... and I myself read "the '&3wer to this challenge is 'asana'. ommm<tab>" with some other garbage. It would be difficult te teach OCR to read better than me...
avrrobot
Posts: 51
Joined: Fri Mar 04, 2011 2:54 pm
Location: Germany

Post by avrrobot »

I used Media Player Classic to view it frame by frame and automated it with a batch of points on the screen that my program scans. It then determines a threshold and via that whether it is a 0 or a 1. Then it moved to the next frame by simulating keypresses.
It was pretty quick to code, although it might have been faster to do it by hand.
But I need to have a bit of fun too :D
yourMom
Posts: 6
Joined: Sat Dec 18, 2010 9:58 pm
Location: Sofia

Post by yourMom »

Here are my steps to solve this challenge:

1) ffmpeg -ss 00:00:00 -t 00:00:16.56 -i a.mp4 -r 25.0 yoga%3d.jpg
2) for i in $(ls *.jpg); do gm convert $i -crop 40x70+0+0 $i; done;
3) split in 8 columns in explorer and read ascii
Post Reply