You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!

What i have until now, is following your 2nd path(b), i append below. I only focus on the upper left "card" (25 fields with numbers)

I hoped to get around by simply doing a vertical "cut" through the left/right center of each cipher and compare this cut with a reference cut, which i stored for each number. "Compare" means: sum up the difference of each pixel of this "cut" between the reference and the actual cut. So in the end i have ten scalars (0..9) and the minim of this group should represent the hit.

Unfortunately the error-qoute is much to high

- having 24 fields (center-field excluded, sp 5x5-1) - having 44 ciphers (4 fields contain only one cypher) - and getting 13 errors (wrong cyphers) ... 13/44 = 30%

At the same time, i'm already close to my "personal limit" of about max 0,5 sec per field....therefore my last post, that i think it will last "too long". Becaus i would expect that you would have to compare much more pixel than i do now. Maybe time will increase to more than 2..3 sec per field ...and in that time one can do the input manually!

Further more i still don't have representative scans, all is based upon a screenshot, i.e. with absolut best alignment conditions...

brochi

Code:

GR.OPEN 255,0,0,0,,1 GR.COLOR 255,0,255,0,0

bmp$ = "bingo_1.png"

GR.BITMAP.LOAD bmp1, bmp$

offx = 10 offy = 10

GR.BITMAP.DRAW nn,bmp1,offx,offy

! Find initial corner ------------------- drad = 5 DO rad += drad FOR phi=2 TO 88 STEP 2 phir = TORADIANS(phi) px = rad*COS(phir) py = rad*SIN(phir) GR.GET.BMPIXEL bmp1, px,py,a,r,g,b GR.POINT nn,px+offx,py+offy IF r<5 THEN : GR.RENDER : ex=1 IF ex THEN F_N.BREAK NEXT IF ex THEN D_U.BREAK UNTIL rad >=100

py = ROUND(py) px = ROUND(px)

!Seach to next two horizontal lines towards "south" ------ FOR i=1 TO 2 py +=10 DO GR.GET.BMPIXEL bmp1, px+4,py++,a,r,g,b UNTIL r<200 NEXT

!Fine-adust left border ----------------- !...just from the hip -> has to be refined !! ------- px +=-2

! now we have the reference-point:lower-left of first number-field ! mark it with two circles --------- GR.COLOR 255,255,0,0,0 GR.CIRCLE nn, px+offx,py+offy,5 GR.CIRCLE nn, px+offx,py+offy,8 GR.RENDER !------------------------------------------

!------------------------------------------

!Find next lines to south -------------- LIST.CREATE n,lpy LIST.ADD lpy, py FOR i=1 TO 4 pyold= py py +=10 DO GR.GET.BMPIXEL bmp1, px+4,py++,a,r,g,b UNTIL r<200 LIST.ADD lpy, py dy += py-pyold GR.CIRCLE nn, px+offx,py+offy,4 NEXT ! dy is the average y-grid-size -- dy = ROUND(dy/4) PRINT dy !------------------------------------------

!Find next lines to east -------------- LIST.CREATE n,lpx LIST.ADD lpx, px FOR i=1 TO 4 pxold= px px +=10 DO GR.GET.BMPIXEL bmp1, px++,py-4,a,r,g,b UNTIL r<200 LIST.ADD lpx, px dx += px-pxold GR.CIRCLE nn, px+offx,py+offy,4 NEXT ! dx is the average x-grid-size -- dx = ROUND(dx/4) PRINT dx !------------------------------------------

compare: LIST.CREATE n,sums LIST.TOARRAY vals,vals[] ARRAY.SUM sum_vals, vals[] : PRINT "sum_vals: "; sum_vals ARRAY.LENGTH nval, vals[] !ARRAY.LENGTH n_0, _0[] !PRINT nval,n_0 FOR i=1 TO nval :sum+=vals[i]-_0 [i]:NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval :sum+=vals[i]-_1 [i]:NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval :sum+=vals[i]-_2 [i]:NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval :sum+=vals[i]-_3 [i]:NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval :sum+=vals[i]-_4 [i]:NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval :sum+=vals[i]-_5 [i]:NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval :sum+=vals[i]-_6 [i]:NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval :sum+=vals[i]-_7 [i]:NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval :sum+=vals[i]-_8 [i]:NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval :sum+=vals[i]-_9 [i]:NEXT:LIST.ADD sums,sum:sum=0 PRINT "----" minsum=1e20 FOR i=0 TO 9 LIST.GET sums,i+1,tmp IF ABS(tmp)<minsum THEN minsum=ABS(tmp): hit=i PRINT INT$(i);" : ";tmp NEXT PRINT "hit: "; hit RETURN

!----------------------------- cut: LIST.CLEAR charFun LIST.CLEAR vals rxdx = center *dx FOR i=5 TO dy-5 STEP 2 GR.GET.BMPIXEL bmp2, rxdx ,i, a,r,g,b LIST.ADD charFun, i*10, -255+r LIST.ADD vals, -255+r out$ += STR$(-255+r)+"," NEXT CLIPBOARD.PUT out$

UNDIM vals[] LIST.TOARRAY vals,vals[]

RETURN !-----------------------------

!----------------------------- findCenter: FOR relx = leStart TO 1 STEP 0.01 GOSUB weight : IF weight>500 THEN left = relx : F_N.BREAK NEXT FOR relx = reStart TO 0 STEP -0.01 GOSUB weight : IF weight>500 THEN right = relx : F_N.BREAK NEXT center = (right- left)/2+left !PRINT left, right, center RETURN !-----------------------------

!----------------------------- weight: rxdx = relx *dx !GR.LINE nn , ox + rxdx, oy, ox+ rxdx, oy+dy weight =0 FOR i=5 TO dy-5 STEP 2 GR.GET.BMPIXEL bmp2, rxdx ,i, a,r,g,b weight += 255-r NEXT %print relx, weight RETURN !------------------------------ !------------------------------ numberCount: minWeight = 999999 dblNumber = 0 FOR relx = 0.44 TO 0.56 STEP 0.02 GOSUB weight IF weight< minWeight THEN minWeight= weight: posMinWeight=relx NEXT IF minWeight<300 THEN dblNumber =1 RETURN !------------------------------

I found my error....i just had to use the ABS() values while calculating the differences between the 10 compare functions with my actual function. Error-rate is =0% then. So, who wants to proof/test, would just have to replace the relevant part of the "compare" subroutine (see below).

With this i get about 8.5 sec for one card (24fields/44ciphers). Rounding up to 10 sec. for searching of each card, i would guess 1 min per sheet is realistic. But only under this best alignment-conditions....! (but it seems to be obselet now anyway....just for fun)

brochi

Code:

compare: LIST.CREATE n,sums LIST.TOARRAY vals,vals[] ARRAY.SUM sum_vals, vals[] : PRINT "sum_vals: "; sum_vals ARRAY.LENGTH nval, vals[] !ARRAY.LENGTH n_0, _0[] !PRINT nval,n_0 FOR i=1 TO nval:sum+=ABS(vals[i]-_0 [i]):NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval:sum+=ABS(vals[i]-_1 [i]):NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval:sum+=ABS(vals[i]-_2 [i]):NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval:sum+=ABS(vals[i]-_3 [i]):NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval:sum+=ABS(vals[i]-_4 [i]):NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval:sum+=ABS(vals[i]-_5 [i]):NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval:sum+=ABS(vals[i]-_6 [i]):NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval:sum+=ABS(vals[i]-_7 [i]):NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval:sum+=ABS(vals[i]-_8 [i]):NEXT:LIST.ADD sums,sum:sum=0 FOR i=1 TO nval:sum+=ABS(vals[i]-_9 [i]):NEXT:LIST.ADD sums,sum:sum=0 PRINT "----" minsum=1e20 FOR i=0 TO 9 LIST.GET sums,i+1,tmp IF ABS(tmp)<minsum THEN minsum=ABS(tmp): hit=i PRINT INT$(i);" : ";tmp NEXT PRINT "hit: "; hit RETURN

Here also possible solution for detecting/correcting an angular offset (below). For testing, the bingo-sheet is drawn with an artificial rotation (rotrnd) and this is detected afterwards. Most attempts have accurary of 0.1 degree or better.

- could also easily be used for detecting of 6- or 4- card sheet, simply by the ratio of line-lengthes of red/green - could be easily enhenced to determine upper left corner (calculation crosspoint of the two lines)

GR.RENDER : pause 500 DO : GR.TOUCH tou,tc,ty: UNTIL tou

END

!----------------- search : DO rad += drad FOR phi=phis TO phie STEP _dir*drad/rad*4 phir = TORADIANS(phi) px = rad*COS(phir) + offsx py = rad*SIN(phir) + offsy GR.GET.BMPIXEL bmp1, px,py,a,r,g,b GR.POINT nn,px,py IF r<128 THEN ex=1 : F_N.BREAK NEXT GR.RENDER UNTIL ex RETURN !--------------

I'm still trying to understand your code. I like the idea of doing it native in BASIC! I wrote code to do something similar. I defined a standard number array with each number being a set of pixels of 5 X 8. I requested the number of boards across and down. Knowing the height and width of the image and the number of bingo boards across and down, I found those x y blocks for each square. Then I compared that block to the standard defined 5 x 8 array. It added the hits equal to the standard array and the max hits would give you the possible number.

Users browsing this forum: No registered users and 3 guests

You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum