Scan QR codes and barcodes with Python

Поділитися
Вставка
  • Опубліковано 24 жов 2024

КОМЕНТАРІ • 79

  • @sravanjosh1218
    @sravanjosh1218 3 роки тому +9

    Hey Kostadin, Thanks a lot for the video. It was really helpful. I'm that introvert who would watch videos and go silent without commenting in it. This video demands appreciation. Thanks again for the video.

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

      Hey Sravan, thanks a lot for your comment, it is much appreciated :)

    • @Frank-xx6rs
      @Frank-xx6rs 2 роки тому +1

      I just felt the need to add +1!

  • @Sinclair393
    @Sinclair393 Рік тому +1

    Thank you for posting this video, python just became less intimidating to me. Thanks again.

    • @Pythonenthusiast
      @Pythonenthusiast  Рік тому +1

      I wish you lots of success in your journey, you can do it! :)

  • @vaibhavsrivastva1253
    @vaibhavsrivastva1253 3 місяці тому

    *HELPFUL TIPS* (will update) :-
    1. myVidCap = cv2.VideoCapture(0, cv2.CAP_DSHOW) # CAP_DSHOW api opens camera MUCH faster than CAP_MSMF, at least on Windows.
    2. flippedHorizontal = cv2.flip(frame, 1) # Flipping the output about the Y-axis.
    cv2.imshow("Testing-Code-Scan", flippedHorizontal) # Change "frame" to the operation carried out on it.

  • @mustaqim6642
    @mustaqim6642 3 роки тому +7

    Hello Kostadin. Your tutorial is very helpful. Can i know, how can i put the data that was printed into a variable. Then, i can just use the variable to play around with the data such as insert into a database. Thank you in advance for your help!

    • @Pythonenthusiast
      @Pythonenthusiast  3 роки тому +5

      Hi Mustaqim, thanks for your question. If you want to create a variable (let's name that variable x), you can use x = code.data.decode('utf-8'). Then you can work with the variable. Hope this helps!

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

    Great video, thanks for posting it. How do you stop the camera and get out of the while loop after reading ONE barcode? Thanks

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

      In the code, I am using time.sleep(5), which waits for 5 seconds after finding a code. If you want to completely get out of the loop, here's how you would do it:
      1. Take a look at the while look, it starts with while camera == True. So, while camera == True, it will keep running.
      2. In the first if-statement, instead of having time.sleep(5), you can add a line camera == False (or replace the time.sleep one with this.
      What this would do is, once a barcode is found, it would set camera to be False and therefore get out of the while loop.
      I hope this helps!

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

      @@Pythonenthusiast Thank you so much for the quick reply.

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

      Add a line camera == False? I think camera = False.

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

      @@kyawzinhtet1704 I guess its camera == False.

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

      @@sravanjosh1218 definetly camera = false. You want to set the variable to false so only one =. With 2 you would use to check if camera is false --> camera == false

  • @kgoulas21
    @kgoulas21 6 місяців тому

    Hi,
    This is great! May I ask if this would work with a Data Matrix?

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

    Hello, wonderful demo !!! Can you help me resolving the below issue pls ?
    When I use import statement as "from pyzbar.pyzbar import decode" and run the code (without any other executable lines), am getting the error "ImportError: Unable to find zbar shared library".
    P.S - I did brew the ZBAR and then installed the PYZBAR as mentioned in one of the forums but still no luck...
    Thanks in advance !

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

    Did this and loved it. Thankyou soo much!

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

    Hello this is one of the best cv tutorial i ever watched. can i add script on this code where once i click the button this python code will run?

  • @Oussama-qp2hh
    @Oussama-qp2hh 3 роки тому

    Thank you so much bro.
    I have a conflict, how add the code reader instead the camera?
    I hope to answer me

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

    Hello Kostadin, how to connect the USB barcode scanner device to the code you have shown in the video? Thanking you in advance for your help!

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

      Hey there. I don't think there's one answer that would be correct for all barcode scanners. But, you can take a look at the link below:
      www.instructables.com/USB-Barcode-Scanner-Raspberry-Pi/
      Basically, you need to have the option to add the code to your barcode scanner. However, you can think outside of the box. A scanner doesn't have to look like a regular scanner, it can be your phone.

  • @IsaacMoore-un9hc
    @IsaacMoore-un9hc Рік тому

    To scan UPC-A barcodes would I still use utf-8 or would it be a different format of decoding? I scanned a pack of gum and it registered as EAN13 even though it is UPC-A, however when I tried to scan a drink can, it would not register. How can I fix this?

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

    Hi, is the pyzbar only handling type EAN13 and QRCODE? I have once lable which is not seems to be working ... just wonder how many types pyzbar could handle...

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

    Hello @ Kostadin Ristovski , i would like to know if i use cv2 in a BeeWare python app, built it in Android. It would use the cam of the phone??? Or are more things necesary??

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

    Thanks a lot for this video. It's very helpful.

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

    I think it should be change to if the same code not get scan in a minute , it can rescan , it should be better if you make a bought list in supermarket

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

      In the supermarkets I have noticed two types of scanners:
      1. Fixed ones that are built in the table, where they scan constantly, until there is a product. Then, there is a stop for a second or two before they start scanning again. This is to ensure that the same product is not scanned multiple times at once.
      2. Portable ones, where the scanning starts by pressing (and sometimes holding) a button. Once a product is scanned, the same one/two seconds stop is applicable for the same reason.

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

    Thank you this helped!

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

    This is fantastic.
    Thank you

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

    Hello Kostadin!
    Firstly, thank you for good tutorial!
    I have a question about how can I use jpeg-file with QR Code that I got, for example, by taking photo of some item in supermarket

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

      Hi there. The tutorial starts with decoding an image and extracting the information from a QR-code. If you have a jpeg file, then it would be the same. You need to "read" the image with cv2, then decode it and you can extract the data. Hope this helps!

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

      @@Pythonenthusiast but, I saw in the documentation, that there are two ways to read an image file in to the pyzbar: with PIL and with Open CV.
      What is your favorite way, and why?

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

      @@puzobaklan Well, both PIL and Open CV allow you to read an image. PIL (short for pillow) is more usable for image manipulation/processing. So for example if you want to resize an image or cut it. Open CV is a computer vision library, which is suitable for complex vision-related tasks or live videos.
      Hope this helps!

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

      @@Pythonenthusiast many thanks!

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

    Can we get the details(price) and store(price) in SQLite(database)

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

    Great tutorial !!
    Question: Do you know if there's a way to run some code from the Atom editor into IDLE-Shell without having to open the folder where my py file is located then right-click on it and select "open with > IDLE..." it's quite tedious when testing. Thanks!

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

      Hi Ricky, if you have a .txt file, by double-clicking it, it would open in a word-processing program, such as notepad. The reason for that is, well, you can't do anything else with the file.
      However, if you have a .py file, it can be edited, but also run. So, by double-clicking it, you access its main function, to run the code written inside. If you want to edit it, you have to right-click and open via IDLE for example.

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

    Do this code work for barcode scanning machine than webcam..?

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

    if it possible using raspberry pi zero w and camera to build a barcode scanner using tis code?
    plz replay sir, if this works i like to build a portable scanning devices!

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

      It is absolutely possible :)

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

      @@Pythonenthusiast one more question sir, "pyzbar" is that a package?

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

      @@KartihkCg80 Yes, it is a package/library that can be installed as any other.

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

      @@Pythonenthusiast thank you so much sir 🖤

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

    Hello Kostadin, Thank You very much for this video, do you perhaps know how to close the video capture? When i close the ui of the camera it just kept on coming back, do you know what to do with this?

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

      There are many ways to do that, probably the easiest one is to break when a QR code is found.

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

      @@Pythonenthusiast Thank You

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

    hello kostadin. I really enjoy your tutorial, can i know that can I use it for the mobile app which is implemented by Kivy, such as using camera from smartphone, then read it then the returned data can be used for sth else. by the way, is there any solution to tracking the scanned time of the QR code, thanks!

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

      Hi there, thanks for the question. All of what you have mentioned is possible. I am not that familiar yet with mobile app development, but Kivy library was recommended to me, so maybe you can combine this tutorial with the Kivy library and create an app as you describe. As for the scanned time, you can take a look at datetime, there's a function datetime.now() that would return the current time. Hope this helps!

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

    Great tutorial!

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

    Awesome content buddy.

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

    Hello kostadin,
    Importing pyzbar showing me an error
    Could not find module 'libiconv.dll' (or one of its dependencies). Try using the full path with constructor syntax.
    please help!!

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

      hey did you find the solution?

    • @neonyt6739
      @neonyt6739 4 місяці тому

      @@Olivernipples did you find?

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

    how can i stop the scaaning once system able to recognize the QR .. please suggest

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

      Try to create a loop that breaks when a QR is found.

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

    could this code be used within flask
    ??

  • @chrizzchan6800
    @chrizzchan6800 5 місяців тому

    part 2??? and 3??

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

    can you paste the code because I'm getting errors when copied your code

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

      What error do you get? Is it fix now?

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

    how do i put the webcam inside a tkinter window

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

      Maybe the link below would help you out.
      stackoverflow.com/questions/16366857/show-webcam-sequence-tkinter

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

    how to make it with tkinter?

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

    this is some good shit

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

    how does one install cv2

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

      Check the link below:
      pypi.org/project/opencv-python/

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

      @@Pythonenthusiast thanks, found it

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

    👍👌🙏🙏🙏

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

    Man codes in light mode i dont trust him

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

    Hi Sir can i want learn from you how can it learn step by step can text us ,
    Thanks you,

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

      Hi Tan, sorry I cannot fully understand your message.

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

      @@Pythonenthusiast Hi Sir i want to learn from you is good that i can get more detail form you i am from Singapore after watch your video is a great thing ,
      Many Thanks,
      Tan MS

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

      My email is stated on my UA-cam profile, so you can reach out to me with any questions that you might have.

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

      @@Pythonenthusiast Hi Sir i did see your address can pass to me ,
      Many Thanks,
      Tan Meow Soon

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

      @@Pythonenthusiast Hi Kostadin i want to learn the way you do the python program for the barcode,
      by using the Pc cameras how can i go to your Tutorial step by step ?
      can guide me ,
      Many Thanks,
      Tan Meow Soon

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

    I hate tutorials like this. Whats the point of making a barcode scanner with Python if youre gonna import all of the code anyway. Theres no good tutorials out there. Everybody just imports everything and calls it a day.