Command Line Webcam?

Поделиться
HTML-код
  • Опубликовано: 4 янв 2025

Комментарии • 115

  • @tophy43
    @tophy43 5 лет назад +23

    Even though the colors are not perfect, it's most likely the craziest thing someone has ever done using the standard windows command promt. I love it, anyway.

  • @skyhorn9070
    @skyhorn9070 7 лет назад +45

    friggin awesome! you do things and show how they work from ground-up! i've never imagined that i would see webcam working in the CMD! Love it

    • @javidx9
      @javidx9  7 лет назад +2

      Lol thanks Skyhorn! But I refer you to a previous comment "it is decidedly awe-less! :-D To Be Improved..."

  • @eformance
    @eformance 6 лет назад +27

    A symbolic way of using a union to access the RGB values would be like this:
    struct _rgb {
    unsigned char x, r, g, b;
    };
    union {
    int pixel;
    struct _rgb color;
    } RGB;
    Then use RGB.color.r to access red, RGB.color.g to access green, and RGB.color.b to access blue. This gives the pixel data symbolic format.

  • @harleyspeedthrust4013
    @harleyspeedthrust4013 4 года назад +23

    I was expecting bitshifting at 7:00, but I've never seen unions and I really like this way of doing it. Thanks David!

    • @andreaprovasi9786
      @andreaprovasi9786 4 года назад +3

      TOTALLY expecting bit mask & shift too but been blown away by this union trick, Awesome!

  • @andrewdunbar828
    @andrewdunbar828 5 лет назад +7

    Back in the late '90s I wrote a console GIF viewer. I can't remember how I chose the colours for each character block but I was taken aback by how convoluted your method was. I'm guessing I precomputed an RGB value for each character based on its black to white pixel ratio and used Euclidian distance to find the closest match from an image pixel colour to a possible character block colour pair and character. Then again I used to avoid square roots and I was using all printable characters, not just the five greyscale blocks.

  • @nonchip
    @nonchip 4 года назад +1

    btw HSV is hue/saturation/value, with luminance going all the way up to white along its axis of the cylindrical colour space, while value is only white where the saturation is 0. essentially max saturation of a colour would be at L=0.5 but V=1. so HSV cuts off the "upper half" of luminance where it begins to tint to white despite the saturation.
    wikipedia sums it up nicely: "HSV models how paints mix together, while HSL resembles perceptual colours" (as in: V=1 = more vibrant colour, L=1 = brighter light)

  • @goshisanniichi
    @goshisanniichi 5 лет назад +7

    I'd've gone backwards. Start w/ the console color and character and determine the resulting rgb color, i.e.: 25% Red + %75 Cyan = rgb( 63, 191, 191 ) and create a 3D lookup table and use some version k-nearest means or some similar classification algorithm to select the appropriate one.

  • @sfl1986
    @sfl1986 4 года назад +1

    i shed a tear over the Grim Fandango poster

  • @spjewkes
    @spjewkes 7 лет назад +6

    Nice video. I like the idea of getting three colours into just a foreground and background colour. I was wondering if you'd considered spreading the RGB values across more than one 'pixel'? Although I guess the resolution of the console is so low that the eye wouldn't really blend anything together in the way I'd expect. Hopefully, you'll post up a future video when/if you improve your algorithm.

    • @javidx9
      @javidx9  7 лет назад +4

      Thanks Steve. Yeah I think resolution is the limitation - I also tried flashing alternate combinations of colours between frames for different durations, but that just made me feel sick.

  • @Kitulous
    @Kitulous 6 лет назад +1

    8:00 is union and char thingy faster than bitwise shifting the integer color value to needed?
    for example,
    color = 0xRRGGBB
    r = color >> 16 & 0xFF
    g = color >> 8 & 0xFF
    b = color & 0xFF

    • @javidx9
      @javidx9  6 лет назад +2

      Hi Craftist, I would expect the union to perhaps be a bit faster than bit shifting, but the performance gain would be pretty much negilible. I think it is certainly clearer than bit shifting, and less prone to error.

    • @Kitulous
      @Kitulous 6 лет назад

      javidx9 thank you for your answer! I really appreciate that!

  • @MrJackojc90
    @MrJackojc90 7 лет назад +4

    Great video as always!

    • @javidx9
      @javidx9  7 лет назад +1

      Thanks Jack - I'm less sure about this one, it feels incomplete.

    • @MrJackojc90
      @MrJackojc90 7 лет назад +4

      You're your own worst critic :P

  • @BrekMartin
    @BrekMartin 7 лет назад +4

    That’s cool :) More people would appreciate it than you’d think I reckon.

    • @javidx9
      @javidx9  7 лет назад

      Hey Cheers Brek - It's daft that's for certain.

    • @BrekMartin
      @BrekMartin 7 лет назад +1

      Let’s say it’s not a candidate for Sony PSP :D plus I don’t have the camera again this time round.

    • @BrekMartin
      @BrekMartin 7 лет назад +1

      You got more subs than me, congrats! Got any tip for me on how to RUclips? :D Let’s see if I’m right again... >6K for you within 12 months, and I think the only way I’ll be wrong is if it explodes suddenly.

    • @javidx9
      @javidx9  7 лет назад +1

      Thanks buddy. Let's see now, tips, oh yes - Get lucky and hope that some other great and frankly eccentric youtuber finds your channel early on and motivates you enough to keep on going. :-D

    • @BrekMartin
      @BrekMartin 7 лет назад

      Lol after ten years I don’t need that advice :D Actually I know very well how to do it. Just look at the commonality of the videos that get some thousands of views (and they certainly do have something in common), but then I’d not be doing what I enjoy, which has always been more important to me than YT ;)

  • @strayling1
    @strayling1 4 года назад

    When you're calculating the dominant colours @21:00-.ish have you tried using the RGB scaling from the greyscale luminance function, or something similar? 40% blue might win over 50% yellow for example.
    BTW, beware unions and endianness

  • @johnvonhorn2942
    @johnvonhorn2942 5 лет назад +3

    "He has the power!" C Man! @ castle grayscale

  • @Hunter725R
    @Hunter725R 4 года назад +1

    Just tried to do this with PixelGameEngine 2 and was able to completely skip the symbols implementation. Though it just looks like a regular webcam feed now.

  • @Otakutaru
    @Otakutaru 6 лет назад +15

    what if you made a huuuuuuge lookup table?

    • @javidx9
      @javidx9  6 лет назад +9

      Hi Otakutaru, lol yes, you could create a huge one, but in fact you dont need too! Firstly there are far fewer combinations of characters than there are colours in 24-bit space, so you should be able to reduce the table pretty quickly. In fact some viewers did, if you check out my Community Showcase 2018 #1 video I demonstrate some of the awesome algorithms created by this community to solve the problem

    • @gavinwhite7781
      @gavinwhite7781 5 лет назад +1

      @@javidx9 Why do you never link the videos you mention in your comments?

  • @burntt999
    @burntt999 3 года назад

    9:30 - marker
    i keep getting some 3 lines of text so small that i can only make out the last one and its "press any key to exit ...." in the windows terminal when I hit debug in VS. at the marker i just put down and I also loaded up the finished product .cpp file from the github and it does the same thing. on both my desktop and laptop. (usually things work better on my laptop for some reason. so yes i'm not sure whats going on. little bummed that even the finished one from javidx9's github has the same problem. give me absolutely no direction to head in with this project. boo :) oh well guess ill code along with a different video

    • @javidx9
      @javidx9  3 года назад

      If you powered up your debugger it would quickly reveal that your monitor is insufficient to display the size of console you are requesting. It's trying it's best to squeeze in the font onto your display and can't as the resolution of your monitor is too low, or the resolution of the console you are creating is too high. Try halving fontw and fonth values in ConstructConsole function. This will likely allow it to fit on the screen, at a sensible font size.

  • @EtherealIntellect
    @EtherealIntellect 7 лет назад +2

    Silly question, but why not build a massive rgb lookup table of all the possible color (and black/white) and dither combinations from 2 colors and then search against that (just rgb nearest neighbour or convert to hsv and nearest neighbour and back or whatever)? That's basically what the black/white code does already, it was just simpler to code all the combinatorics by hand

    • @javidx9
      @javidx9  7 лет назад +2

      Hi Ethereal, it's not a silly question at all, and in fact was one of my first approaches, but its quite a large and complex table! It would be easier to work backwards and try all the character combinations and calculate which RGB it approximates. It gets tricky as you need to include luminance, which starts to add discontinuities into the colour space when converting to characters. Even more frustrating is MS in their wisdom did not consider representing their luminance options linearly. Hey, give it a go, I'd love to just use a lookup table - I could play with palette effects and other tricks!

  • @Ozuqam
    @Ozuqam 6 лет назад +3

    15:18 That's very nice we can see quite a number of shades of gray. ( May be 50 ?)

  • @germimonte
    @germimonte 4 года назад +1

    probably wrong, but coudn't you train a small neural network ro convert the 3 input nodes(r,g,b) into 37 output nodes(32 for bg and fg colors and 5 for char), or maybe calculate the rgb equivalent of all bg/fg/char colors and then simply find the closest one for each pixel(may be more computationally intensive, idk how you would even find the closest in 3d space

    • @javidx9
      @javidx9  4 года назад

      Possibly, but in order to train the network, I would need the results anyway, and its likely that the training data would be generated algorithmically, in which case I could just use that.

  • @MuradBeybalaev
    @MuradBeybalaev 4 года назад

    But you kinda do have 3 output variables:
    Background color, foreground color and the visual density of the dithering character.
    Mapping brightness AND saturation to them is still a tall order still, since both require dithering with only prime hues available.
    Either way, what you should've probably done is upsample and dither for real.

  • @anonymoussloth6687
    @anonymoussloth6687 4 года назад +1

    Hi, I was following your 8 bits of image processing video and you used escapi there as well, so I found this video to see how to set escapi up. For some reason, I still cant manage to make it work. When I run the program, it just shows a terminal with "Press any key to close the window..." and my webcam doesn't turn on.
    I downloaded the binaries of escapi, and added the escapi.cpp and escapi.h files to my project. Am I missing anything or doing something wrong?

    • @javidx9
      @javidx9  4 года назад +1

      Sounds like the console you are making is too large to fit on your display. Try halving the fontw and fonth arguments in ConstructConsole()

    • @anonymoussloth6687
      @anonymoussloth6687 4 года назад

      @@javidx9 I solved this. It was because I was missing the dll files.

  • @VenomousCamel
    @VenomousCamel 5 лет назад

    With only a limited knowledge of image processing, I presume you could increase the "feel" of the image by interleaving your color-grayscale with a pure greyscale. Theoretically that would put an emphasis on the luminance and increase the number of possible shades. Though if you do this as full frames, you might get a nasty 15-30 Hz flicker. But as alternating interlaced scanlines, that could work.

  • @abrarmasumabir3809
    @abrarmasumabir3809 3 года назад

    this guy makes me go all out?

  • @landsgevaer
    @landsgevaer 5 лет назад +1

    This begs for some dithering across pixels, I think, a topic very much up your video series' alley. Not too complicated when done on RGB channels separately, for instance Floyd-Steinberg.
    en.m.wikipedia.org/wiki/Floyd%E2%80%93Steinberg_dithering

    • @javidx9
      @javidx9  5 лет назад +1

      You're right Dave, and in fact the community went on to do this with fantastic results, they also implemented gamma correction too XD the results can be seen in the community showcase video that follows this one.

  • @devgamez8527
    @devgamez8527 2 года назад

    Thanks, i'm learning a lot from your videos. And here i found some interesting i have bit of trouble with classic Console engine every time i stop my program, so i'm using GL version instead. one difference is that its PIXEL_SOLID is more like 95% solid, that gives more color options. 8 shades between color, and in total 28 grayscale colors. Rest of solid and partially solid characters ar also bit different, so if i switch between classic and GL i get different and in this case incorrect results.

  • @LiamSwiftTheDog
    @LiamSwiftTheDog 5 лет назад

    I skipped through the video so you probably mentioned it, but a dithering algorithm could make this look much much better and closer to the source material

    • @marcus_w0
      @marcus_w0 5 лет назад

      Yeah, you skipped thru it. Around 11:00 minutes in, he describes the dithering.

  • @dimitrykachkovski5513
    @dimitrykachkovski5513 4 года назад

    Any chance you have a suggestion as to why my results are running at 6-8fps vs your 30? I have an Intel(R) Core(TM) i7-7820X CPU @ 3.60GHz, so I don't see a reason why this would be happening...
    Looking at the profiler, seems my CPU usage is minimal, too...

  • @il_moddo
    @il_moddo 4 года назад

    My setupESCAPI returns NULL, even though I have a built in webcam in my computer and another external one connected to it. What might be the cause of this?

    • @javidx9
      @javidx9  4 года назад

      Have you put the dll file in your working directory/project folder?

    • @il_moddo
      @il_moddo 4 года назад

      @@javidx9 Yes, I tried putting the x64 .dll file in the directory and also putting the entire path of the file in the escapi.cpp file but it didn't work. I have now tried to put the Win32 dll file instead and it seems to work. Thank you anyway for helping me

  • @theairaccumulator7144
    @theairaccumulator7144 5 лет назад

    This is the greatest bodge in console game engine history.

  • @aburipon8279
    @aburipon8279 4 года назад

    Which Webcam did you use for this video, that show quite clearly your command line? name and model of that webcam pls.

  • @hallakim184
    @hallakim184 7 лет назад +1

    Have you considered changing CONSOLE_SCREEN_BUFFER_INFOEX.ColorTable?

    • @javidx9
      @javidx9  7 лет назад

      Hi Halla, I could, but I don't see what advantage I could gain. I still only have 16 "colours" to choose from, though perhaps there are better combinations. However, I'm unsure if you're able to set the colour table for each character drawn. It's messy, but I've not tested doing that. I think the colour table is applied across the output console.

    • @hallakim184
      @hallakim184 7 лет назад

      Yes you're correct. If you change ColorTable[0] to RGB(100, 100, 100) and print out "AAA" with color 0 and then you change ColorTable[0] to RGB(255, 0, 0), eventually previous "AAA" will have color RGB(255, 0, 0). I was thinking it would be nice if one can find the 'mostly used color range' and modify color table to achieve the best output though still your solution looks great enough. Thanks for nice tutorial!

  • @arf20
    @arf20 4 года назад

    Hey, I just done that yesterday not even knowing this video was going to be uploaded! But I did it with OLC:: PGE. And I also used ESCAPI

    • @arf20
      @arf20 4 года назад

      I posted in the show your stuff channel in your discord.
      I also did it in a client/server architecture, that was the main point, an uncompressed video stream. (With sockets). And the colors were messed up, but not in the way of this video, the color channel were mixed in some way xD

  • @Bonfra04
    @Bonfra04 5 лет назад

    when i call the initCapture function the program just hold forever.. what can i do?

  • @jonathanmaynard2551
    @jonathanmaynard2551 6 лет назад

    I know I am commenting about this a lot later, but do we need to add the dll to our project inside of Visual Studio itself along with the cpp file and the h file, because I have tried both, and whenever I type in SimpleCamParams, it comes up with a error

    • @javidx9
      @javidx9  6 лет назад

      Hi Mokizel, you only need to include the h and cpp files into your project. What compiler error are you getting? Also make sure the files are in the same folder as your main program code.

    • @jonathanmaynard2551
      @jonathanmaynard2551 6 лет назад

      I get a error saying whenever I type in 'SimpleCapParams capture;' "identifier "SimpleCapParams" is undefined". Also thank you for responding to my comment and helping me.

    • @javidx9
      @javidx9  6 лет назад

      do you #include "escapi.h" in your source file?

    • @jonathanmaynard2551
      @jonathanmaynard2551 6 лет назад

      No, and now that I incorporated it, it did it worked. I can't believe I forgot to put that in, and thank you for helping me.

    • @anonymoussloth6687
      @anonymoussloth6687 4 года назад

      did we need to add the dll file also? if so, how do we add it? Do we just copy paste it in the explorer of the project? Please help me because I have been trying to get this to work for a long time.

  • @imranrajjad7028
    @imranrajjad7028 4 года назад

    great content, too bad I was not able to make the olcConsoleGameEngine work on Code Blocks + MSYS2/MinGW, as it goes looking for SDL

    • @javidx9
      @javidx9  4 года назад +1

      You grabbed the wrong one then. CGE original does not use sdl

    • @imranrajjad7028
      @imranrajjad7028 4 года назад

      @@javidx9 thats odd, is this not the right one? github.com/OneLoneCoder/videos/blob/master/olcConsoleGameEngine.h
      the build failes at github.com/OneLoneCoder/videos/blob/master/olcConsoleGameEngine.h#L1147 with error undefined reference to `__imp_waveOutOpen'
      Could I have assessed the problem incorrectly?

  • @AdvancedSoul
    @AdvancedSoul 6 лет назад

    christ, why not use bit shifting to extract the values? it's a more portable way of getting the specific color components (you can even use CHAR_BIT if you feel like it)

    • @javidx9
      @javidx9  6 лет назад +1

      Hmmm. The problem here is not extracting colour values, it's deriving a sufficient mapping between the two colour spaces, one of which is contiguous and the other is not. The limited palette of the command prompt requires mixing with shade characters that means you can only form full spectrum by summation of two colours at discrete spectral intervals.

  • @TravelingMooseMedia
    @TravelingMooseMedia 4 года назад +4

    Wonder what this looks like in pixel game engine

    • @javidx9
      @javidx9  4 года назад +5

      Lol. It just looks like a webcam 😂

    • @TravelingMooseMedia
      @TravelingMooseMedia 4 года назад

      @@javidx9 Nice, gonna try and implement it :)

  • @orocimarosay1447
    @orocimarosay1447 6 лет назад +1

    the initCapture function is not working for me :(

    • @javidx9
      @javidx9  6 лет назад

      Escapi requires a few things on your system which perhaps you dont have, such DirectMedia

    • @orocimarosay1447
      @orocimarosay1447 6 лет назад +1

      what is that ?

  • @jsflood
    @jsflood 6 лет назад +1

    Great video :-)

  • @TheChodex
    @TheChodex 7 лет назад +2

    Are you alien? :O This is awesome! :D

    • @javidx9
      @javidx9  7 лет назад +3

      Thanks Danilo! as far as I know, I'm from this planet.

    • @delofon
      @delofon 4 года назад

      @@javidx9 we can't be 100% sure...

  • @glowiever
    @glowiever 4 года назад

    lol nice. looks paletted. remind me of good ol dos gamw

  • @jean-naymar602
    @jean-naymar602 7 лет назад +1

    wow, that's fucking awesowe !

    • @javidx9
      @javidx9  7 лет назад

      Cheers Jean-Nay! However, I respectfully disagree - it is decidedly awe-less! :-D To Be Improved...

    • @jean-naymar602
      @jean-naymar602 7 лет назад +1

      But using the console to display a webcam video is an idea that has to be praised !

  • @0xoldschool17
    @0xoldschool17 2 года назад

    Next Step: implementing this in ms dos ega graphics

  • @zoltans3466
    @zoltans3466 6 лет назад

    May I ask your help please? Got stuck in the beginning - at the first try on black and white testing. The #include "escapi.h" is there, the header and the cpp added to the project. The problem occurs on startup, when escapi cannot load in the setup the escapi.dll (HMODULE capdll = LoadLibraryA("escapi.dll");
    Do I need to add something else?

    • @javidx9
      @javidx9  6 лет назад

      Do you have escapi.dll in your project folder on disk?

    • @zoltans3466
      @zoltans3466 6 лет назад

      Ok, sorry was a bit tired - copied into the wrong folder. Thank you :)

  • @grftaNitro
    @grftaNitro 5 лет назад +2

    I can barely make running code and then I see people creating this...

    • @javidx9
      @javidx9  5 лет назад

      Everyone has gotta start somewhere buddy!

  • @nguyenucnghia9304
    @nguyenucnghia9304 5 лет назад

    i have an error said CL.exe excited with code 2

  • @witnnileUnity
    @witnnileUnity 4 года назад

    You are crazy

  • @dorjderemnamsraijav5182
    @dorjderemnamsraijav5182 5 лет назад

    Why you don't use linux?

    • @javidx9
      @javidx9  5 лет назад +2

      I do, just dont find it as fluid as windows.

  • @BrekMartin
    @BrekMartin 7 лет назад

    I didn’t get YT notification. Something broke :( Anyone else?

    • @javidx9
      @javidx9  7 лет назад +1

      I think so - I've been missing a few too. One of yours too actually Parts 4 & 5 didn't get announced. Still watched 'em though :)

    • @BrekMartin
      @BrekMartin 7 лет назад

      Cool :D I knew conceptually how a retro computer worked with it’s address & data bus, but it took someone else’s practical project to really turn the light on. So now I’ve already ordered a 68030 40MHz CPU for an accelerator, salvaged 2Mb RAM from a bung mainboard, and have already started the parallel port. I’ll keep making a stack till something breaks. I don’t think it’s all YT material though.

    • @seditt5146
      @seditt5146 7 лет назад

      Brek, they changed the YT Algorithm to display based on time frame between last time a video was watched from that person, so if a longer time span has gone by they will show you other videos or just not display a notification at all. There has been a lot of bitching about it across the board from YT creators. Game Theory did a decent video on the Algorithm changes and there are some other videos out there explaining it as well.

  • @yeilmusic
    @yeilmusic 4 года назад

    wtf lol xD