2.6 Saving Images and Base64 Encoding - Working with Data and APIs in JavaScript

Поділитися
Вставка
  • Опубліковано 20 жов 2024
  • 💻github.com/Cod...
    Let's add an image from the webcam to our database. For this project, we will be using the p5.js JavaScript library!
    🎥 NEXT LESSON: • 2.7 Project Wrap-up: A...
    🎥 PREVIOUS LESSON: • 2.5 Database Query - W...
    🎥 FULL COURSE: • Working with Data and ...
    🔗 p5.js: p5js.org
    🔗 Processing Foundation: processingfoun...
    🔗 Base64: en.wikipedia.o...
    🚂 Website: thecodingtrain....
    💖 Patreon: / codingtrain
    🛒 Store: www.designbyhu...
    📚 Books: www.amazon.com...
    🎥 Coding Challenges: • Coding Challenges
    🎥 Intro to Programming: • Start learning here!
    📄 Code of Conduct: github.com/Cod...

КОМЕНТАРІ • 107

  • @JesseLikesWeather
    @JesseLikesWeather 9 місяців тому +1

    As a guy who loves meteorology, your playlist on apis has truly helped me write my script. A million thanks to you!!!

  • @SteampunkSammy
    @SteampunkSammy 5 років тому +14

    The attention to detail with regards to the editing alone in these videos is great!
    12:27 The clip in the top right is synced with the motion of exactly what your talking about, 'Taking the javascript out'
    Kudos to you!

  • @maazhussain8303
    @maazhussain8303 2 місяці тому

    you are work is just Awesome Sir....the way you teach is Amazing....hats-off to you...Thank you so much

  • @curt8806
    @curt8806 5 років тому +10

    Dang. You are just hammering these out.

  • @NathanLuMax
    @NathanLuMax 5 років тому +2

    You are so awesome! I was looking everywhere for coding courses and I thought YT would never have anything, but I was definitely wrong. Thank you for offering such high-quality content for free! If there is any way for me to support with money, please let me know!

    • @TheCodingTrain
      @TheCodingTrain  5 років тому +2

      Thank you! You are welcome to use the UA-cam "join" button and I also have a Patreon.

    • @NathanLuMax
      @NathanLuMax 5 років тому

      @@TheCodingTrain Will do!

  • @fastlearner9993
    @fastlearner9993 2 роки тому

    THE BEST TEACHER!!!!!!!! someone ask me in 2023 how much have i progressed since today

    • @TheCodingTrain
      @TheCodingTrain  2 роки тому +1

      I will try to remember!

    • @nkvl3326
      @nkvl3326 Рік тому

      @@TheCodingTrain IT'S TIMEEEEE!!!!!

  • @markboots_
    @markboots_ 5 років тому +25

    Hope you will still do some explanation about hosting the node.js somewhere else then on a local machine

    • @TheCodingTrain
      @TheCodingTrain  5 років тому +17

      I do! It comes as the last video in this series.

    • @bigboots6626
      @bigboots6626 5 років тому +2

      @@TheCodingTrain Great!!

  • @Pedritox0953
    @Pedritox0953 5 років тому

    This is one of your funniest you have made

  • @kevinheckart
    @kevinheckart 5 років тому +6

    3 dislikes? Who the heck would dislike this???

  • @mamado226
    @mamado226 5 років тому

    Can not like this video enough! amazing series!!!

  • @brendano1204
    @brendano1204 2 роки тому

    thankyou v much you are such a good teacher

  • @sudhamjayanthi
    @sudhamjayanthi 3 роки тому +1

    Awesome. Subscribed!

  • @danooshansureshkumar8405
    @danooshansureshkumar8405 2 роки тому +4

    Hi, hopefully I am not too late, but as of writing this (July, 2022). P5.dom.js script has been merged into the p5.js script. However when trying to call noCanvas() on chrome, it fails to locate the dom element for the camera, as the browser I am using (firefox) doesn't ask me for permission to use my camera. I tried fumbling with the settings on the browser but that didn't work, the prompt to use the camera just won't show up. If I can find a solution I will post below

    • @danooshansureshkumar8405
      @danooshansureshkumar8405 2 роки тому +3

      Update: After trying to get permission to use the camera from navigator (similar to how geolocations permission was called) I realized my virtual linux environment cannot detect my webcam. I even tried using other sites on the VM to see if it could access my laptop camera and it failed. That is most likely the error, nothing to do with the code.

    • @cm3462
      @cm3462 2 роки тому +1

      thanks for this

  • @hendasheng
    @hendasheng 3 роки тому

    it's great! This is exactly what I want to try, it helped me a lot, thank you for your course.

  • @prabhatsingh7713
    @prabhatsingh7713 4 роки тому

    Sir, you are genius

  • @geoffwagner4935
    @geoffwagner4935 11 місяців тому

    omg it works, i can see my fallout 76 achievements

  • @BrettCooper4702
    @BrettCooper4702 5 років тому +1

    Great series, thanks

  • @jinxasta
    @jinxasta 5 років тому +1

    Hey Daniel what's up ? Could you record a short video with p5 ? or can you only use the createCapture function to capture frames from the webcam ?

  • @subhadipghorui2216
    @subhadipghorui2216 5 років тому +3

    Can't display the image .....but the image is present when i console log it.

  • @aleksadamjanovic7699
    @aleksadamjanovic7699 3 роки тому

    Daniel i love you, i learned so much from you especialy about machine learning. I use this recomanded video just to say you how im greatfull. Thanks a lot. Love you

  • @yiren609
    @yiren609 5 років тому +9

    turns out that the p5.dom.js library has to be imported after the p5.js...otherwise the createCapture will not work...spend my day debug this...

    • @alator21
      @alator21 5 років тому

      Not only this method. All the methods from p5.dom.js will not work. p5.js is prerequisite.

  • @mileswilliams527
    @mileswilliams527 5 років тому

    As always, great work Dan

  • @antonfsd
    @antonfsd 4 роки тому +1

    anyone else having trouble with the image? I am doing this with sqlite and it seems like it is going through when I send the request, but when I manually render the img on the DOM it is blank? thinking the loadpixels() method may not be working for me?

  • @ibrahimmohammed4267
    @ibrahimmohammed4267 5 років тому

    I love this series 😭 so sad its coming to an end..

    • @TheCodingTrain
      @TheCodingTrain  5 років тому +2

      There's a whole 3rd project to come!

    • @00el04
      @00el04 3 роки тому +2

      @@TheCodingTrain do you have more after 3rd project?

  • @semrana1986
    @semrana1986 5 років тому

    simply superb...

  • @sanjarcode
    @sanjarcode 2 роки тому

    Awesome 👍

  • @jkw4703
    @jkw4703 5 років тому

    Excellent video!

  • @Viralplace
    @Viralplace 4 роки тому

    Should I store all base64 data to the DB? Text format? Because I think that in varchar we have not space

  • @shadmantanjim7985
    @shadmantanjim7985 5 років тому

    I love you man...I needed this.

  • @cybercrimeconsultant
    @cybercrimeconsultant 2 роки тому

    Nice video tutorial. It is much better if the coordinates be embedded in the picture, say at the bottom-right corner. The coordinates as well as the picture (using the back camera) will be coming from the mobile phone. Can you come up with a tutorial like that?

  • @adrianwalker9917
    @adrianwalker9917 3 роки тому +1

    I'm getting a blank image every time it saves to the DB (shows as blank white space in the browser and the same base64 code for each entry). Troubleshooting now. Long story short....wasn't able to find the problem.....had to rewrite it with a different style of button (the addEventListener type he used).

  • @devilnight6610
    @devilnight6610 5 років тому

    Very good tutorial

  • @thiagogomes5309
    @thiagogomes5309 2 роки тому

    Is there a way to send an image from base64 to image in gmail body?
    I've tried use the "data:image/jpg;base64," but doens't worked.

  • @ahnafswapnil275
    @ahnafswapnil275 3 роки тому

    Where is the supplemental code that you said you will be adding to this video?

  • @niyazi95
    @niyazi95 4 роки тому

    Can you help me please, I have a project which I have to send images over Python Socket Server to JavaScript client. When I do that, I get hexadecimal array (actually it's decimal but 0-255) I want to convert the array to image (on JavaScript client) but I can't.

  • @agustinrivero4358
    @agustinrivero4358 5 років тому +3

    Can u make a video about mixing react/angular with node.js please?

    • @leonk6950
      @leonk6950 5 років тому +1

      He probably won't in the closer future as he doesn't use any frontend frameworks, because he doesn't really do frontend in the traditional sense.
      Mixing them is just building a rest API or, which I would recommend depending on your needs, a graphQL API with node.js, and then building a frontend with react/angular/Vue that accesses that API to get data and store changes.
      Id really recommend trying the GraphQL route, and I'd really recommend ReactJS over angular. React lets you just use javascript but helps you with displaying stuff. Angular changes the way you do pretty much everything, so it's a lot harder to learn, a lot harder to get out of, a lot less helpful for learning actual JavaScript, and a lot slower, both in development and in running it

  • @Nola1222Piano
    @Nola1222Piano 5 років тому

    Yay, waited for this!

  • @anamaykane9355
    @anamaykane9355 3 роки тому

    Where is the supplemental code included with this video?

  • @nicolareiman9687
    @nicolareiman9687 5 років тому

    Wow for the first time i saw a man who does an interesting thing with nodejs rather than repeat what is already in the documentation.

  • @wxIyz
    @wxIyz 4 роки тому +1

    great video, *video.size(160, 120)* has a bug with the video width element and the image is a white background, to solved this I remove *video.size(160, 120)* and add *createCanvas(160, 120)*, what is the correct form?

    • @adamwoolf9993
      @adamwoolf9993 4 роки тому +1

      thanks for this! I had the same problem.

    • @wxIyz
      @wxIyz 4 роки тому

      @@adamwoolf9993 Hi, another way is where the video take the parent width:
      const main = document.getElementById('main');
      function setup() {
      noCanvas();
      video = createCapture(VIDEO);
      video.parent(main);
      }

    • @martinchirino5455
      @martinchirino5455 4 роки тому +1

      @@wxIyz Thanks ! "createCanvas" did not resize the cam for me. But appending the video to a parent div worked after some css. cheers!

    • @offical.Brogym
      @offical.Brogym 3 роки тому

      Mirror issue how can fixed

  • @kristiannn
    @kristiannn 3 роки тому

    7:14 - base64

  • @arlontuazon6263
    @arlontuazon6263 3 роки тому

    Can I do this using mysql database instead of nedb? Thanks!

  • @rendryhelen3512
    @rendryhelen3512 3 роки тому

    So... is it possible to delete base64 'encoded' images or not?

  • @adrianwalker9917
    @adrianwalker9917 3 роки тому

    The problem is.......I had already used a function to get the button to work since I didn't know about eventlisteners, etc. (I still don't, I just see it in your code). I am getting errors when I try to wrap that function (for the button) in the new function setup()

  • @btiwari-games5279
    @btiwari-games5279 5 років тому

    best as always

  • @sofiasantamaria1084
    @sofiasantamaria1084 4 роки тому

    Hi!! Thank you for EVERY video you make! I've been experimenting with p5 and currently working on a ml5 and p5 project. I wanna send a frame of a canvas DIRECTLY to Cloudinary (or any other cloud-based image and video platform) so I can display it on the web page I'm working on. It's been two days and I don't seem to find the answer to this issue. Maybe there's some other way to send a frame of a canvas to the cloud-base platform that I don't know about?? Any help would be highly appreciated! Cheers

    • @TheCodingTrain
      @TheCodingTrain  4 роки тому

      Hi Sofia! I just discovered I can view comments by members and am only just noticing this right now. Are you in the discord? That would be a great place to discuss this! I know many members (and I) could help!

    • @sofiasantamaria1084
      @sofiasantamaria1084 4 роки тому

      @@TheCodingTrain Oh I just became a member this morning, so looking forward for that train whistle, fortunately It's been solved and the project is kinda ready, but I'll probably have some more blocks in the near future that I could clarify with you or the community. I'll send the link of the project so u can take a look at it. Thank youu!!!

  • @antonioquintero-felizzola5334
    @antonioquintero-felizzola5334 5 років тому

    You are amazing!

  • @geoffwagner4935
    @geoffwagner4935 11 місяців тому

    omg npm steamapi is a good one

  • @adehenry9591
    @adehenry9591 3 роки тому

    i was able to finish this project upto this point and capture images, saved in database, retrieved and console logged on the html page, but the picture is just blank!!!! , i inspected the page, the img tag is there with the src attribute and value but the picture on the html is just plain white , empty!..... please HELP!

    • @adehenry9591
      @adehenry9591 3 роки тому

      i have found solution to this issue... thanks!

  • @thaboramohlale1399
    @thaboramohlale1399 4 роки тому

    how was exercise 07_save_files accomplished

  • @elliot.r4383
    @elliot.r4383 5 років тому

    How many programming languages do you know?

  • @koenamathaba5726
    @koenamathaba5726 5 років тому

    Can i create a video chat application using P5?

  • @HereWasDede
    @HereWasDede 5 років тому

    You had some old videos that used socket.io (Collaborative Drawing App) and i was wondering why you didn't need any of that in this code. I'm try to make an app, and i would like to know why someone would or would not use socket.io. How does one host beyond of localhost?
    Thanks Daniel, Great videos!

    • @TheCodingTrain
      @TheCodingTrain  5 років тому +2

      This is a great question! Socket.io makes more sense (from my point of view) for real-time interactions like text chat or collaborative drawing, etc. But it's not standard for "one time requests" of data from an API. I think there could be some fun possibilities to integrate sockets with this example though for sure!

    • @HereWasDede
      @HereWasDede 5 років тому

      @@TheCodingTrain Thank You! So Cool, i got a response from you! Ive been watching your videos like like two years. You Rock!
      editor.p5js.org/ddrbnsn@gmail.com/full/-TdqHmvWo

  • @rupayanc
    @rupayanc 4 роки тому

    can i use p5 with react?

  • @namhoanginh6386
    @namhoanginh6386 5 років тому +1

    Why can't I use the function: createCapture(VIDEO) ??

  • @omnipotentfish
    @omnipotentfish 3 роки тому

    DOMException: Could not start video source
    ahhhhhhhhhhhhhhhhh!!!
    why wouldn't it work ?!??
    HELP :(

  • @saurabhpratapsingh312
    @saurabhpratapsingh312 4 роки тому

    my image is not showing in list
    please do something

  • @augischadiegils.5109
    @augischadiegils.5109 2 роки тому

    ❤️❤️❤️❤️❤️

  • @mdminhajuddinkhan3014
    @mdminhajuddinkhan3014 5 років тому

    Hello sir. I am getting createCapture is not defined Error in index.html. Please help
    Edit: I got it fixed. I forgot to add p5 dom library.
    By the way, I appreciate your work so much.

  • @kukuhbakuhsatria4125
    @kukuhbakuhsatria4125 3 роки тому

    can you learn me how to make button upload image capture to google drive sooner..without php but using appscript

  • @inotilaatinghaamwa9333
    @inotilaatinghaamwa9333 3 роки тому

    These tutorials are great,BUT, when you add your own code like with the buttons or the enter and list thing you really loose me(a first time who)

  • @stepone3040
    @stepone3040 5 років тому

    There is lot of playlist that i found in the channel witch i found interesting. But would like to assemble all of this serie of video in separet playlist plz and name it something simple to be easy to been found :)

    • @TheCodingTrain
      @TheCodingTrain  5 років тому +1

      here you go! ua-cam.com/play/PLRqwX-V7Uu6YxDKpFzf_2D84p0cyk4T7X.html

  • @saurabhpratapsingh312
    @saurabhpratapsingh312 4 роки тому

    The image64 data is not converting into image

  • @scadeline805
    @scadeline805 4 роки тому

    I was searching for how to save that image string as file, but villainy rule, you said to do it by yourself

    • @scadeline805
      @scadeline805 4 роки тому +1

      If someone wanted to find a solution:
      # Python 3+
      import base64
      # crop redundant letters from beginning ("data:image/png;base64,")
      sketch64 = sketch[22:]
      def save_sketch_to_server(sketch64, sketch_path):
      with open(sketch_path, "wb") as fh:
      fh.write(base64.decodebytes(sketch64.encode()))

  • @99Pakii
    @99Pakii 3 роки тому

    I learned something(s)

  • @raffaelerimorso9671
    @raffaelerimorso9671 5 років тому

    top lezion

  • @takeleashenafi1187
    @takeleashenafi1187 3 роки тому

    like all

  • @sharadsharma3176
    @sharadsharma3176 5 років тому

    Please make a video on music player

  • @saurabhpratapsingh312
    @saurabhpratapsingh312 4 роки тому

    Please suggest something

  • @geoffwagner4935
    @geoffwagner4935 11 місяців тому

    my payday 2 achievements are my most important ones, want to make my achievements dance around my page lol 911 achievements on that one

  • @WishLovePeace2Everyone
    @WishLovePeace2Everyone 3 роки тому

  • @geoffwagner4935
    @geoffwagner4935 11 місяців тому

    that is the coolest thing ever again. wordpress is such a joke to this stuff lol it' like taylor made to fit everything on the web that' ridiculous. even steam has a direct api tap to it's data

  • @arhabersham
    @arhabersham 5 років тому +1

    0:44 to make "those (technology related) fields accessible to diverse communities".With awesome videos like this one, there is NOTHING impeding "access" to "diverse" communities. What a hell are they talking about!? Stay away from stupid identity politics, and keep up the good work!

  • @GameMasterzZ
    @GameMasterzZ 5 років тому

    Only 611 views :/

  • @grainfrizz
    @grainfrizz 5 років тому

    Hi,
    Here's my PR: github.com/morethanyell/nodejs-tut/pull/7
    Summary:
    added new codes for capturing webcam image
    added gitignore to exclude database.db
    Thank you.

  • @lonnybulldozer8426
    @lonnybulldozer8426 5 років тому +1

    Pretty cool, but you're hyper-cringe. Luckily for you, I get a sick thrill from that so I subscribed. I feel the same way about Siraj Rival, his videos are so funny for some reason but at the same time make me want to die.