Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Webcam API w/ Filters and Adjustments
#25
(03-12-2025, 02:32 PM)madscijr Wrote:
(03-05-2025, 04:39 AM)vince Wrote: tranny kpop matrix mod

I did give this a try, nice! Video to ASCII in realtime! That was on my "to do" list!

Question - did you assign a brightness value to the different ASCII characters, or are they just arbitrarily selected?

I have been meaning to write a simple prog to go through the printable ASCII characters and for each, _PRINTSTRING it to the screen and count the pixels, the # being its "brightness", and save that score, then at the end sort them by score. Then the picture-to-ascii matches the brightness of each pixel (or a given block of pixels) to be approximated by an ASCII char, and does a lookup in the array to find a character with the corresponding brightness.

In the time it took me to write that explanation I could have finished the code, LOL, but it did help clarify it in my mind.
it does all of the above, yes

I have been meaning to write a simple prog to go through the printable ASCII characters and for each, _PRINTSTRING it to the screen and count the pixels, the # being its "brightness", and save that score,
Code: (Select All)
 for i=0 to n
    p(i).img = _newimage(8, 16, 32)

    _dest p(i).img
    _source p(i).img

    _printstring (0,0), chr$(i + 32)
    p(i).c = chr$(i + 32)

    sum = 0
    for y=0 to 16-1
    for x=0 to 8-1
        z = point(x, y)
        'pset (x, y), z

        if point(x,y)=_rgb(255,255,255) then sum = sum + 1
    next
    next

    p(i).d = sum
next

then at the end sort them by score.
Code: (Select All)
 for i=1 to ubound(p)
    j = i
    do while (j>0 and p(j-1).d > p(j).d)
        swap p(j), p(j-1)
        j = j - 1
    loop
next

Then the picture-to-ascii matches the brightness of each pixel (or a given block of pixels) to be approximated by an ASCII char, and does a lookup in the array to find a character with the corresponding brightness.
Code: (Select All)
     z = point(x*8 + 4, y*16 + 8)
    'z2 = point(x*8 + 4, y*16 + 4)

    r = _red(z)
    g = _blue(z)
    b = _green(z)

    c = 0.299*r + 0.587*g + 0.114*b
    c = (c/255)*n

also, madsci, i did not forget about the 3D glasses stuff, i'll get around to it one of these days -- it turned out to be truly mad science
Reply


Messages In This Thread
RE: Webcam API w/ Filters and Adjustments - by vince - 03-12-2025, 10:33 PM



Users browsing this thread: Steffan-68, 1 Guest(s)