How to use opencv 'superres' package on Python cv2? - python

A simple enough question - I can't seem to find how to import or use superres from cv2 on Python, even though it is documented:
http://docs.opencv.org/2.4/modules/superres/doc/super_resolution.html
Thanks.

I guess there is no official Python API support for the superres module, However you may get some Open Source implementations of the same algorithm from: SeRanet Github or Python superresolution module

Related

create golang bindings for a python module

I want to write golang bindings for an existing (third party) Python module.
The purpose is that I want to use the API that the Python module provides in Golang.
I already found golang bindings for Python's C API (go-python3 for py3 and go-python for py2), but I still haven't figured out how to translate a relatively complex Python module into Golang (i.e. how to deal with type safety in go for unsafe inputs and returns in python, etc).
What would be a good approach? Are there any pre-existing tools in that space? Are there any good examples for Golang bindings for Python code? (I couldn't find many tbh).
I want to use the API that the Python module provides in Golang.
Calling Python from Go is detailed recently in "Python and Go : Part I - gRPC" by Miki Tebeka.
You can see an example in ardanlabs/python-go/grpc
But, as shown in their next two articles, you can also:
compiled Go code to a shared library and used it from the Python interactive shell.
use a Python module that hides the low level details of working with a shared library and then package this code as a Python package.
Full example: ardanlabs/python-go/pyext.

Code completion is not working for OpenCV and Python

I am using Ubuntu 14.04. I have installed OpenCV using Adrian Rosebrock's guide. I am also using PyCharm for programming python and opencv.
My problem is that I can use code completion for cv2 modules but code completion wont work for instances initiated from cv2. An example is shown below.
This works:
This does not:
There is no run time error when I write my program as expected. Such that cap.isOpened() works without an error.
Though I am Window user, I also had faced similar problem with you. In my case, I could solve this problem by importing this way:
from cv2 import cv2
As I'm lack of knowledge of how does the python imports module, I can't explain you clearly about why this solve the problem, but it works anyway.
Good luck.
The openCV python module is a dynamically generated wrapper of the underlying c++ library. PyCharm relies on the availability of python source code to provide autocomplete functionality. When the source code is missing (as in the opencv case), pycharm will generate skeleton files with function prototypes and rely on those for autocompletion but with diminished capabilities.
As a result when you autocomplete at
cv2.
it can figure out that the module cv2 has the following members and provide suggestions.
On the other hand when you
cap = cv2.VideoCapture(file_name)
PyCharm can figure out that you just called a method from the cv2 module and assigned it to cap but has no information about the type of the result of this method and does not know where to go look for suggestions for
cap.
If you try the same things in shell mode, you will see the behavior you actually expected to see, since in shell mode will actually introspect live objects (it will ask the created cap object what members it has and provide those as suggestions)
You can also write stubs for the opencv module yourself to enable correct autocompletion in edit mode.
Take a look here
If anyone still is experiencing the issue, downgrading to opencv to 4.5.5.62 helped my case.
I am using PyCharm on windows 10 and faced similar issue on the intellisense for cv2.
This is my solution:
Pycharm>File>Manage IDE settings> Restore Default settings
Restart the Pycharm IDE
Reconfigure Python Interpretor

how to control ImageJ from Python 3.4.2

I am trying to use Python 3.4.2 to control ImageJ
what I want to do is from python code , I want to sent orders to imageJ to analayse some images, detecting edges, contrast, noise etc
there is a similar question here
How to connect ImageJ to python?
but there is no answer, like "install this, and control the Find Edges button with this command"
I wonder how can I do that, can somebody help me
I have found this link, and this link, and they say that it is possible by using "import ij" but there is no ij library that I can use or install.
also ImageJ website states in "How can I call ImageJ from my software?" that "If your software is written in another language such as C or Python, there are many ways to integrate Java functionality. You must choose which one is best for your particular requirements." but there are no specifics
this Google webpage says that with "py4ij" I can control imagej with python "Py4IJ - Python for ImageJ - plugin and IDE that allows Python and Jython access to the ImageJ"
but I am not sure how to run it, Help
as an alternative to Imagej is Fiji but I am not sure if python can control it or I have to use Fiji, and Fiji tutorial
my last alternative is Using OpenCV for image processing but I actually need to use ImageJ or Fiji, so OpenCV is not a valid answer
thanks
EDIT
according to the first answer, it suggest to write a CellProfiler's RunImageJ module, but my question is should I have to install CellProfiler? from here, following the examples here and here and running the module
or should I follow the native Python idea from this link
in any case the first answer link talks about Jython, but I can not use Jython, the latest version of it is based on python2.7 and I am using 3.4, and there is no development for jython 3.x
help
Integration of Python with ImageJ was recently discussed on the new ImageJ forum; see the Python scripting thread.
While it focuses on calling native-code-wrapped Python modules such as NumPy from ImageJ, the reverse direction (calling ImageJ from Python) is also addressed by some of the solutions, particularly CellProfiler's RunImageJ module. As discussed there, a dedicated programmer could start there and champion a more general solution for the benefit of the community.
In general, this issue is discussed on the ImageJ wiki on the Python page, particularly the section on limitations.

Using OpenCV TLD from Python

According to the release docs for OpenCV 3.0.0, it includes an implementation of the Tracking-Detection-Learning algorithm. There's even some very basic docs for the C++ code.
I downloaded and compiled the 3.0.0-beta, including the Python wrapper, and it seems to have succeeded, and although I can run the Python samples, I can't find any way to access and TLD functionality through the Python wrapper. I can't even find references to it in the code.
Is it actually included in the 3.0.0 release, and if so, how do I access it?
From what I find so far there is no instruction, explicitly telling the user how to use TLD. But, you can access TLD tracking modules just by changing the parameter For instance: cv2.Tracker_create("TLD")
For a demo, you can try https://github.com/Itseez/opencv_contrib/blob/master/modules/tracking/samples/tracker.py and change the like cv2.Tracker_create("MIL") to cv2.Tracker_create("TLD")
Note: you must install opencv along with opencv_contrib to make this demo work.
Good Luck
the tld c++ code for opencv3.0 is in the opencv_contrib repo,
unfortunately, atm python or java wrapping is not ready yet.

Where can i find vtk documentation for python?

I am trying to use VTK from python. I tried to find and could not realy find anything on the web which can be used for documentation. I tried looking at the c++ documentation but the methods are very different.
Thanks a lot
You could see the python examples at VTK's wiki. There is another resource by going to the official nightly documentation and looking for a particular class; in the section examples for many (not all) classes you can find implementations in python (also in c++ and tcl). A third option is to go to the source folder of your last downloaded release of VTK; look for the folder "Examples", there you will also find different VTK implementations in python (besides C++ and tcl)
I recommend you use Mayavi and TVTK from Enthought, the API is much pythonic:
http://code.enthought.com/projects/mayavi/
On the VTK website you can find the VTK User's Guide. It is pretty thorough.

Categories