Liberty BASIC Community Forum
« JR codes ( thread jump from QR codes) »

Welcome Guest. Please Login or Register.
Aug 23rd, 2017, 8:15pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: JR codes ( thread jump from QR codes)  (Read 213 times)
tenochtitlanuk
Moderator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1161
xx JR codes ( thread jump from QR codes)
« Thread started on: Aug 30th, 2016, 2:50pm »

It is quite fun creating a SIMPLE image-based coding system.
Creating the code is the easy part. Reading it is MUCH harder.

Here's my quick attempt at the easy bit -
User Image
It's coded with

Code:
    nomainwin

    WindowWidth  =440
    WindowHeight =440

    open "JR code" for graphics_nsb as #wg

    #wg "trapclose [quit]"
    #wg "size 1 ; fill white ; color 210 210 210"

    message$    ="jzdjcj 1946 cxmvmvbmxm  ngf xyzzzy plugh foobar digame!"
    n           =1

    for i =0 to 24^2 -1 step 8
        c$          =mid$( message$, n, 1)
        a           =asc( c$)
        pAscBin$    =dec2bin$( a)
        n           =n +1
        x           =i mod 24
        y           =int( i /24)
        for j =1 to 8
            if mid$( pAscBin$, j, 1) ="1" then col$ ="red": #wg "color red" else col$ ="white": #wg "color white"
            #wg "backcolor "; col$
            #wg "up ; goto "; 80 +x*10 +j *10; " "; 80 +y *10; " ; down"
            #wg "boxfilled "; 90 +x*10 +j *10; " "; 90 +y *10
        next j

    next i

    #wg "backcolor cyan ; color cyan"
    #wg "up ; goto  50  40 ; down ; boxfilled  90  80"
    #wg "up ; goto 330  40 ; down ; boxfilled 370  80"
    #wg "up ; goto  50 320 ; down ; boxfilled  90 360"

    #wg "getbmp scr 0 0 430 410"
    bmpsave "scr", "JR.bmp"
    wait

    [quit]
    close #wg
    end

function dec2bin$( num)
   if num =0 then dec2bin$ ="00000000": exit function
    while num >0
        dec2bin$    =str$( num mod 2) +dec2bin$
        num=        int( num/2)
    wend
    dec2bin$ =right$( "00000000" +dec2bin$, 8)
end function
 

However the line I encoded is different from the message$ shown.
You can decode it quite easily by eye. Can you program it? ( change the gif to a bmp so LB can load it if you aren't used to making LB load gifs...

Of course in real life the image may be at different distances/sizes. May be blurred, rotated, trapezium-distorted. And no error correction is built in.
Even DETECTING that a code is in view is not trivial.
User Image

User Image What did this line read to produce the JR code above?
PS It just struck me that I ought to make it circular-symmetric- then orientation is not a problem....
« Last Edit: Aug 30th, 2016, 4:09pm by tenochtitlanuk » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls