I have spent weeks looking for a way to turn my webcam (built into the computer) into a QR scanner using Python but nothing has worked.
In the first instance, I tried installing this software which supposedly would allow me to turn my camera into a barcode scanner, which could then use this video to decode the codes in python. I installed the scanner along with 'pywin32' which was supposedly the library I needed to use, but I couldn't get the two to communicate as my computer kept saying that pywin32 has not been installed (although it had).
Then, I moved onto using zbar/ pyzbar. I downloaded all of the modules that were recommended (I followed the instructions set out on here) but these each came with several more error messages. It was all to do with various libraries and modules not being installed - I've tried downloading PIL/pillow, pyqrcode and a number of other things that are supposed to work, but for some reason, don't.
I don't feel that I can provide any evidence of code as I haven't got any code to fix for this particular issue -- I am simply looking for anyone who may know of a way to transform an ordinary webcam into a barcode/qr scanner using python.
Assuming none of the libraries I need are installed on my computer at the moment, could someone please explain to me exactly which libraries I will need to download, where I can find them, and how I could use them to make Python communicate with my webcam?
This is for my A Level Coursework and the scanner is absolutely fundamental to the program; if anyone can provide me with a useful, understandable solution then I would be really grateful. I apologise if this question is still a little too broad - I am a complete novice to coding and after searching endlessly for hours to find a solution, I feel that this is my final resort.
I did a project on zbar a couple of years ago, and it took 6 months to get zbar working :)
Here's how I setup zbar:
Zbar python module does require zbar.exe. Go to http://zbar.sourceforge.net/download.html and click either ZBar 0.10 Windows installer if you have windows, or Linux builds. Run zbar-0.10-setup.exe and follow installation instructions.
The Zbar python module is available on pypi. That means a simple pip install zbar will install it.
To get .py examples of Zbar running, first download the source code for zbar (top link on http://zbar.sourceforge.net/download.html ), unzip the tar.bz2 file (use 7zip). Inside the unzipped folder there should be /examples. Inside the folder, you will find several examples (proccessor.py is a good one), which can be run just as you would normally run a python program.
Related
I've created a python program for object detection and OCR, using torchvision and tesseract, respectively (finetuned pretrained models). Now, when I run it on my laptop (with i7 7700), it takes about 4-5s to process a single image, and I'm satisfied with that.
What I would like to do is run the program on my Raspberry PI 4 (with 4GB ram, and running 64bit Raspbian). After trying out a few libraries' versions, I've managed to run it with some of them set to older ones (torch~=1.8.0, torchvision~=0.9.0, opencv-python~=4.5.3.56, numpy~=1.21.1, matplotlib~=3.4.2, Pillow~=8.3.1, pytesseract~=0.3.8). Now, that same program is run on the PI in about 60s per image, and what puzzles me most is the repeatedly spammed message OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.. Now this was confusing to me, because I've never needed to build anything from source before, but after some googling, I've figured out that OpenCV may be the problem, specifically the OpenBLAS library it uses. So, with the goal of building the OpenBLAS library with USE_OPENMP=1, I've downloaded the OpenBLAS repo and followed the guide given here.
Thing is, now this library is built and installed, I guess, and there is a new /opt/OpenBLAS folder present on my system with bin, include and lib subfolders. However, whenever I run my python script, it still takes about 60s and spams the same message, so I guess this has not quite fixed it. So, how do I make opencv-python use this newly compiled OpenBLAS? Do I have to compile it myself, and if so, how? I haven't managed to find anywhere in its guides how to build it with "custom" OpemBLAS. Lastly, if OpenCV is not the problem, where else could the OpenBLAS Warning stem from?
Thank you for your time :D
Just a small update, I've tried running export OMP_NUM_THREADS=1, and the warning disappeared, and the program runs in 45-50s for 1 image. But that is still not fast enough, so I've tried setting export OMP_NUM_THREADS=2, but that worsens the performance and the warning returns.
Not sure if this is the right place for this question - but I have a python script which uses ffmpeg. I want to create an application/executable file which includes the dependencies of Python and ffmpeg which I can distribute so that others don't have to install Python or ffmpeg on their machine to run the script.
Any ideas how this can be achieved?
I don't know whether my answer will be sufficient, but I hope it may lead to the answer.
First, FFMPEG is not a problem, it's very independent, needs no installation. However, I know nothing of Python nor do I know your target machines, the target operating systems.
There's a very popular online video downloader developed under Python (which can also use FFMPEG) called: youtube-dl. This runs independently under Windows without any additional installations. Maybe worth checking out?
youtube-dl link here: youtube-dl
I have been trying this for hours now, but cannot seem to get this right. I am trying to download Pocketsphinx for use of command recognition in Python.
So first thing I did was attempt to install SphinxBase, which is required for Pocketsphinx to work. So here we go. I downloaded the files, the tar.gz zip. I followed the instructions in the README document in order to install on windows.
To compile sphinxbase in Visual Studio 2010 Express (or newer):
1, unzip the file.
2, rename the directory to sphinxbase
3, go into the sphinxbase folder and click sphinxbase.sln
4, in the menu, choose Build -> Rebuild All -> Batch Build -> Build
I have never used visual before, but it seemed pretty self explanatory. First thing I did was unzip and rename. Next up I opened the SLN project in visual, selected all 6 projects, the Files>Build Selection. It build with all 6 projects succeeding. Great, that's done. Now was that really all? I had to do?
Next up was PocketSphinx. I downloaded the tar.gz again, and basically did the same process.
* load pocketsphinx.sln in pocketsphinx directory
* compile all the projects in PocketSphinx
All builds succeeded in being built. So... done, right? After this, I am lost. Most tutorials stop here and do not actually go into using Pocketsphinx in other languages. I need to be able to use it in Python.
So I did some digging around and found a setup_win32.py file under pocketsphinx/python. I tried to run this in the command prompt but go multiple errors. Now I am running windows 64 bit, but could this cause this issue?
http://hastebin.com/japobecusi.tex
So all in all, I just need help getting this to work with Python. I am very inexperienced in these things currently. Thanks
One more thing, I am considering switching to my Ubuntu Linux partition in order to almost make it easier on myself. Most programs, including this one, seem to only use windows 32, like 64 is unacceptable apparently. So would it benefit me to move over to a Linux platform to work in Python? Would it be easier?
Thanks for any help in advance.
It is not that trivial to build python with swig on windows. You can just pick latest prebuilt binaries here:
https://pypi.python.org/pypi/PyPocketSphinx/12608
At the corresponding repository https://github.com/bambocher/PyPocketSphinx you can find more detailed manual on how to build it.
Please note that for latest features you need a latest pocketsphinx version from github/subversion repository, a packaged 0.8 is not going to work.
Switch to Linux is also a good idea.
I'm not sure if I'm even asking this question correctly. I just built my first real program and I want to make it available to people in my office. I'm not sure if I will have access to the shared server, but I was hoping I could simply package the program (I hope I'm using this term correctly) and upload it to a website for my coworkers to download.
I know how to zip a file, but something tells me it's a little more complicated than that :) In fact, some of the people in my office who need the program installed do not have python on their computers already, and I would rather avoid asking everyone to install python before downloading my .py files from my hosting server.
So, is there an easy way to package my program, along with python and the other dependencies, for simple distribution from a website? I tried searching for the answer but I can't find exactly what I'm looking for. Oh, and since this is the first time I have done this- are there any precautions I need to take when sharing these files so that everything runs smoothly?
PyInstaller or py2exe can package your Python program.
Both are actively maintained. PyInstaller is actively maintained. py2exe has not been updated for at least a year. I've used each with success.
Also there is cx_Freeze which I have not used.
Take a look at http://www.py2exe.org/
I'm trying to write my own media player (like Foobar), and I'm having trouble tracking down a Python library that'll play MP3s. I know Pymedia does mp3s, but it looks outdated - the latest installer is for Python version 2.4, and I'm using 2.6. I've never had much success with Pygame, and Pyglet doesn't look like it has too much in the way of documentation. Are there any other alternatives?
There is http://pyglet.org/ and also have you tried http://code.google.com/p/mp3play/? It's also available from PyPi (http://pypi.python.org/pypi/mp3play/) However, I think mp3play is Win32 only for now.
Looking at the updates, there were commits within last couple of months.
I've been using PyMedia in Python 2.6.5 on Windows successfully. Caveats: the documentation is bad and wrong -- many of the tutorials have glaring errors or otherwise don't work -- so I had to do some experimentation and Googling to get my code to work right. Also for whatever reason the maintainers seem to have stopped updating the project site 4 years ago, though they seem to be actively doing something.
I found installers here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
The semi-active forum linked from their website includes some code maintainers who are semi-helpful. I'm jboyd99 if anyone is looking for tips.
For reasons that are beyond me the focus is on car audio systems, despite the fact that it is a fairly fully featured library that does some things no other free Python library does, like read MP3s into raw PCM data. The library has some flaws -- I'll probably use PyAudio or PyAudiere for actual playback for better control of synchrony issues.
Maybe it'd be simpler to write that part of your application in Python 2.4 as a separate "backend". This way you could use PyMedia (http://pymedia.org/) (as you mentioned) for the actual playback. It'd allow you to write your GUI in another Python version (like 2.6), which would also mean more decoupling of program components and parallelism (smoother GUI).
If you target only the Windows platform, then using Media Player via COM might help:
http://www.daniweb.com/code/snippet216465.html