Google app engine QR code decoder - python

I was wondering if there is a good library for python for decoding QR code. Basically what I would like is to give library image with QR code on it and the library would output contents saved in image.

Have you already looked at : http://pyqrcode.sourceforge.net/
If code compiling does not work for you, then there is also pure python implementation at : http://github.com/hcvst/pyqr

If you're still looking for something to do this a year later, you should check the ZBar project at http://zbar.sourceforge.net/. It looks like it started out for 1-D barcodes but has been expanded to include QR. It's implemented in C, LGPL licensed, and in addition to source has binaries for Linux, Windows and iPhone. Bindings available for Python, Perl, Ruby.
As of August 17, 2011 the core image processing portion of ZBar hasn't been updated since 2009 but there is recent activity on the iPhone development part of the project, which I'll interpret as the core being stable. There's also some activity in the SourceForge forums for the project.
It's also possible that pyxing (https://github.com/holizz/pyxing) would work but all that's there is an initial checkin of the port, so it's up to the (possible) user to check it.

I've looked before with no success. Two problems are that native c code can't be compiled and you can't get access to the file system.
pyqrcode didn't work out and neither did zxing.

Try qrtools
, It has a nice enough interface
from qrtools import QR
myCode = QR(filename=u"/home/psutton/Documents/Python/qrcodes/qrcode.png")
if myCode.decode():
print myCode.data
print myCode.data_type
Output
123456
text

Related

XCode or Visual Studio ? Building Human Motion detection iOS app using iPhone camera

I am a Bioengineer and need to build a Motion Capture Validation app on my iPhone 8. My goal is have my app capture the motion of a human's full body and analyse it to confirm if the person performed well the movement it should have done or not. The app flow is very simple: just have a “Welcome” page and then go onto the Exercise page, where the person will have its mouvement recorded. Mouvements are in 2D and very simple: for example, front-facing human raising straight leg to the side by 45 degrees.
To build the app for iOS, I know the only way is to code it in Swift, so I am considering using XCode to do so. However, my Motion Capture Analysis section will likely be in Python. If I understand correctly, XCode does not go well with Python. Is there a way to make XCode 11 working for Python? Or should I use Visual Studio Code?
How my motion capture analysis will work:
1. My app will have access to the camera of my iPhone (I do not care which one, does not matter).
2. The app will not record a video but take pictures (3 per second at least) from the camera's visual.
3. The image will be called by my Python code.
4. The code will transform it into a skeletal model.
5. The skeletal model obtained will be compared to a "good mouvement" skeletal model.
6. The python code will send a Yes/No validation message to the app.
5. The app will display a green tick to say the mouvement was well performed, and a red cross if not.
So, as you can see, when my app runs, it will be asking the Swift code (skeleton of my app) and the Python code (motion analysis of the person in the camera) to run together. A Python file will call the images from the “App”. And the Swift code will call my Python code to get a YES/NO answer. I do not know if that is something I can do in XCode?
Could you help me?
Best regards,
H.R.
It's easy to call python code using NSTask in swift for macOS projects. I am not sure in iOS, you can try using PythonKit
#if canImport(PythonKit)
import PythonKit
#else
import Python
#endif
print(Python.version)
By default, when you import Python, Swift searches system library paths for the newest version of Python installed. To use a specific Python installation, set the PYTHON_LIBRARY environment variable to the libpython shared library provided by the installation.
You can use like below-
let pythonInt: PythonObject = 1
In Swift, PythonObject represents an object from Python. All Python APIs use and return PythonObject instances.
Basic types in Swift (like numbers and arrays) are convertible to PythonObject. In some cases (for literals and functions taking PythonConvertible arguments), conversion happens implicitly. To explicitly cast a Swift value to PythonObject, use the PythonObject initializer.

Python to read services Description

I want my python script to read the windows service description, In order to decide whether to stop it \ make it run only manually..
The point is that I don't find the method that reads the Description.
(may be something like 'GetServiceDescription').
help anyone?
You can use wmi library also follow other answers like List running processes on 64-bit Windows.
i haven't tested this but this should be the short snippet to list them reference,
import wmi
c = wmi.WMI()
for service in c.Win32_Service(): #if its win32
print service.Name
Follow this tutorial
If you find it tough to follow may be looking at the tutorial may help or come again with another question.

ITK in Python: SimpleITK or not?

I have started to work with ITK for a week thanks to SimpleITK in Python. Even though, currently, I am satisfied with SimpleITK, I have noticed that some features such as the Powell optimization scheme or the OnePlusEvolutionary one are not available in SimpleITK. It seems to be the same with landmark-based registration methods.
So, I was wondering if there is a way to retrieve all the features available in ITK (in C++) in SimpleITK or if it is necessary to perform my own wrapping?
If not I will later learn C++ to do so!
Thanks!
You are correct. SimpleITK is limited in functionality. It is however possible to access the entire ITK library in Python using the WrapITK interface. This is an old interface which I don't believe has been updated for a while. However, it is still possible to compile new builds from source and use WrapITK.
The process is not exactly smooth. I have done the build on a Windows machine in the past and had then noted some of the not-so-smooth-steps that I had to encounter. I'll lay those down here. Since you haven't mentioned your OS, I'm going to go ahead explain the setup for Windows. Let's see if you're able to get it up and running.
ITK-4.6 + Python2.7 + CMake + VS2008 professional (all 32-bit)
Nothing later than VS2008 can compile GCCXML, which is required for generating python bindings
After configuring CMAKE, the following flags need to be additionally set:
ITK_WRAP_PYTHON
ITK_WRAP_* (all types: float, double, etc.)
ITK_BUILD_SHARED_LIBS (gets automatically set if first flag is set)
In VS2008, build in Release mode only. Number of projects in the project explorer will be more than 500. Around 300-350 should get built.
When building, make sure that you have an accessible internet conection for downloading GCCXML (which will likely get downloaded after you have started the build in VS2008). There should be no error while verifying the download. If there is, it might be because of directory creation permission errors.
The project should get built with NO ERRORS
Copy the WrapITK.pth file from the ITK build/Wrapping/Generators/Python/Release to Python/Lib/site-packages
Add the following to your Path variable:
C:\ProgramLibs\ITK\build2008\lib\Release
C:\ProgramLibs\ITK\build2008\bin\Release
C:\ProgramLibs\ITK\build2008\lib
Now ITK should work properly (below is a test python file that you can use to run a sanity check on the build). Except every time you call itk.Image the first time in your program or on the Python interpreter, there are a dozen warnings and they take time to execute that. This is a known issue. Once you are past this, it's smooth.
Test file
import itk
pixelType = itk.UC
imageType = itk.Image[pixelType, 2]
readerType = itk.ImageFileReader[imageType]
writerType = itk.ImageFileWriter[imageType]
reader = readerType.New()
writer = writerType.New()
reader.SetFileName("<input image file location>")
writer.SetFileName("D:/Output.png")
writer.SetInput( reader.GetOutput() )
writer.Update()
There is also WrapITK, which is a python wrapping of ITK that you can enable to compile with ITK (so, you'll have to compile it by yourself but you will not need to code the warpping at least). See http://kitware.com/blog/home/post/888, http://www.itk.org/Wiki/ITK/Wrapping , http://www.itk.org/Wiki/ITK/Release_4/Wrapping/WrapITK_Installation.t .
Note however that probably not all filters are wrapped (http://www.itk.org/Wiki/Proposals:Increasing_WrapITK_Coverage#List_of_Unwrapped_Filters , last updated in 2009 so probably now the situation is better).
The only compiled wrapITK package I came across is Devide-RE https://www.youtube.com/watch?v=-b1zS536R2M (with an older version of ITK, 3.2 if I remember correctly), but maybe also Slicer and Vistrail have it (http://www.itk.org/pipermail/insight-users/2009-August/031910.html)

Using a TLB-defined interface with Python and COM

I will try to keep this question as tight as possible, but if it seems that I am saying insane things, it is almost certainly because I am ignorant of some key point, so please do correct me.
I am writing a program, in a Windows environment, that will interface with an existing application that has a COM interface to allow 3rd-party software to interact with it.
I have read all of the documentation for this application, and it says that there is a TLB file that defines the functions and data available via COM.
How do I use the TLB file with python? How do I discover the progID of the application so that I can interface with it (this isn't given in the documentation).
I'm pretty lost. I have a fair amount of experience with Python, but I am completely new to developing in a Windows environment. Any help would be enormously helpful. I have been reading all the documentation on win32com, but I still have no clue what to do, as no one addresses -- as far as I have seen -- bringing in a TLB file.
The questions asked is to link the custom TLB file with COM client to be developed in python. I have done a small example code for my COM server developed in C# and same is accessed by python client using "comtypes" package.
The below snippet of code gives:
import comtypes.client as CC
import comtypes
ccHandle = CC.CreateObject("CSharpServer.InterfaceImplementation")
print (ccHandle)
import comtypes.gen.CSharpServer as CS
InterfaceHandle = ccHandle.QueryInterface(CS.IManagedInterface)
print ("output of PrintHi function = ", InterfaceHandle.PrintHi("World"))
The above python script is for the C# COM server code available at http://msdn.microsoft.com/en-us/library/aa645738(v=vs.71).aspx (refer to the File 1: CSharpServer.cs).
OK, it's been a while since I've done this, and I'm not a COM expert by any means. Read the COM chapter from Python Programming on Windows to see how to do this. Follow along with the examples (trying things out against Excel) to get a feel of how things work.
First off, install the PyWin32 Extensions if you haven't already. This is the package that gives you pythonwin.exe and the COM interface modules. Get it from here.
Then you are going to open the "COM Makepy Utility" from PythonWin's Tools menu. Browse through the list of registered COM components (some will be typelibs, others DLLs) until you identify the one you have (you have to do a bit of detective work). Click OK to generate the Python glue code. You will then need to run it again with the -i command-line argmument to generate the boilerplate code so your python script can use this glue. Here's a paraphrase of the O'Reilly example for the Microsoft Excel Object library:
import win32com.client
from win32com.client import gencache
gencache.EnsureModule('{00020813-0000-0000-C000-000000000046}', 0, 1, 2)
earlyBound = win32com.client.Dispatch("Excel.Application")
lateBound = win32com.client.dynamic.Dispatch("Excel.Application")
print earlyBound.ActiveCell()
Using early-bound objects is optional, but it does improve performance.
To find the ProgID is again a bit of detective work, although this answer seems to imply it's going to be hard. Try poking around the HKEY_CLASSES_ROOT hive of the registry with RegEdit to see if you see a ProgID that looks promising.

Extract Assembly Version from DLL using Python

I'm trying to extract some version information from a DLL using python. I read this question:
Python windows File Version attribute
It was helpful, but I also need to get the 'Assembly version' from the DLL. It's there when I right click and look on the versions tab, but not sure how I extract this with python.
On this page:
http://timgolden.me.uk/python/win32_how_do_i/get_dll_version.html
Tim Golden says:
You can use the slightly more messy
language-dependent code in the demos
which come with pywin32 to find the
strings in the box beneath it.
Can someone point me to the example that might be useful? I looked in the win32api directories but there's nothing obvious. Would I find a solution there?
If you would rather not introduce a dependency on Python.Net, you can also use the win32 api directly:
from win32api import GetFileVersionInfo, LOWORD, HIWORD
def get_version_number (filename):
info = GetFileVersionInfo (filename, "\\")
ms = info['FileVersionMS']
ls = info['FileVersionLS']
return HIWORD (ms), LOWORD (ms), HIWORD (ls), LOWORD (ls)
Source: http://timgolden.me.uk/python/win32_how_do_i/get_dll_version.html
I'm not sure you can get at this information by using native code. The usual way of obtaining the assembly info is by running .Net code (e.g. C#). So I'm guessing in order to be able to do the same from python you'll need to run some .Net python interpreter. See for example http://pythonnet.github.io/

Categories

Resources