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

Поделиться
HTML-код
  • Опубликовано: 5 июн 2019
  • 💻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

  • @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!

  • @JesseWx_
    @JesseWx_ 7 месяцев назад +1

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

  • @maazhussain8303
    @maazhussain8303 4 дня назад

    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.

  • @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!!

  • @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 Год назад +1

      thanks for this

  • @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 RUclips "join" button and I also have a Patreon.

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

      @@TheCodingTrain Will do!

  • @kevinheckart
    @kevinheckart 5 лет назад +6

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

  • @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!!!!!

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

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

  • @sudhamjayanthi
    @sudhamjayanthi 3 года назад +1

    Awesome. Subscribed!

  • @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.

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

    This is one of your funniest you have made

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

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

  • @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?

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

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

  • @geoffwagner4935
    @geoffwagner4935 9 месяцев назад

    omg it works, i can see my fallout 76 achievements

  • @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

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

    thankyou v much you are such a good teacher

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

    Great series, thanks

  • @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).

  • @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.

  • @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

  • @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 ?

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

    As always, great work Dan

  • @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

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

    Sir, you are genius

  • @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?

  • @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.

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

    Awesome 👍

  • @geoffwagner4935
    @geoffwagner4935 9 месяцев назад

    omg npm steamapi is a good one

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

    I love you man...I needed this.

  • @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()

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

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

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

    Excellent video!

  • @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...

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

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

  • @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!

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

    Very good tutorial

  • @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.

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

    7:14 - base64

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

    Yay, waited for this!

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

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

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

    Where is the supplemental code included with this video?

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

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

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

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

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

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

  • @antonioquintero-felizzola5334
    @antonioquintero-felizzola5334 5 лет назад

    You are amazing!

  • @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!!!

  • @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.

  • @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! ruclips.net/p/PLRqwX-V7Uu6YxDKpFzf_2D84p0cyk4T7X

  • @augischadiegils.5109
    @augischadiegils.5109 2 года назад

    ❤️❤️❤️❤️❤️

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

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

  • @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

  • @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)

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

    how was exercise 07_save_files accomplished

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

    Can i create a video chat application using P5?

  • @99Pakii
    @99Pakii 3 года назад

    I learned something(s)

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

    my image is not showing in list
    please do something

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

    can i use p5 with react?

  • @elliot.r4383
    @elliot.r4383 5 лет назад

    How many programming languages do you know?

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

    like all

  • @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()))

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

    Please make a video on music player

  • @geoffwagner4935
    @geoffwagner4935 9 месяцев назад

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

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

    top lezion

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

    The image64 data is not converting into image

  • @geoffwagner4935
    @geoffwagner4935 9 месяцев назад

    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

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

    Please suggest something

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

  • @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!

  • @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.

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

    Only 611 views :/

  • @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.

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

    Aaaaaaaaaahhhhh.